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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/567771c1-88fb-4f1c-b26e-5c2a3ee4eb78%40googlegroups.com.

Reply via email to