Repository: ansible-collections/community.general

Issue:
Proxmox inventory module - missing description
### Summary

When the description of a Proxmox VM contains commas, it is removed from the output.

### Issue Type

Bug Report

### Component Name

community.general.proxmox inventory plugin

### Ansible Version

```console (paste below)
$ ansible --version
ansible [core 2.12.3]
  config file = None
  configured module search path = ['/home/tseeker/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/tseeker/.virtualenvs/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /home/tseeker/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/tseeker/.virtualenvs/ansible/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.0.3
  libyaml = True


```


### Community.general Version

```console (paste below)
$ ansible-galaxy collection list community.general

# /home/tseeker/.virtualenvs/ansible/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 4.5.0  
```


### Configuration

Irrelevant

### OS / Environment

Irrelevant

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
Using a very basic inventory entry :
```yaml (paste below)
---
plugin: community.general.proxmox

url: https://proxmox.example.org:8006
validate_certs: false
user: test@pve
password: (password)
want_facts: true
```

On a VM that has a description which looks like this : 
```
# qm config 1234 | grep description
description: this,is,a,test
```

Running the following command : 
```
ansible-inventory --host the-vm | grep description
```

### Expected Results

The test above should return
```
"proxmox_description": "this,is,a,test",
```

### Actual Results

The test above returns nothing, the description field is missing from the output.

This is caused by the code below in the `plugins/inventory/proxmox.py` file, line 336 : 
```python
                if not (isinstance(value, int) or ',' not in value):
                    # 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(","))
                    except Exception:
                        continue
```

Since no special handling exists for the description, the plugin attempts to generate a dict from it and fails to do so.

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* `lib/ansible/plugins/inventory`

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
!component =plugins/inventory/proxmox.py
Files identified in the description:
* [`plugins/inventory/proxmox.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/inventory/proxmox.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Ajpantuso @Thulium-Drake @ilijamt @joshainglis @karmab @tleguern
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I was looking into patching it to allow the `description` key through whatever it contains, but I suspect it is slightly more complicated than that.

As far as I understand it, the idea behind this chunk of code is to generate dictionaries from strings that look like `key1=value1,key2=value2,...`. However, this will not work if the string only contains one value, for example :

```
$ ansible-inventory --host the-vm | grep proxmox_boot
    "proxmox_boot": "order=virtio0",
```

I will submit a pull requests that attempts to fix both issues shortly.

Resolving patch:
diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py
--- a/plugins/inventory/proxmox.py
+++ b/plugins/inventory/proxmox.py
@@ -307,7 +307,7 @@ def _get_vm_config(self, node, vmid, vmtype, name):
         self.inventory.set_variable(name, vmtype_key, vmtype)
 
         plaintext_configs = [
-            'tags',
+            'description',
         ]
 
         for config in ret:
@@ -333,11 +333,11 @@ def _get_vm_config(self, node, vmid, vmtype, name):
                     if agent_iface_value:
                         self.inventory.set_variable(name, 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
 


Test patch: