Fixes #32146 Fixes reconcile inventory to correctly remove hosts from ungrouped
This commit is contained in:
parent
57da6319e1
commit
e02c72d856
2 changed files with 2 additions and 2 deletions
|
@ -128,7 +128,7 @@ class InventoryData(object):
|
||||||
if self.groups['ungrouped'] in mygroups:
|
if self.groups['ungrouped'] in mygroups:
|
||||||
# clear ungrouped of any incorrectly stored by parser
|
# clear ungrouped of any incorrectly stored by parser
|
||||||
if set(mygroups).difference(set([self.groups['all'], self.groups['ungrouped']])):
|
if set(mygroups).difference(set([self.groups['all'], self.groups['ungrouped']])):
|
||||||
host.remove_group(self.groups['ungrouped'])
|
self.groups['ungrouped'].remove_host(host)
|
||||||
|
|
||||||
elif not host.implicit:
|
elif not host.implicit:
|
||||||
# add ungrouped hosts to ungrouped, except implicit
|
# add ungrouped hosts to ungrouped, except implicit
|
||||||
|
|
|
@ -198,6 +198,6 @@ class TestInventoryPlugins(unittest.TestCase):
|
||||||
all_hosts = set(host.name for host in inventory.groups['all'].get_hosts())
|
all_hosts = set(host.name for host in inventory.groups['all'].get_hosts())
|
||||||
self.assertEqual(set(['host1', 'host2', 'host3', 'host4', 'host5']), all_hosts)
|
self.assertEqual(set(['host1', 'host2', 'host3', 'host4', 'host5']), all_hosts)
|
||||||
ungrouped_hosts = set(host.name for host in inventory.groups['ungrouped'].get_hosts())
|
ungrouped_hosts = set(host.name for host in inventory.groups['ungrouped'].get_hosts())
|
||||||
self.assertEqual(set(['host1', 'host2', 'host3']), ungrouped_hosts)
|
self.assertEqual(set(['host1', 'host2']), ungrouped_hosts)
|
||||||
servers_hosts = set(host.name for host in inventory.groups['servers'].get_hosts())
|
servers_hosts = set(host.name for host in inventory.groups['servers'].get_hosts())
|
||||||
self.assertEqual(set(['host3', 'host4', 'host5']), servers_hosts)
|
self.assertEqual(set(['host3', 'host4', 'host5']), servers_hosts)
|
||||||
|
|
Loading…
Reference in a new issue