码迷,mamicode.com
首页 > 其他好文 > 详细

ansible循环四

时间:2020-09-17 17:19:20      阅读:33      评论:0      收藏:0      [点我收藏+]

标签:The   led   skipped   esc   debug   exe   sts   循环   reac   

with_indexed_items

示例:


  • hosts: jack6_1
    remote_user: root
    gather_facts: no
    tasks:
    • debug:
      msg: "{{item}}"
      with_indexed_items:
      • [t1,t2]
      • [t3,[t4,t5]]
      • [t6]

输出结果如下:
[root@jack7-1 work]# ansible-playbook --syntax-check item_index.yml

playbook: item_index.yml
[root@jack7-1 work]# ansible-playbook item_index.yml

PLAY [jack6_1] *****

TASK [debug] ***
ok: [jack6_1] => (item=[0, u‘t1‘]) => {
"msg": [
0,
"t1"
]
}
ok: [jack6_1] => (item=[1, u‘t2‘]) => {
"msg": [
1,
"t2"
]
}
ok: [jack6_1] => (item=[2, u‘t3‘]) => {
"msg": [
2,
"t3"
]
}
ok: [jack6_1] => (item=[3, [u‘t4‘, u‘t5‘]]) => {
"msg": [
3,
[
"t4",
"t5"
]
]
}
ok: [jack6_1] => (item=[4, u‘t6‘]) => {
"msg": [
4,
"t6"
]
}

PLAY RECAP *****
jack6_1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

ansible循环四

标签:The   led   skipped   esc   debug   exe   sts   循环   reac   

原文地址:https://blog.51cto.com/13434656/2529217

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!