From 08e0e97e12068cb7ea9152fe17aad8cd663fc322 Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Fri, 20 Sep 2024 09:49:47 +0200 Subject: [PATCH] Fix LXC without group error --- inventory_lxc.py | 5 ++++- inventory_lxc_ip.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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': [],