You can use the |default jinja2 filter to help you out:

{{ ansible_env['NGINX_HOME']|default('') }}


This will default the value to '' if NGINX_HOME does not exist in the dict.

On Thu, Sep 18, 2014 at 4:53 AM, Zhenkai Jiang <[email protected]> wrote:

> I want to do some check using remote environment variables, which can be
> read from format like this
>
> {{ ansible_env.NGINX_HOME }}
>
> This "path" or environment variable can be absent, and that's the purpose
> of that check anyway.
>
> But Ansible treat this as a fatal error, showing error message like
>
> *One or more undefined variables: 'dict object' has no attribute
> 'NGINX_HOME'*
>
> What can I do to just skip this?
>
> --
> 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/f58820d2-ed6f-4533-b3a7-2d57937949e1%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f58820d2-ed6f-4533-b3a7-2d57937949e1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
[email protected]
http://sivel.net/

-- 
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/CAD8N0v_HGeEiE2xoDNLGGbZTiajLBVoEy5vXX9SAGs%2BVAiaYvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to