community.vmware icon indicating copy to clipboard operation
community.vmware copied to clipboard

Add support for multiple datastores in vmware_guest.py

Open SidRoy97 opened this issue 4 years ago • 8 comments

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:

7

the attached hard disks to the "name1" VM that has been created after running the above task are as follows:

6

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

SidRoy97 avatar Jul 04 '21 14:07 SidRoy97

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.

click here for bot help

ansibullbot avatar Jul 04 '21 14:07 ansibullbot

@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

click here for bot help

ansibullbot avatar Jul 04 '21 14:07 ansibullbot

Yes, right, I can reproduce this issue in my environment. Will fix this later. Thanks.

Tomorrow9 avatar Jul 16 '21 06:07 Tomorrow9

+1

corepl avatar Jan 21 '22 15:01 corepl

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....

hassenius avatar Jan 21 '22 16:01 hassenius

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

Tomorrow9 avatar Apr 18 '22 03:04 Tomorrow9

Hi @Akasurde @goneri @mariolenz @sky-joker what do you think about this issue in vmware_guest module?

  1. change doc description about datastore parameter,
  2. make changes in vmware_guest to let it handle datastore config of each disk like in vmware_guest_disk,
  3. any others? Thanks a lot.

Tomorrow9 avatar Apr 18 '22 03:04 Tomorrow9

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.

afogg01 avatar Jan 30 '24 14:01 afogg01