mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
plugins/inventory/lxd.py: fix listing of containers without os / release (#4351)
* plugins/inventory/lxd.py: fix listing of containers without os / release In some cases, a container might be present, that was initialized empty, therefore lacking meta information about the os or the release. Test if the data entry is None to avoid calling lower on it. * Update plugins/inventory/lxd.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/inventory/lxd.py Co-authored-by: Felix Fontein <felix@fontein.de> * Create 4351-inventory-lxd-handling_metadata_wo_os_and_release.yml * fix yaml readability of changelog fragment * Update changelogs/fragments/4351-inventory-lxd-handling_metadata_wo_os_and_release.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Malte Kuhn <mkuhn@maxcluster.de>
This commit is contained in:
parent
9618fb9786
commit
421ccd5dc9
2 changed files with 10 additions and 2 deletions
|
@ -0,0 +1,4 @@
|
|||
bugfixes:
|
||||
- |
|
||||
lxd inventory plugin - do not crash if OS and release metadata are not present
|
||||
(https://github.com/ansible-collections/community.general/pull/4351).
|
|
@ -666,9 +666,13 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
# add network informations
|
||||
self.build_inventory_network(instance_name)
|
||||
# add os
|
||||
self.inventory.set_variable(instance_name, 'ansible_lxd_os', self._get_data_entry('inventory/{0}/os'.format(instance_name)).lower())
|
||||
v = self._get_data_entry('inventory/{0}/os'.format(instance_name))
|
||||
if v:
|
||||
self.inventory.set_variable(instance_name, 'ansible_lxd_os', v.lower())
|
||||
# add release
|
||||
self.inventory.set_variable(instance_name, 'ansible_lxd_release', self._get_data_entry('inventory/{0}/release'.format(instance_name)).lower())
|
||||
v = self._get_data_entry('inventory/{0}/release'.format(instance_name))
|
||||
if v:
|
||||
self.inventory.set_variable(instance_name, 'ansible_lxd_release', v.lower())
|
||||
# add profile
|
||||
self.inventory.set_variable(instance_name, 'ansible_lxd_profile', self._get_data_entry('inventory/{0}/profile'.format(instance_name)))
|
||||
# add state
|
||||
|
|
Loading…
Reference in a new issue