multiple vm playbook

161 views
Skip to first unread message

Rene Paquin

unread,
Feb 2, 2022, 1:51:22 PM2/2/22
to ansible...@googlegroups.com

I am attempting to create a playbook to deploy multiple linux  VMs from a template and assigning a static ip and I am running into issues.  My playbook:

 

---

 

- hosts: localhost

  gather_facts: no

  vars_files:

    - group_vars/vars

    - group_vars/vars_sec

 

  tasks:

  - name: Clone the template

    vmware_guest:

      hostname: "{{ vcenter_server }}"

      username: "{{ vcenter_user }}"

      password: "{{ vcenter_pass }}"

      validate_certs: False

      name: "{{ item.name }}"

      template: "{{ template }}"

      datacenter: "{{ datacenter_name }}"

      folder: "{{ folder }}"

      cluster:  "{{ cluster_name }}"

      datastore: "{{ datastore }}"

      networks:

        name: "{{ lan }}"

        ip:  '{{ item.ip }}'

        netmask: 255.255.254.0

        gateway: "{{ gw }}"

        connected: yes

        start_connected: yes

      state: poweredon

      wait_for_ip_address: yes

    delegate_to: localhost

    with_items:

    - { name: qanstest01, ip: 10.10.73.43 }

    - { name: qanstest02, ip: 10.10.73.44 }

    - { name: qanstest03, ip: 10.10.73.45 }

 

When I run the playbook I get the following error output

 

  "msg": "argument 'networks' is of type <class 'dict'> and we were unable to convert to list: <class 'dict'> cannot be converted to a list"

 

Any suggestions on how to get around this? 

 

Thanks,

 

********************************
Rene Paquin - Systems Administrator
Wilfrid Laurier University
Waterloo, Ontario
(519)884-0710 x3795
rpa...@wlu.ca

 

Stefan Hornburg (Racke)

unread,
Feb 2, 2022, 1:57:16 PM2/2/22
to ansible...@googlegroups.com
Use a list for the network parameters as shown in the examples for this module:

networks:

    - name: "{{ lan }}"

      ip:  '{{ item.ip }}'

      netmask: 255.255.254.0

      gateway: "{{ gw }}"

      connected: yes

      start_connected: yes


Regards

            Racke

> Thanks,
>
> ********************************
> Rene Paquin - Systems Administrator
> Wilfrid Laurier University
> Waterloo, Ontario
> (519)884-0710 x3795
> rpa...@wlu.ca <mailto:rpa...@wlu.ca>
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/YT2PR01MB6256445CD02F696E3D8F076CD8279%40YT2PR01MB6256.CANPRD01.PROD.OUTLOOK.COM <https://groups.google.com/d/msgid/ansible-project/YT2PR01MB6256445CD02F696E3D8F076CD8279%40YT2PR01MB6256.CANPRD01.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages