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

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 can use the |default jinja2 filter to help you out:

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

Thank you so much