Somewhat new to Ansible and connecting it to vsphere, but I threw together a simple playbook to test some modules. I have imported the vcenter root CA certificate and verified it is trusted via openssl. The task that calls the cluster info connects via SSL and returns output just fine, but the last task fetching the content library info returns an error with validate_certs on or off (see more below):
---
- name: host in cluster info demo
hosts: localhost
become: false
gather_facts: false
collections:
- community.vmware
pre_tasks:
- include_vars: vars/vpc_vault.yml
- include_vars: vars/vpc.yml
tasks:
- name: Gather info about all ESXi Hosts in given Cluster
community.vmware.vmware_cluster_info:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
#validate_certs: "{{ vcenter_validate_certs }}"
validate_certs: true
cluster_name: "{{ cluster_name }}"
schema: vsphere
properties:
- name
delegate_to: localhost
register: cluster_info
- name: print cluster info
ansible.builtin.debug:
var: cluster_info
- name: Content Library info
community.vmware.vmware_content_library_info:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: true
delegate_to: localhost
Returns:
PLAY [host in cluster info demo] ************************************************************************************************************************************************************************************************************
TASK [include_vars] *************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [include_vars] *************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Gather info about all ESXi Hosts in given Cluster] ************************************************************************************************************************************************************************************
ok: [localhost]
TASK [print cluster info] *******************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"cluster_info": {
"changed": false,
"clusters": {
"redacted": {
"name": "redacted"
}
},
"failed": false
}
}
TASK [Content Library info] *****************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to connect to vCenter or ESXi API at XXXXXredacted:443 due to SSL verification failure : HTTPSConnectionPool(host='XXXXXXXredacted', port=443): Max retries exceeded with url: /api (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))"}
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
And if I set validate_certs to false on the content library task:
I get a huge error message with some bits like
Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n warnings.warn(\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc":
and
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/home/XXXXX/.local/lib/python3.10/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'XXXXredacted'. Adding certificate verification is strongly advised.
Essentially: I know validate_certs: true works because the cluster task completes. But the content lib task fails on this.
Furthermore, I tried forcing http (and also āhttpā) instead of default https in the content library module parameter but still the same error. I can confirm all my ESXi hosts and vcenter have valid certs (self-signed though). The connection between esxi and vcenter is trusted. So, while Iām new to vsphere SDK, Iām beginning to think is a bug maybe.