Browse Source

Fix issue with same host and group names

When host and group name is the same, the inventory fails to run.
Use different method of adding host to inventory with this case.

Fixes rhbz#2017495
Change-Id: Iad288c3c11d0791be33b379554577eab8381b44d
changes/11/816311/1
Sagi Shnaidman 7 months ago
parent
commit
11c7cd23f8
  1. 6
      plugins/inventory/openstack.py

6
plugins/inventory/openstack.py

@ -311,7 +311,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
for group_name, group_hosts in groups.items():
gname = self.inventory.add_group(group_name)
for host in group_hosts:
self.inventory.add_child(gname, host)
if gname == host:
display.vvvv("Same name for host %s and group %s" % (host, gname))
self.inventory.add_host(host, gname)
else:
self.inventory.add_child(gname, host)
def _get_groups_from_server(self, server_vars, namegroup=True):
groups = []

Loading…
Cancel
Save