循环控制语句 之 with_indexed_items
添加索引
- hosts: all
tasks:
- name: debug
debug:
msg: "{{ item }}"
with_indexed_items:
- [1,2,3]
- ['a','b','c','d']
- hosts: all
tasks:
- name: debug
debug:
msg: "{{ item.0 }}"
with_indexed_items:
- [1,2,3]
- ['a','b','c','d']
- hosts: all
tasks:
- name: debug
debug:
msg: "{{ item.0 }} {{ item.1 }}"
with_indexed_items:
- [1,2,3]
- ['a','b','c','d']