请查看我现有的代码,该代码可以正常运行。
从下面的代码中,您可以看到我已经为vars
和list3
静态定义了list4
:
- hosts: localhost
gather_facts: false
tasks:
- name: "set fact for snow"
set_fact:
list2: "{{ hostvars['192.168.10.20']['list1'] }}"
- include_tasks: loop1.yml
vars:
list3:
- dev-cn-c1
- dev-cn-c2
- dev-cn-c3
- dev-cn-c7
- dev-cn-c8
- dev-cn-c3
- dev-cn-c10
loop: "{{ list2 }}"
loop_control:
loop_var: outer_item
when:
- outer_item.type == 'CpmiGatewayCluster'
- list3|intersect(outer_item.names)|length > 0
- debug:
msg: "{{ list2 }}"
- include_tasks: loop2.yml
vars:
list4:
- dev-cn-c1
- dev-cn-c2
- dev-cn-c3
- dev-cn-c7
- dev-cn-c8
- dev-cn-c3
- dev-cn-c10
loop: "{{ list2 }}"
loop_control:
loop_var: outer_item
when:
- outer_item.type == "simple-gateway"
- list4|intersect(outer_item.name)|length > 0
我想从CSV文件vars
中动态读取这些int.csv
。
devicename,location
dev-cn-c1,32
dev-cn-c2,32
dev-cn-c3,56
dev-cn-c4,56
有可能吗?