1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Revert "YAML inventory unit test: fix test inventory format (#33828)" (#33869)

This reverts commit dfb2f346d8.

https://github.com/ansible/ansible/pull/33828
This commit is contained in:
John R Barker 2017-12-13 19:19:19 +00:00 committed by ansibot
parent 2f67d3a4f3
commit cfb15b0272
2 changed files with 3 additions and 14 deletions

View file

@ -140,9 +140,6 @@ class InventoryModule(BaseFileInventoryPlugin):
for host_pattern in group_data['hosts']: for host_pattern in group_data['hosts']:
hosts, port = self._parse_host(host_pattern) hosts, port = self._parse_host(host_pattern)
self._populate_host_vars(hosts, group_data['hosts'][host_pattern] or {}, group, port) self._populate_host_vars(hosts, group_data['hosts'][host_pattern] or {}, group, port)
if group == 'all':
for host in hosts:
self.inventory.add_host(host, group='ungrouped', port=port)
else: else:
self.display.warning('Skipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are valid' % (key, group)) self.display.warning('Skipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are valid' % (key, group))

View file

@ -113,7 +113,7 @@ class TestInventory(unittest.TestCase):
) )
class TestInventoryPlugins(unittest.TestCase): class IniInventory(unittest.TestCase):
def test_empty_inventory(self): def test_empty_inventory(self):
inventory = self._get_inventory('') inventory = self._get_inventory('')
@ -168,21 +168,13 @@ class TestInventoryPlugins(unittest.TestCase):
--- ---
all: all:
hosts: hosts:
test1: test1
test2: test2
""")} """)}
C.INVENTORY_ENABLED = ['yaml'] C.INVENTORY_ENABLED = ['yaml']
fake_loader = DictDataLoader(inventory_content) fake_loader = DictDataLoader(inventory_content)
im = InventoryManager(loader=fake_loader, sources=filename) im = InventoryManager(loader=fake_loader, sources=filename)
self.assertTrue(im._inventory.hosts) self.assertTrue(im._inventory.hosts)
self.assertIn('test1', im._inventory.hosts)
self.assertIn('test2', im._inventory.hosts)
self.assertIn(im._inventory.get_host('test1'), im._inventory.groups['all'].hosts)
self.assertIn(im._inventory.get_host('test2'), im._inventory.groups['all'].hosts)
self.assertEqual(len(im._inventory.groups['all'].hosts), 2)
self.assertIn(im._inventory.get_host('test1'), im._inventory.groups['ungrouped'].hosts)
self.assertIn(im._inventory.get_host('test2'), im._inventory.groups['ungrouped'].hosts)
self.assertEqual(len(im._inventory.groups['ungrouped'].hosts), 2)
def _get_inventory(self, inventory_content): def _get_inventory(self, inventory_content):