Hi Matti,
You've created a dictionary instead of a list.
Check this document:
http://docs.ansible.com/ansible/YAMLSyntax.html
The proper use of "with_items" needs a list like this:
vmware_guest_disks:
- size_gb: 20
datastore: datastore1
- size_gb: 1
datastore: datastore1
- size_gb: 2
datastore: datastore1
Note the dash and space per item. The indentation is important, too.
Then you should access the items this way: {{ item.size_gb }} and {{ item.datastore }}. No "value" part.
Cheers,
Marko
________________________________
From:
ansible...@googlegroups.com <
ansible...@googlegroups.com> on behalf of Matti Rantakömi <
ran...@gmail.com>
Sent: Monday, January 30, 2017 11:48
To: Ansible Project
Subject: [ansible-project] How to use with_items loop with vmware_guest module
Hello,
I'm trying to create new VM using vmware_guest module with multiple disks which details are defined in host_vars file. Unfortunately I can't get it working. Is it even possible to use with_items with vmware_guest module?
I have tried the following:
Disk definition in host_vars:
vmware_guest_disks:
disk1:
size_gb: 20
datastore: datastore1
disk2:
size_gb: 1
datastore: datastore1
disk3:
size_gb: 2
datastore: datastore1
Task used to try to create new VM:
- name: Create new VM
vmware_guest:
hostname: 192.168.1.2
username: admini...@vsphere.local
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
ansible-proje...@googlegroups.com<mailto:
ansible-proje...@googlegroups.com>.
To post to this group, send email to
ansible...@googlegroups.com<mailto:
ansible...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/2ce90552-5058-4a8c-9bf7-691046e22d0a%40googlegroups.com<
https://groups.google.com/d/msgid/ansible-project/2ce90552-5058-4a8c-9bf7-691046e22d0a%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit
https://groups.google.com/d/optout.
______________________________________________________________________________________________________
CONFIDENTIALITY NOTICE: This message is the property of International Game Technology PLC and/or
its subsidiaries and may contain proprietary, confidential or trade secret information.
This message is intended solely for the use of the addressee. If you are not the intended recipient
and have received this message in error, please delete this message from your system. Any unauthorized
reading, distribution, copying, or other use of this message or its attachments is strictly prohibited.