diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-02-07 15:21:59 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-02-07 15:45:53 +0100 |
commit | 95909065ee34ef273444ca96004bc0556c345ea6 (patch) | |
tree | 39a62e15e9f55cb4d48d1120a63ebedf7d5ccb68 | |
parent | 3a09d1a5058a1baf80da84686c219f830a04620a (diff) |
Don't fail on host without hostgroup
-rwxr-xr-x | foreman_ansible_inventory.py | 8 |
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 = {} |