Repository: ansible-collections/community.general

Issue:
proxmox: plugin gets very angry if remote proxmoxer is not new enough: TypeError: __init__() got an unexpected keyword argument 'token_name'
### Summary

Proxmox expects some specific version of proxmoxer on the remote but does not verify it. 
It causes mismatched versions emitting a bit cryptic parameter errors.

### Issue Type

Bug Report

### Component Name

https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/misc/proxmox.py


### Ansible Version

ansible [core 2.13.4]


### Community.general Version

community.general 5.6.0  


### Configuration

_No response_

### OS / Environment

Debian/bookworm

### Steps to Reproduce

Use API tokens when remote proxmoxer is `python3-proxmoxer v1.0.3-2` or similar. Fail.

### Expected Results

The problem is that old proxmoxer https backend doesn't handle tokens:
```python
class Backend(object):
    def __init__(self, host, user, password, port=8006, verify_ssl=True,
                 mode='json', timeout=5, auth_token=None, csrf_token=None):
```

while new one does
```python
class Backend(object):
    def __init__(self, host, user=None, password=None, otp=None, port=None,
                 verify_ssl=True, mode='json', timeout=5, auth_token=None,
                 csrf_token=None, token_name=None, token_value=None, service='PVE'):
```
I'd expect either verifying dependant module version/API or handle the error gracefully.


### Actual Results

```
Traceback (most recent call last):
  File "/tmp/ansible_community.general.proxmox_payload_xgpdvxe0/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/module_utils/proxmox.py", line 101, in _connect
    return ProxmoxAPI(api_host, verify_ssl=validate_certs, **auth_args)
  File "/usr/lib/python3/dist-packages/proxmoxer/core.py", line 106, in __init__
    self._backend = importlib.import_module('.backends.%s' % backend, 'proxmoxer').Backend(host, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'token_name'
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/cloud/misc/proxmox.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/misc/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 @UnderGreen @joshainglis @karmab @tleguern
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I am having the same situation. In my case, I installed the latest version of `proxmoxer` via `pip` in my laptop and installed the `python3-proxmoxer` package version 1.0.3-2 on my server running Debian 11 Bullseye (my mistake). When I finished testing the playbook and wanted to run it remotely on the server, this error appeared:

```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: __init__() got an unexpected keyword argument 'token_name'
fatal: [proxmox3.domain.com]: FAILED! => {"changed": false, "msg": "__init__() got an unexpected keyword argument 'token_name'"}
```

While I understand that a more modern version is required in the server (I'll start working on that today) I agree with @grinapo that a more elegant, precise and explanatory message should be given back to the user (e.g. "The version of proxmoxer that you are running on the host is too old. At least version X.Y is required").

Thanks in advanced.
Files identified in the description:
* [`plugins/modules/proxmox.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/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 --->

Resolving patch:
diff --git a/plugins/doc_fragments/proxmox.py b/plugins/doc_fragments/proxmox.py
--- a/plugins/doc_fragments/proxmox.py
+++ b/plugins/doc_fragments/proxmox.py
@@ -29,11 +29,13 @@ class ModuleDocFragment(object):
   api_token_id:
     description:
       - Specify the token ID.
+      - Requires C(proxmoxer>=1.1.0) to work.
     type: str
     version_added: 1.3.0
   api_token_secret:
     description:
       - Specify the token secret.
+      - Requires C(proxmoxer>=1.1.0) to work.
     type: str
     version_added: 1.3.0
   validate_certs:
diff --git a/plugins/module_utils/proxmox.py b/plugins/module_utils/proxmox.py
--- a/plugins/module_utils/proxmox.py
+++ b/plugins/module_utils/proxmox.py
@@ -100,6 +100,8 @@ def _connect(self):
         if api_password:
             auth_args['password'] = api_password
         else:
+            if self.version() < LooseVersion('1.1.0'):
+                self.module.fail_json('Using "token_name" and "token_value" require proxmoxer>=1.1.0')
             auth_args['token_name'] = api_token_id
             auth_args['token_value'] = api_token_secret
 


Test patch: