Ansible在任务内模板化yaml
我正在使用lxd_容器模块创建一些lxd容器。其中一个容器的配置中应包含行security.nesting:“true”。我无法模板化此配置,因为它是由lxc工具控制的。 我需要像这样的东西: {%if item.0==“gitlab”%}安全性。嵌套:true{%endif%} 我如何在一项任务中实现这一点?会帮助您吗Ansible在任务内模板化yaml,ansible,lxd,Ansible,Lxd,我正在使用lxd_容器模块创建一些lxd容器。其中一个容器的配置中应包含行security.nesting:“true”。我无法模板化此配置,因为它是由lxc工具控制的。 我需要像这样的东西: {%if item.0==“gitlab”%}安全性。嵌套:true{%endif%} 我如何在一项任务中实现这一点?会帮助您吗 - set_fact: nesting: "{{ (item0 == 'gitlab') | ternary(true, omit) }}" - debug:
- set_fact:
nesting: "{{ (item0 == 'gitlab') | ternary(true, omit) }}"
- debug:
msg: "{{ nesting|default('NOT SET') }}"
你能做到:
security.nesting:“{{item.0==gitlab}”
- set_fact:
nesting: "{{ (item0 == 'gitlab') | ternary(true, omit) }}"
- debug:
msg: "{{ nesting|default('NOT SET') }}"