目录标题
1. with_list:嵌套列表
[root@server4 ~]# cat xh5.yml
---
- hosts: testB
remote_user: root
gather_facts: no
tasks:
- debug:
msg: "{
{item}}"
with_list:
- [1,2,3] # 作为整体输出
- [a,b]
测试:
[root@server4 ~]# ansible-playbook xh5.yml
PLAY [testB] *******************************************************************
TASK [debug] *******************************************************************
ok: [172.25.60.3] => (item=[1, 2, 3]) => {
"msg": [
1,
2,
3
]
}
ok: [172.25.60.3] => (item=[u'a', u'b']) => {
"msg": [
"a",
"b"
]
}
PLAY RECAP *********************************************************************
172.25.60.3 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2. with_flattened和with_items类似
[root@server4 ~]# cat xh5.yml
---
- hosts: testB
remote_user: