diff --git a/inventory_lxc.py b/inventory_lxc.py index 26f32d3..71a8c2f 100755 --- a/inventory_lxc.py +++ b/inventory_lxc.py @@ -19,7 +19,10 @@ for ctname in ctnames: ct = lxc.Container(ctname) if ct.running: - for group in ct.get_running_config_item('lxc.group').rstrip().split('\n'): + groups = ct.get_running_config_item('lxc.group') + if not groups: + groups = 'ungrouped' + for group in groups.rstrip().split('\n'): if not group in inventory: inventory[group] = { 'hosts': [], diff --git a/inventory_lxc_ip.py b/inventory_lxc_ip.py index 06537ee..ffa4522 100755 --- a/inventory_lxc_ip.py +++ b/inventory_lxc_ip.py @@ -19,7 +19,10 @@ for ctname in ctnames: ct = lxc.Container(ctname) if ct.running: - for group in ct.get_running_config_item('lxc.group').rstrip().split('\n'): + groups = ct.get_running_config_item('lxc.group') + if not groups: + groups = 'ungrouped' + for group in groups.rstrip().split('\n'): if not group in inventory: inventory[group] = { 'hosts': [],