I made a simple playbook to show the issue. It seems ansible evalutes all 
variables regardless of the conditional result before ternary.
If you run the playbook twice, once with "simpleDict" defined, and again 
with it commented out. 

---
#TESTING: ternary behaviour
- name: Run - Testing ternary
  sudo: yes
  hosts: "{{hosts}}"
  gather_facts: no

  vars:
    simpleDict:
    #  name: 'A simple dictionary'
    #  nestedDict: {}

  tasks:
    - set_fact: foo="{{ simpleDict is defined | 
ternary(simpleDict.nestedDict|default({}),"simpleDict not defined") }}"

    - debug: var=foo

Thanks
Patrick

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bafba9e9-3aee-4237-bc1a-5bb0cb95fa47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to