# ignore\_errors does not take variable

**URL:** <https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444>\
**Category:** Ansible Project\
**Created:** [October 6, 2014, 5:22pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444 "2014-10-06T17:22:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasir\_Saleem](https://avatars.discourse-cdn.com/v4/letter/y/13edae/32.png) [@Yasir\_Saleem](https://forum.ansible.com/u/Yasir_Saleem)\
**Post date:** [October 6, 2014, 5:22pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/1 "2014-10-06T17:22:18Z")

</div>

Hi,  
I was trying to use ignore\_errors to take a variable, but it fails.

Here is example play for ignore error not working:

- hosts: jump  
remote\_user: deploy  
gather\_facts: yes  
tasks:
- set\_fact: test\_err=yes
- debug: var=test\_err  
ignore\_errors: “{{ test\_err }}”

output was:

---

<div class="post-metadata">

**Author:** ![Mark2](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@Mark2](https://forum.ansible.com/u/Mark2)\
**Post date:** [October 7, 2014, 2:10pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/2 "2014-10-07T14:10:10Z")

</div>

Hi Yasir,

Have you read through: [http://docs.ansible.com/playbooks\_error\_handling.html](http://docs.ansible.com/playbooks_error_handling.html) ?

Ignore\_errors is taking yes or no, because simply put there isn’t any other answer possible to “Do you want me to ignore the errors?” yes/no. You are answering with “Mooo” and the system doesnt speak cowish, yet  
I’m interested in knowing why do you want to let ignore\_errors take a variable?

Regards,  
Mark

---

<div class="post-metadata">

**Author:** ![Yasir\_Saleem](https://avatars.discourse-cdn.com/v4/letter/y/13edae/32.png) [@Yasir\_Saleem](https://forum.ansible.com/u/Yasir_Saleem)\
**Post date:** [October 7, 2014, 2:51pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/3 "2014-10-07T14:51:48Z")

</div>

I am setting test\_err to ‘yes’ via set\_fact:

below is playbook details:

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [October 7, 2014, 2:57pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/4 "2014-10-07T14:57:12Z")

</div>

You are setting test\_err to the \*string\* yes, but ingore\_errors is  
looking for a boolean expression. Also, you don't need to using the  
"{{ }}" syntax in ignore\_errors since it is already using jinja2. Try  
using the "bool" filter:

- hosts: jump  
&nbsp;&nbsp;remote\_user: deploy  
&nbsp;&nbsp;gather\_facts: yes  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- set\_fact: test\_err=yes  
&nbsp;&nbsp;&nbsp;&nbsp;- debug: var=test\_err  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore\_errors: test\_err | bool

---

<div class="post-metadata">

**Author:** ![Yasir\_Saleem](https://avatars.discourse-cdn.com/v4/letter/y/13edae/32.png) [@Yasir\_Saleem](https://forum.ansible.com/u/Yasir_Saleem)\
**Post date:** [October 7, 2014, 4:58pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/5 "2014-10-07T16:58:46Z")

</div>

I tried few combinations:

---

<div class="post-metadata">

**Author:** ![shirou](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@shirou](https://forum.ansible.com/u/shirou)\
**Post date:** [February 26, 2015, 3:21pm UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/6 "2015-02-26T15:21:23Z")

</div>

Hi,

This E-mail is a little bit old but I am in the same situation.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore\_errors: test\_err | bool

doesn't work for me on ansible 1.8.4

Is there any work around?

Thank you,  
WAKAYAMA Shirou

---

<div class="post-metadata">

**Author:** ![Tom\_Bamford](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@Tom\_Bamford](https://forum.ansible.com/u/Tom_Bamford)\
**Post date:** [March 1, 2015, 3:55am UTC](https://forum.ansible.com/t/ignore-errors-does-not-take-variable/16444/7 "2015-03-01T03:55:24Z")

</div>

The last time I needed to have conditional ignore\_errors, because that option did not accept a variable I had to duplicate the task in question. One version of the task had `ignore_errors: yes` and had a conditional `when: my_var | bool` and the other had no such setting and the conditional `when: not my_var | bool`.

Something like this:

```auto
vars:
  myvar: yes
tasks:
  - some_module: name=blah state=present
    ignore_errors: yes
    when: myvar | bool
  - some_module: name=blah state=present
    when: not myvar | bool

```

Hope this helps

Tom

​
