Do ‘failed_when:’ and ‘changed_when:’ effect one another?
(i.e. a failed task returns changed instead of failed because you’d specified both flags or vice versa?)
I guess I’m assuming that in any case ‘failed’ supersedes ‘changed’, and these flags just change the definition of those conditions and not their precedence(?).
name: run python script to make ip static
script: …/files/gce_setip.py -a {{ item.public_ip }} -n {{ ipaddrname }} -z {{ zone }}
register: res
failed_when: “res.rc == 2”
changed_when: “res.rc == 0”
with_items: gce.instance_data
Thanks; I think I was a little vague, sorry. I’m actually already using them together to evaluate the return output of a script and determine what task state to return, and I wanted to just remove the ‘failed_when:’ line and let Ansible rely on the return code of the script being called instead of looking at the text it returns. But I wanted to leave the changed_when looking at the output.
I was initially (probably over-thinking it and) curious if there were any corner cases where that could effect if the task still used ‘changed_when:’ as I wanted it to, but having thought about it for a while I’m 99.9% sure that the only time my ‘changed_when:’ will get overridden is when the task actually fails according to the return code. And in that case I obviously would want the failed status to supersede whether or not the changed_when matched.