From f003833c1a406da5a0492a4407820586dc821e4b Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:03:41 +0200 Subject: [PATCH] [PR #6980/796ad356 backport][stable-7] [proxmox] Use proxmoxer_version instead of server API version (#6982) [proxmox] Use proxmoxer_version instead of server API version (#6980) * Use proxmoxer_version instead of server API version * Add changelog fragment (cherry picked from commit 796ad3565eab36a0146c3f3d084306969a5e51ee) Co-authored-by: Sergei Antipov --- changelogs/fragments/6980-proxmox-fix-token-auth.yml | 2 ++ plugins/module_utils/proxmox.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6980-proxmox-fix-token-auth.yml diff --git a/changelogs/fragments/6980-proxmox-fix-token-auth.yml b/changelogs/fragments/6980-proxmox-fix-token-auth.yml new file mode 100644 index 0000000000..93545fff3e --- /dev/null +++ b/changelogs/fragments/6980-proxmox-fix-token-auth.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox module utils - fix proxmoxer library version check (https://github.com/ansible-collections/community.general/issues/6974, https://github.com/ansible-collections/community.general/issues/6975, https://github.com/ansible-collections/community.general/pull/6980). diff --git a/plugins/module_utils/proxmox.py b/plugins/module_utils/proxmox.py index bb3912d1bb..14b49afd6f 100644 --- a/plugins/module_utils/proxmox.py +++ b/plugins/module_utils/proxmox.py @@ -80,8 +80,8 @@ class ProxmoxAnsible(object): module.fail_json(msg=missing_required_lib('proxmoxer'), exception=PROXMOXER_IMP_ERR) self.module = module - self.proxmox_api = self._connect() self.proxmoxer_version = proxmoxer_version + self.proxmox_api = self._connect() # Test token validity try: self.proxmox_api.version.get() @@ -100,7 +100,7 @@ class ProxmoxAnsible(object): if api_password: auth_args['password'] = api_password else: - if self.version() < LooseVersion('1.1.0'): + if self.proxmoxer_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