community.vmware
community.vmware copied to clipboard
Add support for multiple datastores in vmware_guest.py
This issue is an extrapolation from that mentioned in https://github.com/ansible/ansible/pull/50923#issue-244733165
Trying to attach disk sizes from different datastores during VM creation but all the disks are taken from the first datastore in the disk list only.
The vmware_guest task executed is as follows:
the attached hard disks to the "name1" VM that has been created after running the above task are as follows:
which shows disk sizes taken only from datastore1 instead of datastore1 and datastore2. Both have adequate space to accommodate the required disk sizes
My ansible environment specifications are as follows: ansible [core 2.11.1] python version = 3.6.12 (default, Dec 02 2020, 09:44:23) [GCC] jinja version = 2.10 libyaml = False
ISSUE TYPE
- Bug Report
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.
@sidroy7139317: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.
Here are the items we could not find in your description:
- ansible version
- component name
Please set the description of this issue with this template: https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE/bug_report.md
Yes, right, I can reproduce this issue in my environment. Will fix this later. Thanks.
+1
Thanks for looking at this @Tomorrow9 Any update on it? It is a rather important feature for us too, and difficult to work around atm....
Hi @hassenius, I took a look at the vmware_guest module, it seems it does not handle this multiple datastore configuration:
# which datastore?
if expected_disk_spec.get('datastore'):
# TODO: This is already handled by the relocation spec,
# but it needs to eventually be handled for all the
# other disks defined
pass
while there is a workaround using vmware_guest_disk module after using vmware_guest to create a new VM, e.g.,
create a new VM with 1 disk firstly, then add a new disk:
- name: create a new VM with 1 disk
vmware_guest:
hostname: xx.xx.xx.xx
username: xxxxxx
password: xxxxxx
validate_certs: False
datacenter: DC
folder: ""
name: test_vm
guest_id: opensuse64Guest
state: "poweredoff"
hardware:
memory_mb: 1024
num_cpus: 1
boot_firmware: bios
disk:
- size_gb: 4
type: thin
datastore: datastore2
controller_type: paravirtual
controller_number: 0
unit_number: 0
networks:
- device_type: vmxnet3
name: 'VM Network'
type: "dhcp"
- name: add a new disk to above VM
vmware_guest_disk:
hostname: xx.xx.xx.xx
username: xxxxxx
password: xxxxxx
validate_certs: False
datacenter: DC
folder: ""
name: test_vm
disk:
- size_gb: 2
type: thin
datastore: datastore3
controller_type: paravirtual
controller_number: 0
unit_number: 1
Hi @Akasurde @goneri @mariolenz @sky-joker what do you think about this issue in vmware_guest module?
- change doc description about
datastoreparameter, - make changes in
vmware_guestto let it handledatastoreconfig of each disk like invmware_guest_disk, - any others? Thanks a lot.
I am also running into this issue.
Previously I was using a second play in a playbook to add extra disks with the vmware_guest_disk module, but this was causing a race condition when building a Windows VM with customisation and a RunOnce task, where the extra disk might not be presented to the VM in time.
Attempting to refactor to have all the disks built when the VM is created seemed like a good fix, until I realised it was ignoring putting the extra disks in different datastores.