Closed nsbender closed 3 years ago
Hi @nsbender
Thanks for taking the time to report this issue.
The vmware_content_deploy_ovf_template
use the vmware.vapi.vsphere.client.create_vsphere_client
to interact with the vsphere using a requests.Session
object which is not update yet with proxies parameters. This will need a fix.
@nsbender could you test the proxy connection using PR #848 ?
@abikouo, we have tested the pull request version by specifying the proxy host and port using both VMWARE_PROXY_HOST/PORT and proxy_host/port and they both resulted in
The error was: AttributeError: 'dict' object has no attribute 'proxy_port'
(Full error at bottom)
Here is the playbook:
vars:
...
proxyenv:
VMWARE_PROXY_HOST: "10.252.33.216"
VMWARE_PROXY_PORT: 80
# proxy_host: "10.252.33.216"
# proxy_port: 80
tasks:
- name: Clone the template
environment: "{{ proxyenv }}"
community.vmware.vmware_content_deploy_ovf_template:
name: "{{ vmName }}"
hostname: "{{ vcenterHostname }}"
username: "{{ vcenterUsername }}"
password: "{{ vcenterPassword }}"
ovf_template: "{{ vmTemplate }}"
content_library: "{{ vmContentLibrary }}"
datastore: "{{ vmDatastore }}"
folder: "Test"
datacenter: "{{ vmDatacenter }}"
cluster: "{{ vmCluster }}"
validate_certs: no
resource_pool: "Resources"
host: "{{ vmDeployHost }}"
...
Full error:
TASK [Clone the template] ******************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'dict' object has no attribute 'proxy_port'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/automation/.ansible/tmp/ansible-tmp-1621269108.5774417-2372561-169852255276665/AnsiballZ_vmware_content_deploy_ovf_template.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/automation/.ansible/tmp/ansible-tmp-1621269108.5774417-2372561-169852255276665/AnsiballZ_vmware_content_deploy_ovf_template.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/automation/.ansible/tmp/ansible-tmp-1621269108.5774417-2372561-169852255276665/AnsiballZ_vmware_content_deploy_ovf_template.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_content_deploy_ovf_template', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.vmware.vmware_content_deploy_ovf_template_payload_3db6srey/ansible_community.vmware.vmware_content_deploy_ovf_template_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_content_deploy_ovf_template.py\", line 277, in <module>\n File \"/tmp/ansible_community.vmware.vmware_content_deploy_ovf_template_payload_3db6srey/ansible_community.vmware.vmware_content_deploy_ovf_template_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_content_deploy_ovf_template.py\", line 265, in main\n File \"/tmp/ansible_community.vmware.vmware_content_deploy_ovf_template_payload_3db6srey/ansible_community.vmware.vmware_content_deploy_ovf_template_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_content_deploy_ovf_template.py\", line 139, in __init__\n File \"/tmp/ansible_community.vmware.vmware_content_deploy_ovf_template_payload_3db6srey/ansible_community.vmware.vmware_content_deploy_ovf_template_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware_rest_client.py\", line 59, in __init__\n File \"/tmp/ansible_community.vmware.vmware_content_deploy_ovf_template_payload_3db6srey/ansible_community.vmware.vmware_content_deploy_ovf_template_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware_rest_client.py\", line 137, in connect_to_vsphere_client\nAttributeError: 'dict' object has no attribute 'proxy_port'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
@abikouo I believe we fixed the issue. On line 137 of vmware_rest_client.py:
Should:
if self.params.get('protocol') and self.params.get('proxy_host') and self.params.proxy_port:
be:
self.params.get('protocol') and self.params.get('proxy_host') and self.params.get('proxy_port'):
?
We were able to get it working with the latter.
@abikouo I believe we fixed the issue. On line 137 of vmware_rest_client.py:
Should:
if self.params.get('protocol') and self.params.get('proxy_host') and self.params.proxy_port:
be:
self.params.get('protocol') and self.params.get('proxy_host') and self.params.get('proxy_port'):
?We were able to get it working with the latter.
yes you are right, I was in a rush
When that pull request gets merged with this change, this issue will be resolved. Thanks for all your help!
SUMMARY
When specifying VMWARE_PROXY_HOST and VMWARE_PROXY_PORT, vmware_content_deploy_ovf_template does not attempt to use the proxy, and fails to connect to a VCenter.
ISSUE TYPE
COMPONENT NAME
vmware_content_deploy_ovf_template
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Ubuntu 20.04.1 LTS VSphere Client Version 6.7.0.46000
STEPS TO REPRODUCE
EXPECTED RESULTS
Another module, vmware_guest in the same playbook accepts and uses the same variable, and connects to VCenter through the proxy without any issue. The below output is from a content library deploy not using a proxy.
ACTUAL RESULTS