我正在使用lxd_container模块来创建一些 lxd 容器。这些容器之一应在其配置中包含行security.nesting: "true"。我不能模板化这个配置,因为它是由 lxc 工具控制的。我需要类似的东西:
{% if item.0 == "gitlab" %} security.nesting: true {% endif %}
- name: Creating containers
lxd_container:
name: "{{item.0}}"
state: started
source:
type: image
mode: pull
server: https://cloud-images.ubuntu.com/releases
protocol: simplestreams
alias: 18.04/amd64
profiles: ["default"]
config:
security.nesting: true // only if item.0 == gitlab
user.network-config: |-
version: 1
config:
- type: physical
name: eth0
subnets:
- type: static
ipv4: true
address: "{{ item.1 }}"
netmask: 255.255.255.0
gateway: "{{ CONT_GATEWAY }}"
control: auto
timeout: 7000
with_together:
- "{{ CONT_NAME }}"
- "{{ CONT_IP_ADRESS }}"
我怎么能在一项任务中做到这一点?