Skip to content

Commit

Permalink
hostname parsing fixed for groups
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed Dec 10, 2019
1 parent a5a2b23 commit 491be17
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class Group {
if (Group.hasHosts(groupName)) {
// add hostnames
for(var hostname in hostsIni[groupName]) {
// check if hostname is valid
if (Group.isValidHostname(hostname)) {
groupList[_groupName].hostnames.push(hostname)
}
groupList[_groupName].hostnames.push(hostname.split(' ')[0])
}
}
else if (Group.hasSubgroups(groupName)) {
Expand Down
2 changes: 2 additions & 0 deletions TreeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ class TreeBuilder {
var subnode = TreeBuilder._internal_cloneObject(TreeBuilder._internal_findSubnode(flatGroupList, node.inventory, node.subgroups[i]))

TreeBuilder.internal_addSubgroupsToNode(flatGroupList, flatHostList, subnode)
subnode.variables = Object.assign(subnode.variables, node.variables)
node.nodes.push(subnode)
}

for (var i in node.hostnames) {
var host = TreeBuilder._internal_cloneObject(TreeBuilder._internal_findSubnode(flatHostList, node.inventory, node.hostnames[i]))
host.variables = Object.assign(host.variables, node.variables)
node.nodes.push(host)
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/inventoryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ describe('#inventoryTest()', function() {
for(var i in groupnames) {
expect( groups.map(g => g.name).includes(groupnames[i]) ).to.be.true
}
expect( groups.find(g => g.name == 'atlanta').hostnames.includes('host1') ).to.be.true
expect( groups.find(g => g.name == 'atlanta').hostnames.includes('host2') ).to.be.true

const emptySubgroups = ['atlanta', 'raleigh', 'northeast', 'southwest', 'northwest', 'ungrouped']
for(var i in emptySubgroups) {
Expand Down
Loading

0 comments on commit 491be17

Please sign in to comment.