use default during conditional role statement?

19 views
Skip to first unread message

ddffgpmfn

unread,
Apr 7, 2015, 9:59:25 AM4/7/15
to ansible...@googlegroups.com

Goal: conditionally apply a role, but not be required to define the var in every target env.

Can I default a var to empty or null if it isn't defined as 'bar'? e.g:

- { role: somerole, when: foo == 'bar' | default([]) }

ddffgpmfn

unread,
Apr 7, 2015, 10:21:51 AM4/7/15
to ansible...@googlegroups.com
ok, the default using an array was wrong.

This works:

{ role: somerole, when: foo | default('') == 'bar' }
Reply all
Reply to author
Forward
0 new messages