diff --git a/changelogs/fragments/4378-proxmox-inventory-tags.yml b/changelogs/fragments/4378-proxmox-inventory-tags.yml new file mode 100644 index 0000000000..04110977d5 --- /dev/null +++ b/changelogs/fragments/4378-proxmox-inventory-tags.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - proxmox inventory plugin - fixed the ``tags_parsed`` field when Proxmox + returns a single space for the ``tags`` entry (https://github.com/ansible-collections/community.general/pull/4378). diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index fc56297490..f2dba5309b 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -323,8 +323,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): # Additional field containing parsed tags as list if config == 'tags': - parsed_key = self.to_safe('%s%s' % (key, "_parsed")) - properties[parsed_key] = [tag.strip() for tag in value.split(",")] + stripped_value = value.strip() + if stripped_value: + parsed_key = key + "_parsed" + properties[parsed_key] = [tag.strip() for tag in stripped_value.split(",")] # The first field in the agent string tells you whether the agent is enabled # the rest of the comma separated string is extra config for the agent