我正在尝试像这样循环哈希和与其关联的数组:
变量:
dictionary:
aword: [ ant, den ]
bword: [ fat, slim ]
任务:
name: Create symlinks
command: do something with item[0] over item[1]
with_nested:
- "{{ item.key }}"
- "{{ item.value }}"
with_dict: dictionary
这不起作用。是我做错了什么还是 Ansible 不支持这样的迭代?
最佳答案
我使用
解决了这个问题with_subelements
像这样
变量:
dictionary:
- name: aword
words:
- ant
- den
- name: bword
words:
- fat
- slim
任务:
name: Create symlinks
command: do something with item.0.name over item.1
with_subelements:
- dictionary
- words
关于ansible - 是否可以使用 Ansible Playbook 将 with_dict 和 with_nested 一起循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35145454/