Hi
Is it possible to write jinja “if” conditionals within a playbook like so? If not can someone suggest an alternative?
`
- name: Deploy the VMs without an anti-affinity group.
cs_instance:
zone: “{{ cs_zone }}”
api_region: “{{ cs_api_region | upper }}”
display_name: “{{ item.instance }}”
name: “{{ item.instance | regex_replace(‘\.’,‘-’) }}”
project: “{{ cs_network }}”
networks: [ “{{ cs_network }}” ]
template: “{{ cs_template }}”
{% if item.cs_instance is null %}
service_offering: “{{ cs_template }}”
{% else %}
service_offering: “{{ item.cs_instance }}”
{% endif %}
state: "{{ cs_state }}
poll_async: “yes”
tags: “{{ final_tags }}”
user_data: “{{ user_data | string }}”
delegate_to: localhost
loop: “{{ myvmsfqdn }}”
when: cs_anti_affinity_group is not defined and cs_state == “started”
`
Thanks