How to use omit with Ansible and avoid any errors?

前端 未结 2 2029
野趣味
野趣味 2021-01-03 04:32

I tried to use omit with an expression like this:

id: \"{{ openstack_networks.id | default(omit) }}\"

But it seems that it keeps failing w

2条回答
  •  执念已碎
    2021-01-03 05:28

    Interestingly enough, Ansible will take something that reads like plain English:

    id: "{{ omit if openstack_networks.id is not defined or openstack_networks.id }}"
    

    The benefit here is that there are no additional parentheses.

提交回复
热议问题