I would like to set changed_when = not failed_when or vice versa. Is that
possible?
On Sunday, 18 January 2015 12:07:25 UTC-5, Mark Casey wrote:
>
> 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.
>
>
> On Thursday, January 15, 2015 at 2:24:40 PM UTC-6, Peter Mooshammer wrote:
>>
>> Well,
>>
>> I just tried and tested both:
>>
>> - 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
>>
>> and it seems to work or at least I hope so ....
>>
>> On Thursday, January 15, 2015 at 11:19:05 AM UTC-8, Mark Casey wrote:
>>>
>>> Hello list,
>>>
>>> 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(?).
>>>
>>> Thank you,
>>> Mark
>>>
>>
--
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/2ea29481-d985-44b5-93f3-096f58c37c23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.