From 06c4439a1c577585ff6bb1f08b827e816bca2160 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 8 Jun 2024 14:59:27 +0200 Subject: [PATCH] [PR #8441/d2d7deb4 backport][stable-9] #8440 Allow for API Port to be specified when using proxmox_kvm (#8478) #8440 Allow for API Port to be specified when using proxmox_kvm (#8441) * added api_port * added changelog fragments for #8440 * api_port minor changes - Added documentation on api_port - Fixed multiple spaces after operator - Switched from str to int * Update changelogs/fragments/8440-allow-api-port-specification.yaml Co-authored-by: Felix Fontein * Update changelogs/fragments/8440-allow-api-port-specification.yaml Co-authored-by: Felix Fontein * Update plugins/doc_fragments/proxmox.py Co-authored-by: Felix Fontein * Update plugins/doc_fragments/proxmox.py Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit d2d7deb4ecb978dd21a68b4ebd372da891ee3029) Co-authored-by: Thomas Gouverneur --- .../fragments/8440-allow-api-port-specification.yaml | 2 ++ plugins/doc_fragments/proxmox.py | 7 +++++++ plugins/module_utils/proxmox.py | 8 ++++++++ 3 files changed, 17 insertions(+) create mode 100644 changelogs/fragments/8440-allow-api-port-specification.yaml diff --git a/changelogs/fragments/8440-allow-api-port-specification.yaml b/changelogs/fragments/8440-allow-api-port-specification.yaml new file mode 100644 index 0000000000..646ee1ab60 --- /dev/null +++ b/changelogs/fragments/8440-allow-api-port-specification.yaml @@ -0,0 +1,2 @@ +minor_changes: + - proxmox - allow specification of the API port when using proxmox_* (https://github.com/ansible-collections/community.general/issues/8440, https://github.com/ansible-collections/community.general/pull/8441). diff --git a/plugins/doc_fragments/proxmox.py b/plugins/doc_fragments/proxmox.py index cb533fefa6..239dba06da 100644 --- a/plugins/doc_fragments/proxmox.py +++ b/plugins/doc_fragments/proxmox.py @@ -16,6 +16,13 @@ options: - Specify the target host of the Proxmox VE cluster. type: str required: true + api_port: + description: + - Specify the target port of the Proxmox VE cluster. + - Uses the E(PROXMOX_PORT) environment variable if not specified. + type: int + required: false + version_added: 9.1.0 api_user: description: - Specify the user to authenticate with. diff --git a/plugins/module_utils/proxmox.py b/plugins/module_utils/proxmox.py index 5fd783d654..05bf1874b3 100644 --- a/plugins/module_utils/proxmox.py +++ b/plugins/module_utils/proxmox.py @@ -29,6 +29,9 @@ def proxmox_auth_argument_spec(): required=True, fallback=(env_fallback, ['PROXMOX_HOST']) ), + api_port=dict(type='int', + fallback=(env_fallback, ['PROXMOX_PORT']) + ), api_user=dict(type='str', required=True, fallback=(env_fallback, ['PROXMOX_USER']) @@ -82,6 +85,7 @@ class ProxmoxAnsible(object): def _connect(self): api_host = self.module.params['api_host'] + api_port = self.module.params['api_port'] api_user = self.module.params['api_user'] api_password = self.module.params['api_password'] api_token_id = self.module.params['api_token_id'] @@ -89,6 +93,10 @@ class ProxmoxAnsible(object): validate_certs = self.module.params['validate_certs'] auth_args = {'user': api_user} + + if api_port: + auth_args['port'] = api_port + if api_password: auth_args['password'] = api_password else: