SUMMARY
vmware_host_datastore state absent seems to try to add instead of delete the datastore.
ISSUE TYPE
COMPONENT NAME
vmware_host_datastore
ANSIBLE VERSION
[root@srvansibledr01 VmWare]# ansible --version
ansible [core 2.16.14]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.12/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.12.9 (main, Sep 2 2025, 00:00:00) [GCC 14.2.1 20250110 (Red Hat 14.2.1-7)] (/usr/bin/python3)
jinja version = 3.1.6
libyaml = True
COLLECTION VERSION
[root@srvansibledr01 VmWare]# ansible-galaxy collection list | grep vmware
community.vmware 6.1.0
vmware.vmware 2.5.0
CONFIGURATION
[root@srvansibledr01 VmWare]# ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg
OS / ENVIRONMENT
[root@srvansibledr01 VmWare]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="10.0"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="10.0"
PLATFORM_ID="platform:el10"
PRETTY_NAME="Oracle Linux Server 10.0"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:10:0:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 10"
ORACLE_BUGZILLA_PRODUCT_VERSION=10.0
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=10.0
STEPS TO REPRODUCE
I need to remove some datastores from my environment ( as they can come from a clone or similar )
- name: Gather datastore to be detached
community.vmware.vmware_host_datastore:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname : "{{ esxi_name }}"
datastore_name: "{{ item }}"
state: absent
validate_certs: false
loop: "{{ datastore_clusters }}"
register: datastore_result
delegate_to: localhost
EXPECTED RESULTS
I expect the datastores to be removed.
ACTUAL RESULTS
TASK [Gather datastore to be detached] *****************************************************************************************************************************************************************************************************
failed: [localhost] (item=vmds01) => {"ansible_loop_var": "item", "changed": false, "item": "vmds01", "msg": "Cannot umount datastore vmds01 from host esxdr01: A VMFS volume with the same UUID '5e8c8d3c-01e5e182-3307-0025b5a00000' is already mounted in the datacenter."}
failed: [localhost] (item=vmds08) => {"ansible_loop_var": "item", "changed": false, "item": "vmds08", "msg": "Cannot umount datastore vmds08 from host esxdr01: A VMFS volume with the same UUID '5e84b0e1-1512bc6e-8391-0025b5a00003' is already mounted in the datacenter."}
Also from vmware I see that the error is :
From ansible-playbook with -vvvv
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296 `" && echo ansible-tmp-1764674230.153249-25407-138854913799296="` echo /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296 `" ) && sleep 0'
Loading collection vmware.vmware from /root/.ansible/collections/ansible_collections/vmware/vmware
Using module file /root/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_host_datastore.py
<localhost> PUT /root/.ansible/tmp/ansible-local-25373r0nzufuw/tmpiryali7z TO /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296/AnsiballZ_vmware_host_datastore.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296/ /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296/AnsiballZ_vmware_host_datastore.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296/AnsiballZ_vmware_host_datastore.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1764674230.153249-25407-138854913799296/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/tmp/ansible_community.vmware.vmware_host_datastore_payload_4g33jgd5/ansible_community.vmware.vmware_host_datastore_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_host_datastore.py", line 298, in umount_datastore_host
self.esxi.configManager.datastoreSystem.RemoveDatastore(ds)
File "/usr/local/lib/python3.12/site-packages/pyVmomi/VmomiSupport.py", line 601, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "/usr/local/lib/python3.12/site-packages/pyVmomi/VmomiSupport.py", line 376, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyVmomi/SoapAdapter.py", line 1518, in InvokeMethod
raise obj # pylint: disable-msg=E0702
^^^^^^^^^
failed: [localhost] (item=vmds01) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"auto_expand": true,
"datastore_name": "vmds01",
"datastore_type": null,
"esxi_hostname": "esxdr01",
"hostname": "192.168.100.253",
"nfs_path": null,
"nfs_ro": false,
"nfs_server": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"proxy_host": null,
"proxy_port": null,
"resignature": false,
"state": "absent",
"username": "administrator@vsphere.local",
"validate_certs": false,
"vasa_provider": null,
"vmfs_device_name": null,
"vmfs_version": null
}
},
"item": "vmds01",
"msg": "Cannot umount datastore vmds01 from host esxdr01: A VMFS volume with the same UUID '5e8c8d3c-01e5e182-3307-0025b5a00000' is already mounted in the datacenter."
}
SUMMARY
vmware_host_datastore state absent seems to try to add instead of delete the datastore.
ISSUE TYPE
COMPONENT NAME
vmware_host_datastore
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
I need to remove some datastores from my environment ( as they can come from a clone or similar )
EXPECTED RESULTS
I expect the datastores to be removed.
ACTUAL RESULTS
Also from vmware I see that the error is :
From ansible-playbook with -vvvv