2

I try to deploy a VMWare guest via Ansible. Unfortunately

ansible-playbook -i inventory.local vmware.yml    

 PLAY [all] ******************************************************************** 

 GATHERING FACTS *************************************************************** 
 ok: [vmcenter00]
 ok: [127.0.0.1]

 TASK: [vsphere_guest ] ******************************************************** 
 failed: [127.0.0.1] => {"failed": true, "parsed": false}
 Traceback (most recent call last):
  File "/Users/some_user/.ansible/tmp/ansible-tmp-1447432699.52-19521550866442/vsphere_guest", line 2936, in <module>
     main()
   File "/Users/some_user/.ansible/tmp/ansible-tmp-1447432699.52-19521550866442/vsphere_guest", line 1207, in main
     viserver.connect(vcenter_hostname, username, password)
   File "/Library/Python/2.7/site-packages/pysphere/vi_server.py", line 101, in connect
    request)._returnval
   File "/Library/Python/2.7/site-packages/pysphere/resources/VimService_services.py", line 2170, in RetrieveServiceContent
     self.binding.Send(None, None, request, soapaction="urn:vim25/5.0", **kw)
   File "/Library/Python/2.7/site-packages/pysphere/ZSI/client.py", line 295, in Send
     self.local.h.connect()
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1274, in connect
     server_hostname=server_hostname)
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 352, in wrap_socket
     _context=self)
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 579, in __init__
     self.do_handshake()
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 808, in do_handshake
     self._sslobj.do_handshake()
 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

 FATAL: all hosts have already failed -- aborting

 PLAY RECAP ******************************************************************** 
        to retry, use: --limit @/Users/some_user/vmware.retry

 127.0.0.1                  : ok=1    changed=0    unreachable=0    failed=1   
 vmcenter00                 : ok=1    changed=0    unreachable=0    failed=0   

What you should know.

I run OS X 10.11. I have ansible 1.9.3 I have pysphere (0.1.7) The output of:

python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 0.9.8zg 14 July 2015...

Am I missing something here?

6
  • I do not mind to use other libraries or tool, as long as it's triggered by Ansible...
    – yield
    Nov 13, 2015 at 18:32
  • "SSL: CERTIFICATE_VERIFY_FAILED" -- Your ansible doesn't trust the certificate of your vCenter Server or ESXi host. Fix that.
    – jscott
    Nov 13, 2015 at 18:36
  • Yes. But, shouldn't there be a option to accept "invalid" certificat ? .... Like, a --skip-ssl option ...
    – yield
    Nov 13, 2015 at 18:41
  • I'm guessing you're using the vsphere_guest module, which does not support such an option.
    – jscott
    Nov 13, 2015 at 18:44
  • Yes. You are right, that is the module I use. Is there any other modules that I could use to do that ? How can I accept a invalid certificat from my VMWare... This is a dev. environnement, there is no way I can get a valid certificat for that... Sad...
    – yield
    Nov 13, 2015 at 18:49

2 Answers 2

4

The tasks fails because SSL certificate verification fails. In Ansible version 2.1 validate_certs was added to the vsphere_guest_module

Validate SSL certs. Note, if running on python without SSLContext support (typically, python < 2.7.9) you will have to set this to no as pysphere does not support validating certificates on older python. Prior to 2.1, this module would always validate on python >= 2.7.9 and never validate on python <= 2.7.8.

So setting validate_certs: no should solve this issue as long you can use Ansible version >= 2.1 and Python version >= 2.7.9

0

Workaround: Add below two lines in /Library/Python/2.7/site-packages/pysphere/vi_server.py

import ssl
ssl._create_default_https_context = ssl._create_unverified_context
1
  • Ok. Back to the topic. Same old story... Still with same error. So... Here I am with python virtualenv to test with Ansible 1.9.6 and 2.0.0.2 and I have the same issue... Like explained to me in the previous post, this files does not exist and/or even if I create it, I have the same issue: /Library/Python/2.7/site-packages/pysphere/vi_server.py. I am surprised that there not more peoples looking for that. All I see are Python dev work around, but I obviously can't modify Ansible code... Well.. I could, but I'm not a developper... So... ? Any ideas or step by step ?
    – yield
    May 19, 2016 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .