Fix LXC without group error

This commit is contained in:
Sven Velt 2024-09-20 09:49:47 +02:00
parent e8761ab285
commit 08e0e97e12
2 changed files with 8 additions and 2 deletions

View file

@ -19,7 +19,10 @@ for ctname in ctnames:
ct = lxc.Container(ctname) ct = lxc.Container(ctname)
if ct.running: 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: if not group in inventory:
inventory[group] = { inventory[group] = {
'hosts': [], 'hosts': [],

View file

@ -19,7 +19,10 @@ for ctname in ctnames:
ct = lxc.Container(ctname) ct = lxc.Container(ctname)
if ct.running: 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: if not group in inventory:
inventory[group] = { inventory[group] = {
'hosts': [], 'hosts': [],