with_dict in loop counter

192 views
Skip to first unread message

Rafael Tomelin

unread,
Dec 18, 2019, 9:09:23 AM12/18/19
to ansible...@googlegroups.com
Hi,

I have a task for creating the virtual machine at Azure with_dict.

I should like to create a variable count (number the VMS) and put it with_dict.  

How can create loop count with with_dict?

  
--
Atenciosamente,

Rafael Tomelin
Tel.: 51-984104084
Skype: rafael.tomelin

LPI ID: LPI000191271
Red Hat Certified Engineer
Puppet Professional 2017 Certification

Matt Martz

unread,
Dec 18, 2019, 9:54:30 AM12/18/19
to ansible...@googlegroups.com

Examples:

    - debug:
        msg: "{{ ansible_loop.index0 }}: key: {{ item.key }}, value: {{ item.value }}"
      with_dict: "{{ thing }}"
      loop_control:
        extended: true

    - debug:
        msg: "{{ ansible_loop.index0 }}: key: {{ item.key }}, value: {{ item.value }}"
      loop: "{{ thing|dict2items }}"
      loop_control:
        extended: true

--
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/CAGEUqbBao7gxPbcJAr7Hb8%3DBSpb5gwHY8WnadLLPTuWZfrpc%2Bw%40mail.gmail.com.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages