From 95909065ee34ef273444ca96004bc0556c345ea6 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 7 Feb 2016 15:21:59 +0100 Subject: Don't fail on host without hostgroup --- foreman_ansible_inventory.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'foreman_ansible_inventory.py') 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 = {} -- cgit v1.2.3