vmware_guest module and loop

hello,

Forgive me in advance for my bad english.

I’m trying to use vmware_guest module with loops to create disks in the created vm.
But I don’t understand how to do this. The idea is to create a random number of disk.

My code:
`

  • name: “Creating a VM based on template”
    vmware_guest:
    datacenter: “{{ vmware_datacenter }}”
    cluster: “{{ vmware_cluster }}”
    hostname: “{{ vcenter_host }}”
    username: “{{ vcenter_user }}”
    password: “{{ vcenter_password }}”
    validate_certs: no
    folder: “{{ v_folder | default(‘/’) }}”
    name: “{{ v_hostname }}”
    annotation: “{{ ansible_date_time.date }} - VM creation {{ v_hostname }} using ansible”
    state: poweredon
    template: “{{ vmware_template }}”
    disk**:**
    - size_gb: “{{ item }}”
    type: “thin”
    datastore: “{{ vmware_datastore }}”
    hardware:
    memory_mb: “{{ v_memory_size }}”
    num_cpus: “{{ v_cpu_number }}”
    scsi: paravirtual
    networks:
  • name: “{{ vmware_network }}”
    vlan: “{{ v_vlan_id }}”
    ip: “{{ v_ip }}”
    netmask: “{{ v_netmask | default(‘255.255.255.0’) }}”
    gateway: “{{ v_gateway }}”
    with_items: “{{ disktest }}”
    delegate_to: localhost

`

And I execute:

ansible-playbook -vvv -e '{"vmware_network":"MYNETWORK","v_hostname":"MYHOSTNAME","v_memory_size":2048,"v_cpu_number":1,"v_ip":"xxx.xxx.xxx.xxx","v_netmask":"255.255.255.0","v_gateway":"xxx.xxx.xxx.xxxx","v_vlan_id":xx}' **-e '{"disktest": [20,50]}'** vmware.yml

But it doesn’t work:

“msg”: “Provided disks configuration has less disks than the target object (1 vs 2)”

I think it’s just a global loop understanding rather thant a vmware_guest problem. Any idea please ?

Thanks in advance :slight_smile: