I’ve been trying to find a way of accomplishing this (what the subject says). I thought on using blocks, for example:
`
- block:
- name: run task
command:
register: command_result
failed_when: command_result.changed
rescue:
- name: stop task on all other nodes
command:
delegate_to: ‘{{ item }}’
with_items: ‘{{ groups.all }}’
`
Can you think of any other alternative?
Thanks!
Forgot to mention that the reason what the above doesn’t work is because the rescue
tasks are executed only after all the hosts have finished executing the task
Thanks for the suggestion. The problem is that I have other tasks (like local_action) that are not compatible with ‘strategy: free’
To my knowledge strategy free and local_action is not a problem, do mean that you task is not compatible?
If so you are pretty much out of luck since strategy linear work by running all task on all host before advancing to the next.
One thing could be to split the play in three.
One play with linear, one with free that only run that particular task, and then the last play with linear again.
Sorry, I meant ‘run_once’ (it’s incompatible because every host is going on independently). I think I’ll go with having multiple playbooks. Thanks!