[英]Ansible Get dict value from key
I have two files, one with 2 dict and another playbook that use those dict. 我有两个文件,一个包含2个字典,另一个使用这些字典的剧本。
Vars file: Vars文件:
data: {path: ~/prod/iac/playbook/test.conf, conf: test2} vagrant: {path: ~/prod/iac/playbook/test.conf/test2.conf, conf: test4}
and the playbook: 和剧本:
--- - hosts: localhost tasks: - name: Include var for nginx config include_vars: file: ~/prod/iac/playbook/vars.yml name: conf_vars - name: overide doc configuration shell: echo "{{ item[path] }}" > test.conf with_items: " {{ conf_vars }}"
My vars is correctly loaded but i can't get the dict value... Any idea ? 我的var已正确加载,但我无法获得dict值...知道吗?
conf_vars
is a dictionary, with_items
is to be used with lists. conf_vars
是字典, with_items
将与列表一起使用。
You may want to use with_dict
: 您可能要使用
with_dict
:
- name: overide doc configuration
shell: echo "{{ item.value[path] }}" > test.conf
with_dict: "{{ conf_vars }}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.