【发布时间】:2020-08-19 21:17:50
【问题描述】:
我正在编写一个 Playbook Ansible,我想循环进入两个不同的列表。
我现在可以使用with_items 在列表中循环,但是我可以在同一个剧本中使用with_items 两次吗?
这是我想做的:
- name: Deploy the network in fabric 1 and fabric 2
tags: [merged]
role_network:
config:
- net_name: "{{ networkName }}"
vrf_name: "{{ vrf }}"
net_id: 30010
net_template: "{{ networkTemplate }}"
net_extension_template: "{{ networkExtensionTemplate }}"
vlan_id: "{{ vlan }}"
gw_ip_subnet: "{{ gw }}"
attach: "{{ item }}"
deploy: false
fabric: "{{ item }}"
state: merged
with_items:
- "{{ attachs }}"
"{{ fabric }}"
register: networks
所以对于第一次通话,我想使用带有fabric[0] 和attachs[0] 的剧本。
对于第二个电话,我想使用带有fabric[1] 和attachs[1] 的剧本。
等等……
有人可以帮帮我吗?
【问题讨论】: