From d633f6c4c8837b0e412fc0f82633d8c5e3d589e1 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 20:57:36 +0000 Subject: [PATCH] [PR #6839/e5dc6978 backport][stable-6] proxmox module utils: better error msg when token fails with old proxmoxer (#6845) proxmox module utils: better error msg when token fails with old proxmoxer (#6839) * proxmox module utils: clear msg when token fails with old proxmoxer * add changelog frag * better way to determine version (cherry picked from commit e5dc69788799168c0f53c1da636262c81d8fdc5b) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/6839-promoxer-tokens.yml | 2 ++ plugins/doc_fragments/proxmox.py | 2 ++ plugins/module_utils/proxmox.py | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/6839-promoxer-tokens.yml diff --git a/changelogs/fragments/6839-promoxer-tokens.yml b/changelogs/fragments/6839-promoxer-tokens.yml new file mode 100644 index 0000000000..a6013a792b --- /dev/null +++ b/changelogs/fragments/6839-promoxer-tokens.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox module utils - add logic to detect whether an old Promoxer complains about the ``token_name`` and ``token_value`` parameters and provide a better error message when that happens (https://github.com/ansible-collections/community.general/pull/6839, https://github.com/ansible-collections/community.general/issues/5371). diff --git a/plugins/doc_fragments/proxmox.py b/plugins/doc_fragments/proxmox.py index e39af4f3a6..5b417e9355 100644 --- a/plugins/doc_fragments/proxmox.py +++ b/plugins/doc_fragments/proxmox.py @@ -29,11 +29,13 @@ options: 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 index 58287cec17..d07026c038 100644 --- a/plugins/module_utils/proxmox.py +++ b/plugins/module_utils/proxmox.py @@ -98,6 +98,8 @@ class ProxmoxAnsible(object): 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