aboutsummaryrefslogtreecommitdiff
path: root/foreman_ansible_inventory.py
diff options
context:
space:
mode:
Diffstat (limited to 'foreman_ansible_inventory.py')
-rwxr-xr-xforeman_ansible_inventory.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/foreman_ansible_inventory.py b/foreman_ansible_inventory.py
index b1c0f19..dd4f5a3 100755
--- a/foreman_ansible_inventory.py
+++ b/foreman_ansible_inventory.py
@@ -144,9 +144,11 @@ class ForemanInventory(object):
return {}
hostgroup = self._get_hostgroup_by_id(hid)
- ancestry = hostgroup.get('ancestry', '').split('/')
- # Append top level hostgroup last to overwrite lower
- # level values
+ ancestry_path = hostgroup.get('ancestry', '')
+ ancestry = ancestry_path.split('/') if ancestry_path is not None else []
+
+ # Append top level hostgroup last to overwrite lower level
+ # values
ancestry.append(hid)
params = {}