# How to signal an error from a Jinja expression?

**URL:** <https://forum.ansible.com/t/how-to-signal-an-error-from-a-jinja-expression/25573>\
**Category:** Ansible Project\
**Created:** [September 22, 2017, 9:14am UTC](https://forum.ansible.com/t/how-to-signal-an-error-from-a-jinja-expression/25573 "2017-09-22T09:14:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [September 22, 2017, 9:14am UTC](https://forum.ansible.com/t/how-to-signal-an-error-from-a-jinja-expression/25573/1 "2017-09-22T09:14:10Z")

</div>

I have the following task in a role:

command: \>-  
passwd -  
{%- if ansible\_system == ‘SunOS’ %}N  
{%- elif ansible\_system == ‘Linux’ %}l  
{%- else %}  
{{ “Unknown OS”/0 }}  
{%- endif -%}

How to throw an error for the unknown ansible\_system from within the role?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 22, 2017, 11:16pm UTC](https://forum.ansible.com/t/how-to-signal-an-error-from-a-jinja-expression/25573/2 "2017-09-22T23:16:14Z")

</div>

You cannot, but you can do this:

- command: ....  
&nbsp;&nbsp;when: ansible\_system is defined

- fail: msg=' you did not define ansible\_system!"  
&nbsp;&nbsp;when: not ansible\_system is defined
