In case someone else hits this fascinating problem. This is what I had to
do in the end ...
---
- name: FAILER!
command: /bin/false
register: result
with_items:
- one
- two
ignore_errors: True
- name: Error checker
fail:
msg: "FAILER! FAILED!"
when: result.failed is defined and (ignore_replication_errors is not
defined or (ignore_replication_errors is defined and not
ignore_replication_errors|bool))
On Thursday, August 17, 2017 at 11:14:16 AM UTC-7, G Sudduth wrote:
>
> Hi,
>
> So, I have a task ...
>
> ---
> - name: FAILER!
> command: /bin/false
> #with_items:
> # - one
> # - two
> #ignore_errors: True
> ignore_errors: "{{ ignore_replication_errors | default(false) }}"
>
> If I go ...
>
> ansible-playbook test.pl --extra-vars "ignore_replication_errors=false"
> ansible-playbook test.pl --extra-vars "ignore_replication_errors=true"
>
> ... it works correctly ...
>
> localhost : ok=5 changed=1 unreachable=0 failed=1
> ... and ...
> localhost : ok=5 changed=1 unreachable=0 failed=0
>
> However, if I change it like this ...
> ---
> - name: FAILER!
> command: /bin/false
> with_items:
> - one
> - two
> #ignore_errors: True
> ignore_errors: "{{ ignore_replication_errors | default(false) }}"
>
> ... it always ignores ...
>
> localhost : ok=5 changed=1 unreachable=0 failed=0
>
> Also, it works as expected if I take the variable out and explicitly set
> True or False ...
> ---
> - name: FAILER!
> command: /bin/false
> with_items:
> - one
> - two
> ignore_errors: True
> #ignore_errors: "{{ ignore_replication_errors | default(false) }}"
>
> So, it kinda feels like the variable interpretation working differently
> when I throw with_items into the mix. I was thinking that maybe using
> quotes and squiggly braces was causing the value of the variable to be
> interpreted as a string instead of a boolean, but after a lot of fiddling
> with it (using |bool etc.) I couldn't find another syntax that worked.
>
> Is this a bug? Am I missing something?
>
> Thanks,
> --
> Glenn
>
> PS
>
> ansible-playbook --version
> ansible-playbook 2.3.1.0
> config file = ...
> configured module search path = Default w/o overrides
> python version = 2.7.13 (default, Jun 26 2017, 10:20:05) [GCC 7.1.1
> 20170622 (Red Hat 7.1.1-3)]
>
>
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4d5de415-d708-4b29-af02-d890673c7176%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.