From cd760782c9c507a928e08c9707194ca101485e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Thu, 16 Jan 2020 21:41:24 -0500 Subject: [PATCH] vmware_rest_client: define 'port' parameter (#66506) Ensure the `vmware_rest_client` based modules accept the `port` parameter. --- lib/ansible/module_utils/vmware_rest_client.py | 6 +++++- lib/ansible/plugins/doc_fragments/vmware_rest_client.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/vmware_rest_client.py b/lib/ansible/module_utils/vmware_rest_client.py index 77ad4a50c1c..fe89ade75c0 100644 --- a/lib/ansible/module_utils/vmware_rest_client.py +++ b/lib/ansible/module_utils/vmware_rest_client.py @@ -101,6 +101,9 @@ class VmwareRestClient(object): fallback=(env_fallback, ['VMWARE_PASSWORD']), aliases=['pass', 'pwd'], no_log=True), + port=dict(type='int', + default=443, + fallback=(env_fallback, ['VMWARE_PORT'])), protocol=dict(type='str', default='https', choices=['https', 'http']), @@ -117,6 +120,7 @@ class VmwareRestClient(object): username = self.params.get('username') password = self.params.get('password') hostname = self.params.get('hostname') + port = self.params.get('port') session = requests.Session() session.verify = self.params.get('validate_certs') @@ -125,7 +129,7 @@ class VmwareRestClient(object): " Please read the documentation for more information.") client = create_vsphere_client( - server=hostname, + server="%s:%s" % (hostname, port), username=username, password=password, session=session) diff --git a/lib/ansible/plugins/doc_fragments/vmware_rest_client.py b/lib/ansible/plugins/doc_fragments/vmware_rest_client.py index 4c97aa5d3d1..4ef45f915ad 100644 --- a/lib/ansible/plugins/doc_fragments/vmware_rest_client.py +++ b/lib/ansible/plugins/doc_fragments/vmware_rest_client.py @@ -33,6 +33,13 @@ options: - If the value is not specified in the task, the value of environment variable C(VMWARE_VALIDATE_CERTS) will be used instead. type: bool default: yes + port: + description: + - The port number of the vSphere vCenter. + - If the value is not specified in the task, the value of environment variable C(VMWARE_PORT) will be used instead. + type: int + default: 443 + version_added: '2.10' protocol: description: - The connection to protocol.