diff --git a/changelogs/fragments/4349-proxmox-inventory-dict-facts.yml b/changelogs/fragments/4349-proxmox-inventory-dict-facts.yml new file mode 100644 index 0000000000..fcf557c3ed --- /dev/null +++ b/changelogs/fragments/4349-proxmox-inventory-dict-facts.yml @@ -0,0 +1,8 @@ +--- +bugfixes: + - proxmox inventory plugin - fixed the ``description`` field being ignored if + it contained a comma + (https://github.com/ansible-collections/community.general/issues/4348). + - proxmox inventory plugin - always convert strings that follow the + ``key=value[,key=value[...]]`` form into dictionaries + (https://github.com/ansible-collections/community.general/pull/4349). diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index 67fe2b3a6c..fc56297490 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -310,7 +310,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): properties[self._fact('vmtype')] = vmtype plaintext_configs = [ - 'tags', + 'description', ] for config in ret: @@ -334,11 +334,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces")) properties[agent_iface_key] = agent_iface_value - if not (isinstance(value, int) or ',' not in value): + if config not in plaintext_configs and not isinstance(value, int) and all("=" in v for v in value.split(",")): # split off strings with commas to a dict # skip over any keys that cannot be processed try: - value = dict(key.split("=") for key in value.split(",")) + value = dict(key.split("=", 1) for key in value.split(",")) except Exception: continue