在下面的代码中,我可以将traceroute_dest
定义为Ansible理解的列表来获取它吗?
---
- name : Traceroute ip addresses
hosts: all
gather_facts: no
tasks:
- name: "Trace multiple ip addresses"
raw: "traceroute {{item}}"
register: trace_result
with_items: "{{'traceroute_dest'}}"
- debug: var=trace_result.stdout_lines
答案 0 :(得分:0)
完整的剧本应该是这样的。
---
- name : Traceroute ip addresses
hosts: all
gather_facts: no
vars_files:
- 42266085-vars.yml
tasks:
- name: "Trace multiple ip addresses"
raw: "traceroute {{item}}"
register: trace_result
with_items: "{{traceroute_dest}}"
- debug: var=trace_result
...
定义变量的文件应该是这样的。
---
traceroute_dest: ["119.82.76.111"]