# What if a remote environment variable doesn't exist? Ansible take this as an fatal error. How to avoid that?

**URL:** <https://forum.ansible.com/t/what-if-a-remote-environment-variable-doesnt-exist-ansible-take-this-as-an-fatal-error-how-to-avoid-that/16269>\
**Category:** Ansible Project\
**Created:** [September 18, 2014, 9:53am UTC](https://forum.ansible.com/t/what-if-a-remote-environment-variable-doesnt-exist-ansible-take-this-as-an-fatal-error-how-to-avoid-that/16269 "2014-09-18T09:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhenkai\_Jiang](https://avatars.discourse-cdn.com/v4/letter/z/71c47a/32.png) [@Zhenkai\_Jiang](https://forum.ansible.com/u/Zhenkai_Jiang)\
**Post date:** [September 18, 2014, 9:53am UTC](https://forum.ansible.com/t/what-if-a-remote-environment-variable-doesnt-exist-ansible-take-this-as-an-fatal-error-how-to-avoid-that/16269/1 "2014-09-18T09:53:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 18, 2014, 12:02pm UTC](https://forum.ansible.com/t/what-if-a-remote-environment-variable-doesnt-exist-ansible-take-this-as-an-fatal-error-how-to-avoid-that/16269/2 "2014-09-18T12:02:34Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Zhenkai\_Jiang](https://avatars.discourse-cdn.com/v4/letter/z/71c47a/32.png) [@Zhenkai\_Jiang](https://forum.ansible.com/u/Zhenkai_Jiang)\
**Post date:** [September 19, 2014, 3:27am UTC](https://forum.ansible.com/t/what-if-a-remote-environment-variable-doesnt-exist-ansible-take-this-as-an-fatal-error-how-to-avoid-that/16269/3 "2014-09-19T03:27:29Z")

</div>

Thank you so much
