okay will try it and give response.

Thank you

On Tue, Apr 13, 2021 at 1:45 PM Komal Suthar <komalsuthar19122...@gmail.com>
wrote:

>  with_items: "{{ servers }}"
>
> Try this way onces
>
> On Tue, Apr 13, 2021, 3:19 PM rebecca acheampong <bec12...@gmail.com>
> wrote:
>
>> I want to create two VMs with ansible but keep getting this error with
>> the with_items
>> Please I need help. I am very new to ansible.
>>
>> ERROR! Syntax Error while loading YAML.
>>   did not find expected '-' indicator
>>
>> The error appears to be in '/home/ansible/ansible-demo/vm2_play.yml':
>> line 56, column 5, but may
>> be elsewhere in the file depending on the exact syntax problem.
>>
>> The offending line appears to be:
>>
>>     with_items:
>>     ^ here
>>
>> This is my variable file:
>>
>> esxi_host: 'vsecurity.localdomain'
>> VMWARE_HOST: '192.168.154.144'
>> VMWARE_USER: ' '
>> VMWARE_PASSWORD: ' '
>> vm_network: # vmxnet3
>> guest_netmask: '255.255.255.0'
>> guest_gateway: '192.168.154.2'
>> # IP of domaincontroller/dns
>> guest_dns_server1: '192.158.154.2'
>> servers:
>>    - my_vm_03
>>    - my_vm_04
>>
>> and this is my playbook, I am using vmware_guest module.
>>
>> ---
>> - name: create vm
>>   hosts: localhost
>>   gather_facts: no
>>   connection: local
>>   vars_files:
>>        multi_vm.yml
>>   tasks:
>>    - vmware_guest:
>>        hostname: "{{ VMWARE_HOST }}"
>>        username: "{{ VMWARE_USER }}"
>>        password: "{{ VMWARE_PASSWORD }}"
>>        validate_certs: no
>>        folder: /ha-datacenter/vm/
>>        name: "{{ item }}"
>>        state: poweredon
>>        guest_id: ubuntu64Guest
>>        esxi_hostname: "{{ esxi_host }}"
>>        disk:
>>        - size_gb: 15
>>          type: thin
>>          datastore: Datastore_3
>>        hardware:
>>          num_cpu: 1
>>           memory_mb: 1024
>>        networks:
>>        - name: '{{ vm_network }}'
>>          ip: 192.168.154.144
>>          netmask: 255.255.255.0
>>          gateway: '{{ guest_gateway }}'
>>          dns_servers:
>>          - '{{ guest_dns_server1 }}'
>>        wait_for_ip_address: yes
>>      delegate_to: localhost
>>      register: newvm
>>      register: deploy_vm
>>     with_items:
>>        - "{{ servers }}"
>>
>>
>>
>>
>>
>> --
>> 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-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/11a6e7ff-82ed-47aa-adf4-48c1237fab84n%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/11a6e7ff-82ed-47aa-adf4-48c1237fab84n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGgS%3DuXd4VBznCT6qXt8xJnEouuMGyNqqm%2B-W%3DzER0Ocjdy0JQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAGgS%3DuXd4VBznCT6qXt8xJnEouuMGyNqqm%2B-W%3DzER0Ocjdy0JQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKQAy6rb0cTTd7pCaPnBPrNLYEfdMadzBo70Yz5mRoSeW6VQww%40mail.gmail.com.

Reply via email to