ANSIBLE: Adding VMware ESX server to Vcenter Failing though Ansible vmware_host module: Certificate Error

1.1k views Asked by At

I am trying to add an ESX host to a vcenter server using Ansible code and vmware_host module. It's failing in Certification validation. is there any workaround for this ?

---
- hosts: localhost
  tasks:
       - name: Add ESXi Host to VCSA
         local_action:
           module: vmware_host
           hostname: xxxxxxxxxx
           username: [email protected]
           password: xxxxx
           datacenter_name: Datacenter
           cluster_name: cluster1
           esxi_hostname: xxxxx
           esxi_username: root
           esxi_password: xxxx
           state: present

here is the output of my task:

xxxx@ubuntu:/etc/ansible$ sudo ansible-playbook sample.yml
 [WARNING]: provided hosts list is empty, only localhost is available


PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [Add ESXi Host to VCSA] ***************************************************
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "msg": "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)"}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
1

There are 1 answers

2
errata On

Try to add validate_certs: False to your task:

---
- hosts: localhost
  tasks:
       - name: Add ESXi Host to VCSA
         local_action:
           module: vmware_host
           hostname: xxxxxxxxxx
           username: [email protected]
           password: xxxxx
           datacenter_name: Datacenter
           cluster_name: cluster1
           esxi_hostname: xxxxx
           esxi_username: root
           esxi_password: xxxx
           state: present
           validate_certs: False