ignore_errors does not take variable

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:

Hi Yasir,

Have you read through: 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

I am setting test_err to ‘yes’ via set_fact:

below is playbook details:

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
  remote_user: deploy
  gather_facts: yes
  tasks:
    - set_fact: test_err=yes
    - debug: var=test_err
      ignore_errors: test_err | bool

I tried few combinations:

Hi,

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

     ignore_errors: test_err | bool

doesn't work for me on ansible 1.8.4

Is there any work around?

Thank you,
WAKAYAMA Shirou

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:

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