On Sat, 28 Mar 2015 22:46 -0700, Vijay Mohan <[email protected]> wrote:
> Hi Guys,
> 
> I am trying to force the ansible play to check againt the command line 
> variable, here is my "check-requirement.yml" and required_var:
> 
> - fail: msg="Bailing out this play requires '{{ item }}'"
>   when: item is not defined
>   with_items: required_vars
> 
> I have set default/main.yml with following line:
> 
> required_vars:
>   - env
> 
> Now when i run the play book without env, its skipping rather than
> failing: 

"item" is a variable that is always defined when you use with_items.
Ansible will parse that and confirm it exists and is defined.

You could pass "item" through Jinja2 first, which will use the value
it's defined to and fail if it can't locate that variable.

when: "{{ item }} is not defined"

I haven't done a serious effort to understand the Ansible/Jinja2 flow
but the above should work.

Giovanni

-- 
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/1427810690.629768.247553989.3A937771%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to