我想创建一系列依赖于两个单独列表的目录树。
示例:
---
# variable file ...
datacenters:
- london
- paris
types:
- databases
- baremetal
- vms
所以我希望我的树能像这样...
dest: "/{{ datacenter.0 }}/{{ types.0 }}"
dest: "/{{ datacenter.0 }}/{{ types.1 }}"
dest: "/{{ datacenter.0 }}/{{ types.2 }}"
dest: "/{{ datacenter.1 }}/{{ types.0 }}"
dest: "/{{ datacenter.1 }}/{{ types.1 }}"
dest: "/{{ datacenter.1 }}/{{ types.2 }}"
dest: "/{{ datacenter.N }}/{{ types.N }} .... etc
我不确定如何在不使用包含文件的情况下执行此操作....
答案 0 :(得分:3)
您可以使用Nested Loops
- name: Test with_nested
hosts: localhost
vars:
datacenters:
- london
- paris
types:
- databases
- baremetal
- vms
tasks:
- name: Do it
debug: msg="{{item[0]}}/{{item[1]}}"
with_nested:
- datacenters
- types