ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
337 stars 332 forks source link

new state in vmware_host_datastore to differentiate between unmount and remove #2006

Open christian-naenny opened 4 months ago

christian-naenny commented 4 months ago
SUMMARY

If I use state: absent in the vmware_host_datastore module, the VMFS volume is removed! But I do not want to remove it, I only want to unmount the VMFS volume

I would like to do what I already did in PowerShell as $StorageSys.UnmountVmfsVolume($DS.ExtensionData.Info.vmfs.uuid);

In the function umount_datastore_host in vmware_host_datastore.py the code is: self.esxi.configManager.datastoreSystem.RemoveDatastore(ds)

but this is not an unmount, this is a remove! There is a difference between these two!

The code for an unmount should be something like this: self.esxi.configManager.datastoreSystem.UnmountVMFSVolume(ds)

ISSUE TYPE
COMPONENT NAME

community.vmware.vmware_host_datastore

ADDITIONAL INFORMATION

Later in the process, I need to mount the VMFS Volumes again, this does not work if I removed the Datastore using the current solution of the module.

- name: "Unmount datastores"
  community.vmware.vmware_host_datastore:
    datastore_name: "{{ $dsName }}"
    datastore_type: vmfs
    esxi_hostname: "{{ $esxHostName }}"
    vmfs_device_name: "naa.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    vmfs_version: 6
    state: dismount   # or any other value other than absent
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
sathyapj commented 3 months ago

+1. I tried this module for 'Unmount' function. Realized this module will Remove the datastore. Fortunately, the datastore was empty with no vms. Otherwise, I will be in a trouble at work!!

sathyapj commented 3 months ago

Module shows 'absent' is unmount. But it's trying to remove the datastore.