我可能错过了一些简单的东西。我在 vars.yml 中有字典
deploy_env:
dev:
schemas:
year1:
- main
- custom
year2:
- main
- custom
- security
year3:
- main
- custom
Run Code Online (Sandbox Code Playgroud)
然后在我的 playbook.yml 我有类似的东西
- set_fact:
years: "{{ deploy_env.dev.schemas }}"
- name: Create schemas
shell: "mysql ....params go here... {{ item }}"
with_nested:
- "{{ years }}"
Run Code Online (Sandbox Code Playgroud)
如果vars.yml中的模式是一个简单的列表,则上述工作正常,即:
...schemas:
- year1
- year2
- year3
Run Code Online (Sandbox Code Playgroud)
但是,一旦我在每年下添加其他项目(使其成为字典(?),我就开始在线上出现错误:- "{{ years }}"。
我基本上想用此任务的year1、year2、year3值填充{{ years }}。
我看过很多例子,但我看到的一切都太复杂了,而且是关于如何创建没有帮助的词典。
谢谢!