Open hadfiiw opened 4 years ago
Files identified in the description: None
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
!component =plugins/modules/vmware_guest_disk.py
Files identified in the description:
plugins/modules/vmware_guest_disk.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_guest_disk.py)If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @Tomorrow9 @goneri @lparkes @pgbidkar @warthog9 click here for bot help
Any idea if this fix is being added? Is there a roadmap by chance? Thanks
SUMMARY
I have a playbook that spins out a new Ubuntu VM that is re-using the name of an existing VM (a stateless VM replacement playbook). When the playbook goes to add a second HDD to the new VM, it errors out saying the HDD already exists.
This is incorrect because it is looking in the original VMs datastore folder and not the new VMs datastore folder.
Before the new VM is spun out, the original VM is being renamed with an "-OldBackup" suffix to remove conflicts with the VM name (as they both end up in the same "VM and Templates" Folder, they cannot be named the same). This re-name is only for the VM name: the actual files that make up the original VM are on the datastore, in a folder, named the original VM name.
The playbook then spins out a new VM with the original VMs name. Because the original VM is still around in its original-name datastore folder, the system creates a new datastore folder of "VM-name_1". The "_1" at the end is added by the system (vSphere) as the folders cannot have duplicate names.
When the playbook gets to the vmware_guest_disk module to add a second HDD to the VM, it does not look in the datastore folder of "VM-name_1" but incorrectly looks at folder "VM-name".
The module is assuming that the VM it is adding the HDD to keeps its data in the datastore directory that matches its name. This is not always the case, especially when one gets into backup/restore scenarios. I have seen VMs living in folders with _1, _2, _3, etc, etc in the datastore folder name or with totally different names if the VM has been renamed in the past.
As a second test, I spun out the VM (which the system put in the "VM-name_1" folder) then, before the playbook got to the vmware_guest_disk module, I renamed the original VMs datastore folder from (for example) "VM-name" to "VM-name-OLD". The HDD add worked as it put the new HDD in datastore folder "VM-name". So I now have two datastore folders, "VM-name", "VM-name_1" for this single VM (with the original VM being in the "VM-name-OLD" folder).
NOTE: Before going to ansible 2.9 and Python 3, I used to add this second HDD via the "vmware_guest" module without a problem
ISSUE TYPE
COMPONENT NAME
vmware_guest_disk / disk
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
It is a Ubuntu 20 VM running on vSphere 6.7.0.45000 (which I believe is 6.7U2)
STEPS TO REPRODUCE
In this case, the 60GB disk is what is throwing the error (the OVA I am creating the Ubuntu VM from already has the 30GB disk)
EXPECTED RESULTS
The new HDD should be placed in the same datastore directory as the VM it is trying to add the HDD to.
ACTUAL RESULTS
The play is trying to create the new HDD in the "had01-0-webproxy-a" directory but this new VM is actually running from the "had01-0-webproxy-a_1" directory. The module is looking into the wrong datastore directory (it looks like it is assuming the datastore directory is going to be the same as the VM name when that is, sometimes, not the case)
It should be adding, [Infra-VM-Synology-Work] had01-0-webproxy-a_1/had01-0-webproxy-a_1000_1.vmdk (note the _1 in the folder name)