ansible with_subelements

with_subelements 循环列表中的子元素 (意想不到的地方会用到)

---
- hosts: web
  tasks:
  - authorized_key: "user={{ item.0.name }} key='{{ item.1.path) }}'"
    with_subelements:
      - "{{ list }}"
      - some_key

item.0是list中的元素
item.1是list.key中的元素

若{{ list }}是一个列表的列表,可以实现列表内的循环。


注意 : ansible 循环无法在blocks中使用

posted @ 2017-09-18 23:48  clq.lib  阅读(1146)  评论(0编辑  收藏  举报