Hello dear Ansible community .
I am writting here my first post and I am still a beginner with ansible. So if there is anything to fix with my post let me know.
** What did I try so far **
So far I have tried to setup everything as described in the documentation here:
So to summarize I did:
- Create a new virtual environment with Python version 3.12.3
- I installed ansible using
sudo apt install ansible
- I installed the required ansible collection using
ansible-galaxy collection install vmware.vmware
- After that I installed the required python packages using
pip install -r ~/.ansible/collections/ansible_collections/vmware/vmware/requirements.txt
- I exported the required environment Variables
VMWARE_USER
,VMWARE_PASSWORD
andVMWARE_HOST
- I prepared the dynamic inventory using the requested naming convention
hosts.vmware_vms.yaml
---
plugin: vmware.vmware.vms
gather_tags: true
validate_certs: false
keyed_groups:
- key: tags_by_category.env | map('dict2items') | map('first') | map(attribute='value')
prefix: "vmware_tag_env"
separator: "-"
- Having ever everything prepared I wanted to show my dynamic inventory using
ansible-inventory -i ./inventory/hosts.vmware_vms.yaml --list -vvvv
Unfortunately this failed. Infos to why it failed can be seen in the investigation section.
Initial investigations
Here you can see the verbose output of the dynamic inventory
ansible-inventory [core 2.16.3]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-inventory
python version = 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
No config file found; using defaults
setting up inventory plugins
Loading collection ansible.builtin from
host_list declined parsing /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml as it did not pass its verify_file() method
script declined parsing /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml as it did not pass its verify_file() method
Loading collection vmware.vmware from /root/.ansible/collections/ansible_collections/vmware/vmware
toml declined parsing /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml as it did not pass its verify_file() method
[WARNING]: * Failed to parse /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml with auto plugin: module 'ssl' has no attribute 'wrap_socket'
File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 293, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/auto.py", line 50, in parse
plugin = inventory_loader.get(plugin_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ansible/plugins/loader.py", line 864, in get
return self.get_with_context(name, *args, **kwargs).object
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ansible/plugins/loader.py", line 899, in get_with_context
self._module_cache[path] = self._load_module_source(resolved_type_name, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ansible/plugins/loader.py", line 837, in _load_module_source
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/root/.ansible/collections/ansible_collections/vmware/vmware/plugins/inventory/vms.py", line 174, in <module>
from pyVmomi import vim
File "/usr/lib/python3/dist-packages/pyVmomi/__init__.py", line 204, in <module>
from pyVmomi.SoapAdapter import SoapStubAdapter, StubAdapterBase, SoapCmdStubAdapter, \
File "/usr/lib/python3/dist-packages/pyVmomi/SoapAdapter.py", line 993, in <module>
_SocketWrapper = ssl.wrap_socket
^^^^^^^^^^^^^^^
[WARNING]: * Failed to parse /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 293, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/yaml.py", line 114, in parse
raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]: * Failed to parse /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML file.
File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 293, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/ini.py", line 138, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /home/gere/Documents/Gitlab/workloadanalysis/workloads/propositions/k8s/ansible/inventory/hosts.vmware_vms.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}
In my opinion it seems to have some issues with the ssl… but I really don’t understand why, since I have set the valid_certs: false
.
Did anyone of you experience the same troubles setting up this dynamic inventory?
Or would anyone have a few tips on how to properly debug/resolve this?
Thank you very much upfront