示例1
可以理解为:
for item in groups.ungrouped:
print(item)
- hosts: all
tasks:
- name: debug
debug:
msg: "{{ item }}"
with_items: "{{ groups.ungrouped }}"
- hosts: all
tasks:
- name: debug
debug:
msg: "{{ item }}"
with_items:
- "user01"
- "user02"
示例2
可以理解为:
a=[{user: test01,passwd: 123},{user: test02,passwd: 123}]
for item in a:
print(item['name'])
- hosts: all
tasks:
- name: debug
debug:
msg: "your name is {{ item.user }},password is {{ item.passwd }}"
with_items:
- {user: test01,passwd: 123}
- {user: test02,passwd: 123}
标签:语句,name,passwd,items,item,循环,user,debug
From: https://www.cnblogs.com/wangend/p/17061895.html