summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn R Barker <john@johnrbarker.com>2017-12-13 19:19:19 +0000
committeransibot <ansibot@users.noreply.github.com>2017-12-13 14:19:19 -0500
commitcfb15b0272c7aa6e26657fe8f7f13fc6a02866d7 (patch)
tree36172b18c41277cf5371245af89b80701810ad90
parent2f67d3a4f33f9d7261ffa3f82595aa99f32bc527 (diff)
downloadansible-cfb15b0272c7aa6e26657fe8f7f13fc6a02866d7.tar.gz
Revert "YAML inventory unit test: fix test inventory format (#33828)" (#33869)
This reverts commit dfb2f346d8141028ba8d4efd705671babc90ed3c. https://github.com/ansible/ansible/pull/33828
-rw-r--r--lib/ansible/plugins/inventory/yaml.py3
-rw-r--r--test/units/plugins/inventory/test_inventory.py14
2 files changed, 3 insertions, 14 deletions
diff --git a/lib/ansible/plugins/inventory/yaml.py b/lib/ansible/plugins/inventory/yaml.py
index 4a7582a7bf..d9109177a9 100644
--- a/lib/ansible/plugins/inventory/yaml.py
+++ b/lib/ansible/plugins/inventory/yaml.py
@@ -140,9 +140,6 @@ class InventoryModule(BaseFileInventoryPlugin):
for host_pattern in group_data['hosts']:
hosts, port = self._parse_host(host_pattern)
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:
self.display.warning('Skipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are valid' % (key, group))
diff --git a/test/units/plugins/inventory/test_inventory.py b/test/units/plugins/inventory/test_inventory.py
index ab6bdac84f..07934aa49b 100644
--- a/test/units/plugins/inventory/test_inventory.py
+++ b/test/units/plugins/inventory/test_inventory.py
@@ -113,7 +113,7 @@ class TestInventory(unittest.TestCase):
)
-class TestInventoryPlugins(unittest.TestCase):
+class IniInventory(unittest.TestCase):
def test_empty_inventory(self):
inventory = self._get_inventory('')
@@ -168,21 +168,13 @@ class TestInventoryPlugins(unittest.TestCase):
---
all:
hosts:
- test1:
- test2:
+ test1
+ test2
""")}
C.INVENTORY_ENABLED = ['yaml']
fake_loader = DictDataLoader(inventory_content)
im = InventoryManager(loader=fake_loader, sources=filename)
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):