Skip to content

Commit

Permalink
Remove host from ungrouped if it belongs to any other group
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergej Gureev committed Oct 30, 2020
1 parent d0235fc commit 4bd1278
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ func TestBelongToBasicGroups(t *testing.T) {

func TestGroupStructure(t *testing.T) {
v := parseString(t, `
host5
[web:children]
nginx
apache
Expand Down
3 changes: 3 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (inventory *InventoryData) parse(reader *bufio.Reader) error {
}
for k, v := range hosts {
activeGroup.Hosts[k] = v
if activeGroup.Name != "ungrouped" {
delete(inventory.Groups["ungrouped"].Hosts, k)
}
}
for _, host := range hosts {
inventory.Hosts[host.Name] = host
Expand Down

0 comments on commit 4bd1278

Please sign in to comment.