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
On Wednesday, August 12, 2015 at 4:06:18 PM UTC+1, Patrick McMahon wrote:
>
> Hi Brian,
>
> so in my defaults/main.yml if I define only this:
>
> file_system_system_vg:
>
> It works! so we are nearly there. If I remove file_system_system_vg from
> defaults/main.yml
> it throws an error again:
>
>
> TASK: [file_system | Create Logicals Volumes on primary VG]
> *******************
> fatal: [dsdptgfc06v.devqa.exch.int] => with_dict expects a dict
>
> PLAY RECAP
> *******************************************************************
>
> So is it possible to remove file_system_system_vg completely from
> defaults/main.yml?
>
> Thanks
> Patrick
>
> On Wednesday, August 12, 2015 at 3:40:32 PM UTC+1, Brian Coca wrote:
>>
>> have you tried:
>>
>> with_dict: "{{ file_system_system_vg is
>> defined|ternary(file_system_system_vg.lv|default({}), {})}}"
>>
>> ?
>>
>> --
>> Brian Coca
>>
>
--
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/b291a12d-9464-4667-8ec0-6fbdc1061529%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.