diff options
author | Daniel Hokka Zakrisson <daniel@hozac.com> | 2012-11-25 12:42:30 +0100 |
---|---|---|
committer | Daniel Hokka Zakrisson <daniel@hozac.com> | 2012-11-25 12:42:30 +0100 |
commit | 0c70abfaa9a70ca91099ecfd8d0abaa3d28eb648 (patch) | |
tree | ee83076889766310a6dc5cee5c6f786a2fbbd0b6 | |
parent | 5504f13c68f703fc4d67b1b1c5d3dfd58fe17cf2 (diff) | |
download | ansible-0c70abfaa9a70ca91099ecfd8d0abaa3d28eb648.tar.gz |
Make sure any existing groups gets reused
-rw-r--r-- | lib/ansible/inventory/ini.py | 5 | ||||
-rw-r--r-- | test/TestInventory.py | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index ddf1ba9534..4b1607d884 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -67,9 +67,10 @@ class InventoryParser(object): active_group_name = line.replace("[","").replace("]","").strip() if line.find(":vars") != -1 or line.find(":children") != -1: active_group_name = active_group_name.rsplit(":", 1)[0] - self.groups[active_group_name] = Group(name=active_group_name) + if active_group_name not in self.groups: + self.groups[active_group_name] = Group(name=active_group_name) active_group_name = None - else: + elif active_group_name not in self.groups: new_group = self.groups[active_group_name] = Group(name=active_group_name) all.add_child_group(new_group) elif line.startswith("#") or line == '': diff --git a/test/TestInventory.py b/test/TestInventory.py index 8985b1ec6b..5c444d9e96 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -142,7 +142,7 @@ class TestInventory(unittest.TestCase): print vars expected = dict( - a='1', b='2', c='3', d='100002', rga='1', rgb='2', rgc='3', + a='1', b='2', c='3', d='10002', rga='1', rgb='2', rgc='3', inventory_hostname='rtp_a', inventory_hostname_short='rtp_a', group_names=[ 'eastcoast', 'nc', 'redundantgroup', 'redundantgroup2', 'redundantgroup3', 'rtp', 'us' ] ) |