How to control `ignore_errors` with a variable

Hi,

I already opened an issue for my question but I was advised to come here first.
The detailed description is available under https://github.com/ansible/ansible/issues/32384
To sum it up:

I cannot manage to make the ignore_errors work with a variable.
When I use a hardcoded boolean it works, but when I use a boolean variable it always evaluated to true (ignore errors)

`

- hosts: 127.0.0.1
  vars:
    ignore_assertion_errors: false
  tasks:
    - name: With variable
      assert:
        that: item < 2
        msg: "{{item}} isn't < 2"
      ignore_errors: ignore_assertion_errors
      with_items:
        - 1
        - 2

    - name: With 'false' as hardcoded boolean
      assert:
        that: item < 2
        msg: "{{item}} isn't < 2"
      ignore_errors: false
      with_items:
        - 1
        - 2

`

I already tried out the following constructs

`

ignore_errors: "{{ignore_assertion_errors}}"
ignore_errors: ignore_assertion_errors
ignore_errors: "{{ignore_assertion_errors|bool}}"
ignore_errors: ignore_assertion_errors|bool

`

But always with the same result: the errors of the first task are always ignored.

Can anybody explain what I’m doing wrong, because from my current point of view this is an error.

cheers

It works for me, using this play:

- hosts: localhost
gather_facts: false
vars:
   ignore: false
tasks:
   - name: with var
     assert:
       that:
         - item < 2
     ignore_errors: '{{ignore|bool}}'
     with_items: [1,2,3]

I get the following output (note the 'ignoring' at the end:

ok: [localhost] => (item=1) => {
   "changed": false,
   "item": 1,
   "msg": "All assertions passed"
}
failed: [localhost] (item=2) => {
   "assertion": "item < 2",
   "changed": false,
   "evaluated_to": false,
   "item": 2
}
failed: [localhost] (item=3) => {
   "assertion": "item < 2",
   "changed": false,
   "evaluated_to": false,
   "item": 3
}
...ignoring

HI, no, this doesn’t work. You see in you output

`
…ignoring

`

This means, that the errors are ignored.
Also the PLAY RECAP shows, that everything is ok, and no tasks failed.
If you add another task after the one already contained, it is still executed, but this should no happen…

that is exactly what should happen, im not sure what you are expecting.

sorry, im being stupid here ( thanks Toshio for bringing me to my senses). I write “false” but keep reading True…

You are correct, the expression is being incorrectly evaluated, Ill reopen the ticket.