{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/47563","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/47563/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/47563/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/47563/events","html_url":"https://github.com/ansible/ansible/issues/47563","id":373513009,"node_id":"MDU6SXNzdWUzNzM1MTMwMDk=","number":47563,"title":"vmware_host: ESXi servers failed to be added to vCenter","user":{"login":"nicholasrodriguez","id":27832557,"node_id":"MDQ6VXNlcjI3ODMyNTU3","avatar_url":"https://avatars0.githubusercontent.com/u/27832557?v=4","gravatar_id":"","url":"https://api.github.com/users/nicholasrodriguez","html_url":"https://github.com/nicholasrodriguez","followers_url":"https://api.github.com/users/nicholasrodriguez/followers","following_url":"https://api.github.com/users/nicholasrodriguez/following{/other_user}","gists_url":"https://api.github.com/users/nicholasrodriguez/gists{/gist_id}","starred_url":"https://api.github.com/users/nicholasrodriguez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicholasrodriguez/subscriptions","organizations_url":"https://api.github.com/users/nicholasrodriguez/orgs","repos_url":"https://api.github.com/users/nicholasrodriguez/repos","events_url":"https://api.github.com/users/nicholasrodriguez/events{/privacy}","received_events_url":"https://api.github.com/users/nicholasrodriguez/received_events","type":"User","site_admin":false},"labels":[{"id":947190508,"node_id":"MDU6TGFiZWw5NDcxOTA1MDg=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.7","name":"affects_2.7","color":"ededed","default":false},{"id":785271699,"node_id":"MDU6TGFiZWw3ODUyNzE2OTk=","url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":61528803,"node_id":"MDU6TGFiZWw2MTUyODgwMw==","url":"https://api.github.com/repos/ansible/ansible/labels/cloud","name":"cloud","color":"c7def8","default":false},{"id":496359346,"node_id":"MDU6TGFiZWw0OTYzNTkzNDY=","url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":636327968,"node_id":"MDU6TGFiZWw2MzYzMjc5Njg=","url":"https://api.github.com/repos/ansible/ansible/labels/support:community","name":"support:community","color":"ededed","default":false},{"id":942378949,"node_id":"MDU6TGFiZWw5NDIzNzg5NDk=","url":"https://api.github.com/repos/ansible/ansible/labels/traceback","name":"traceback","color":"ededed","default":false},{"id":427121291,"node_id":"MDU6TGFiZWw0MjcxMjEyOTE=","url":"https://api.github.com/repos/ansible/ansible/labels/vmware","name":"vmware","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":{"login":"Akasurde","id":633765,"node_id":"MDQ6VXNlcjYzMzc2NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/633765?v=4","gravatar_id":"","url":"https://api.github.com/users/Akasurde","html_url":"https://github.com/Akasurde","followers_url":"https://api.github.com/users/Akasurde/followers","following_url":"https://api.github.com/users/Akasurde/following{/other_user}","gists_url":"https://api.github.com/users/Akasurde/gists{/gist_id}","starred_url":"https://api.github.com/users/Akasurde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Akasurde/subscriptions","organizations_url":"https://api.github.com/users/Akasurde/orgs","repos_url":"https://api.github.com/users/Akasurde/repos","events_url":"https://api.github.com/users/Akasurde/events{/privacy}","received_events_url":"https://api.github.com/users/Akasurde/received_events","type":"User","site_admin":false},"assignees":[{"login":"Akasurde","id":633765,"node_id":"MDQ6VXNlcjYzMzc2NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/633765?v=4","gravatar_id":"","url":"https://api.github.com/users/Akasurde","html_url":"https://github.com/Akasurde","followers_url":"https://api.github.com/users/Akasurde/followers","following_url":"https://api.github.com/users/Akasurde/following{/other_user}","gists_url":"https://api.github.com/users/Akasurde/gists{/gist_id}","starred_url":"https://api.github.com/users/Akasurde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Akasurde/subscriptions","organizations_url":"https://api.github.com/users/Akasurde/orgs","repos_url":"https://api.github.com/users/Akasurde/repos","events_url":"https://api.github.com/users/Akasurde/events{/privacy}","received_events_url":"https://api.github.com/users/Akasurde/received_events","type":"User","site_admin":false}],"milestone":null,"comments":11,"created_at":"2018-10-24T14:29:20Z","updated_at":"2018-10-26T13:51:28Z","closed_at":null,"author_association":"NONE","body":"##### SUMMARY\r\nSince updating to Ansible 2.7 hosts are failing to be added into vCenter with the message;\r\n\r\n```\r\n\"msg\": \"Failed to add host <HOSTNAME.FQDN> to vCenter: Authenticity of the host's SSL certificate is not verified.\"\r\n```\r\n\r\nAll other vmware_*.py modules I consume (I use a lot of them) are working ok with Ansible 2.7\r\n\r\n##### ISSUE TYPE\r\n- Bug Report\r\n\r\n##### COMPONENT NAME\r\n\r\nvmware_host.py\r\n\r\n##### ANSIBLE VERSION\r\n\r\n```\r\nansible 2.7.0\r\n  config file = /home/nick/code/vmware-ansible/ansible.cfg\r\n  configured module search path = [u'/home/nick/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/lib/python2.7/site-packages/ansible\r\n  executable location = /usr/bin/ansible\r\n  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]\r\n```\r\n\r\n##### CONFIGURATION\r\nDEFAULT\r\n\r\n##### OS / ENVIRONMENT\r\nAnsible run environment: CentOS7\r\nTarget vCenter: 6.7\r\nTarget ESXi 6.7\r\n\r\n##### STEPS TO REPRODUCE\r\n\r\n**IMPORTANT** Only use an ESXi host that the target vCenter hasn't interacted with before or hasn't accepted an SSL thumbprint from the ESXi host.\r\n\r\nBoth playbooks below fail.\r\n\r\nAdding to a cluster\r\n```\r\n- name: 'Add ESXi host to vCenter'\r\n  connection: 'local'\r\n  vmware_host:\r\n    hostname: '{{ vcenter }}'\r\n    username: '{{ ansible_vcenter_username }}'\r\n    password: '{{ ansible_vcenter_password }}'\r\n    datacenter_name: '{{ pod_name }}'\r\n    cluster_name: '{{ cluster_name }}'\r\n    esxi_hostname: '{{ ansible_host }}'\r\n    esxi_username: '{{ esxi_root_account }}'\r\n    esxi_password: '{{ esxi_password }}'\r\n    state: 'present'\r\n    validate_certs: '{{ validate_certs }}'\r\n\r\n```\r\n\r\nAdding to just the Datacenter\r\n```\r\n- name: 'Add ESXi host to vCenter'\r\n  connection: 'local'\r\n  vmware_host:\r\n    hostname: '{{ vcenter }}'\r\n    username: '{{ ansible_vcenter_username }}'\r\n    password: '{{ ansible_vcenter_password }}'\r\n    datacenter_name: '{{ pod_name }}'\r\n    folder: '{{ dc_name }}/host'\r\n    esxi_hostname: '{{ ansible_host }}'\r\n    esxi_username: '{{ esxi_root_account }}'\r\n    esxi_password: '{{ esxi_password }}'\r\n    state: 'present'\r\n    validate_certs: '{{ validate_certs }}'\r\n```\r\n\r\nIf I specify the thumbprint in the playbook then it works. It appears the module is failing to force add the host.\r\n\r\nIf the host is removed and then added without specifying the SSL thumbprint then it works.\r\n\r\nI've built a new CentOS7 server with Ansible 2.7 from scratch to rule out issues with an inplace upgrade of Ansible and the above still fails.\r\n\r\nThe previous version of Ansible I was using and where this works is 2.6.2\r\n\r\n##### EXPECTED RESULTS\r\nThe ESXi host is added to vCenter despite the SSL thumbprint not being specified.\r\n\r\n\r\n##### ACTUAL RESULTS\r\n\r\n```\r\nTASK [add_esxi_to_vcenter_datacenter : Add ESXi host to vCenter] ***********************************************************************************************************************************************************************************************************************\r\ntask path: <PATH TO PLAYBOOK>/vmware-ansible/roles/add_esxi_to_vcenter_datacenter/tasks/main.yml:1\r\n\r\n<HOSTNAME.FQDN> ESTABLISH LOCAL CONNECTION FOR USER: <ME>\r\n<HOSTNAME.FQDN> EXEC /bin/sh -c 'echo ~<ME> && sleep 0'\r\n<HOSTNAME.FQDN> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo <PATH TO PLAYBOOK>.ansible/tmp/ansible-tmp-1540388469.44-25217277322162 `\" && echo ansible-tmp-1540388469.44-25217277322162=\"` echo <PATH TO PLAYBOOK>/.ansible/tmp/ansible-tmp-1540388469.44-25217277322162 `\" ) && sleep 0'\r\nUsing module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_host.py\r\n<HOSTNAME.FQDN> PUT <PATH TO PLAYBOOK>.ansible/tmp/ansible-local-56562_BWcpr/tmpmcoEie TO <PATH TO PLAYBOOK>.ansible/tmp/ansible-tmp-1540388469.44-25217277322162/AnsiballZ_vmware_host.py\r\n<HOSTNAME.FQDN> EXEC /bin/sh -c 'chmod u+x <PATH TO PLAYBOOK>.ansible/tmp/ansible-tmp-1540388469.44-25217277322162/ <PATH TO PLAYBOOK>.ansible/tmp/ansible-tmp-1540388469.44-25217277322162/AnsiballZ_vmware_host.py && sleep 0'\r\n<HOSTNAME.FQDN> EXEC /bin/sh -c '/usr/bin/python <PATH TO PLAYBOOK>.ansible/tmp/ansible-tmp-1540388469.44-25217277322162/AnsiballZ_vmware_host.py && sleep 0'\r\n<HOSTNAME.FQDN> EXEC /bin/sh -c 'rm -f -r <PATH TO PLAYBOOK>.ansible/tmp/ansible-tmp-1540388469.44-25217277322162/ > /dev/null 2>&1 && sleep 0'\r\nThe full traceback is:\r\nWARNING: The below traceback may *not* be related to the actual failure.\r\n  File \"/tmp/ansible_vmware_host_payload_WOvEyN/__main__.py\", line 258, in add_host_to_vcenter\r\n    success, result = wait_for_task(task)\r\n  File \"/tmp/ansible_vmware_host_payload_WOvEyN/ansible_vmware_host_payload.zip/ansible/module_utils/vmware.py\", line 59, in wait_for_task\r\n    raise_from(TaskError(error_msg), task.info.error)\r\n  File \"/tmp/ansible_vmware_host_payload_WOvEyN/ansible_vmware_host_payload.zip/ansible/module_utils/six/__init__.py\", line 744, in raise_from\r\n    raise value\r\n\r\nfatal: [HOSTNAME.FQDN]: FAILED! => {\r\n    \"changed\": false,\r\n    \"invocation\": {\r\n        \"module_args\": {\r\n            \"add_connected\": true,\r\n            \"cluster_name\": null,\r\n            \"datacenter_name\": \"<DATACENTER NAME>\",\r\n            \"esxi_hostname\": \"<HOSTNAME.FQDN>\",\r\n            \"esxi_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\",\r\n            \"esxi_ssl_thumbprint\": \"\",\r\n            \"esxi_username\": \"root\",\r\n            \"folder\": \"<DATACENTER NAME>/host\",\r\n            \"hostname\": \"<VCENTER.FQDN>\",\r\n            \"password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\",\r\n            \"port\": 443,\r\n            \"state\": \"present\",\r\n            \"username\": \"<USERNAME>\",\r\n            \"validate_certs\": false\r\n        }\r\n    },\r\n    \"msg\": \"Failed to add host HOSTNAME.FQDN to vCenter: Authenticity of the host's SSL certificate is not verified.\"\r\n}\r\n\r\nPLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************\r\nHOSTNAME.FQDN : ok=0    changed=0    unreachable=0    failed=1\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/433414787","html_url":"https://github.com/ansible/ansible/issues/47563#issuecomment-433414787","issue_url":"https://api.github.com/repos/ansible/ansible/issues/47563","id":433414787,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzQxNDc4Nw==","user":{"login":"nicholasrodriguez","id":27832557,"node_id":"MDQ6VXNlcjI3ODMyNTU3","avatar_url":"https://avatars0.githubusercontent.com/u/27832557?v=4","gravatar_id":"","url":"https://api.github.com/users/nicholasrodriguez","html_url":"https://github.com/nicholasrodriguez","followers_url":"https://api.github.com/users/nicholasrodriguez/followers","following_url":"https://api.github.com/users/nicholasrodriguez/following{/other_user}","gists_url":"https://api.github.com/users/nicholasrodriguez/gists{/gist_id}","starred_url":"https://api.github.com/users/nicholasrodriguez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicholasrodriguez/subscriptions","organizations_url":"https://api.github.com/users/nicholasrodriguez/orgs","repos_url":"https://api.github.com/users/nicholasrodriguez/repos","events_url":"https://api.github.com/users/nicholasrodriguez/events{/privacy}","received_events_url":"https://api.github.com/users/nicholasrodriguez/received_events","type":"User","site_admin":false},"created_at":"2018-10-26T13:51:28Z","updated_at":"2018-10-26T13:51:28Z","author_association":"NONE","body":"Python version is 2.7.5. I've reset and tried again with the same result, traceback is below;\r\n```\r\nThe full traceback is:\r\nWARNING: The below traceback may *not* be related to the actual failure.\r\n  File \"/tmp/ansible_vmware_host_payload_Ga_0rt/__main__.py\", line 258, in add_host_to_vcenter\r\n    success, result = wait_for_task(task)\r\n  File \"/tmp/ansible_vmware_host_payload_Ga_0rt/ansible_vmware_host_payload.zip/ansible/module_utils/vmware.py\", line 68, in wait_for_task\r\n    raise_from(TaskError(error_msg, host_thumbprint), task.info.error)\r\n  File \"/tmp/ansible_vmware_host_payload_Ga_0rt/ansible_vmware_host_payload.zip/ansible/module_utils/vmware.py\", line 36, in __init__\r\n    super(TaskError).__init__()\r\n\r\nfatal: [<SERVER.FQDN>]: FAILED! => {\r\n    \"changed\": false,\r\n    \"invocation\": {\r\n        \"module_args\": {\r\n            \"add_connected\": true,\r\n            \"cluster_name\": null,\r\n            \"datacenter_name\": \"<DC NAME>\",\r\n            \"esxi_hostname\": \"<SERVER.FQDN>\",\r\n            \"esxi_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\",\r\n            \"esxi_ssl_thumbprint\": \"\",\r\n            \"esxi_username\": \"root\",\r\n            \"folder\": \"<DC NAME>/host\",\r\n            \"hostname\": \"<VCENTER.FQDN>\",\r\n            \"password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\",\r\n            \"port\": 443,\r\n            \"state\": \"present\",\r\n            \"username\": \"<USERNAME>\",\r\n            \"validate_certs\": false\r\n        }\r\n    },\r\n    \"msg\": \"Failed to add host SERVER.FQDN to vCenter: super() takes at least 1 argument (0 given)\"\r\n}\r\n```"}}
{"actor":{"display_login":"nicholasrodriguez"}}