Your with_items line is indented too far. It should align with the first 
letter of the word "name".

On Tuesday, June 21, 2016 at 8:57:47 AM UTC-4, Chun-Hung Huang wrote:
>
> Hi Mark Matthews and ALL
>
> I meet the same problem with create Create multiple VMware guests with a 
> Playbook.
> Could your share / show your playbook with me?
>
> Or help me to fix my playbook?
>
> My playbook is
>
>
> - name: Testing vsphere_guest module in VMware
>   hosts: localhost
>   connection: local
>   vars_prompt:
>     - name: "vcenter_hostname"
>       prompt: "Enter vcenter hostname"
>       private: no
>       default: "vcsa"
>     - name: "vcenter_user"
>       prompt: "Enter vCenter username"
>       private: no
>       default: root
>     - name: "vcenter_pass"
>       prompt: "Enter vcenter password"
>       private: yes
>     - name: "esxi_hostname"
>       prompt: "Enter esxi hostname"
>       private: no
>   tasks:
>     - name: Testing gater facts from vSphere
>       vsphere_guest:
>         vcenter_hostname: "{{ vcenter_hostname }}"
>         validate_certs: no
>         username: "{{ vcenter_user }}"
>         password: "{{ vcenter_pass }}"
>         guest: "{{ item }}"
>         from_template: yes
>         template_src: openSUSELeap42.1_Template
>         esxi:
>           datacenter: Lab
>           hostname: "{{ esxi_hostname }}"
>         with_items:
>           - server01
>           - server02
>
>
> Error message is
>
> fatal: [localhost]: FAILED! => {"failed": true, "msg": "'item' is 
> undefined"}
>
>
> item is undefined.
> But I already have with_items ??
>
>
> Thanks
>
>
> Max
>
> Mark Matthews於 2016年4月5日星期二 UTC+8下午11時16分15秒寫道:
>>
>> Hi guys
>>
>> Just to let you know, I just worked it out.
>>
>> I removed the following variable "serverlist: files/hostnames "
>>
>> And then changed the with_items to the following:
>>
>>       with_items:
>>         - ans_testserver01
>>         - ans_testserver02
>>
>> The playbook now creates both VMs (ans_testserver01 and ans_testserver02) 
>> when it is run.
>>
>> I dont know if that is the correct way of doing it, but it seems to be 
>> working for me.
>>
>>
>>
>> On Thursday, March 10, 2016 at 5:00:18 PM UTC, Mark Matthews wrote:
>>>
>>> Hi
>>>
>>> Is it at all possible to create multiple VMware VM's using an Ansible 
>>> playbook? Giving each VM a unique name (server1, server2, server3, server4)?
>>>
>>> I can see anyway of doing this using the following playbooks, as it 
>>> keeps failing?
>>>
>>> ---
>>>  - hosts: 127.0.0.1
>>>    connection: local
>>>    user: root
>>>    sudo: false
>>>    gather_facts: false
>>>    serial: 1
>>>    vars:
>>>      vcenter_hostname: UK.server.local
>>>      esxhost: xxx.xxx.xxx.xxx
>>>      datastore: UK1
>>>      network: Web
>>>      vmcluster: UKCLUSTER
>>>      guest_name: server1, server2, server3, server4 
>>>      folder: Utilities
>>>      notes: Created by Ansible
>>>
>>>    tasks:
>>>     - name: Create VM from template
>>>       vsphere_guest:
>>>         vcenter_hostname: "{{ vcenter_hostname }}"
>>>         username: "{{ username }}"
>>>         password: "{{ password }}"
>>>         guest: "{{ guest_name }}"
>>>         vm_extra_config:
>>>           notes: "{{ notes }}"
>>>           folder: "{{ folder }}"
>>>         from_template: yes
>>>         template_src: "{{ vmtemplate }}"
>>>         cluster: "{{ vmcluster  }}"
>>>         resource_pool: "/Resources"
>>>         
>>>         esxi:
>>>           datacenter: UK
>>>           hostname: "{{ esxhost }}"
>>>
>>> Any ideas or suggestions would be really appreciated.
>>>
>>> Cheers
>>>
>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4169ebf8-9663-4278-9141-390ade20b887%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to