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中使用

原文地址:https://www.cnblogs.com/iois/p/7545994.html