Hi. I’m trying to implement an ad-hoc “restart” functionality in Ansible Tower similar to what is in the core Ansible CLI. My idea is that, if a deployment fails, I can restart it at the tag that it failed at–however, if I specify this tag in the deployment, it will ONLY run that tag. I am looking for a way such the deployment will start running at that specific tag and then continue to all of the subsequent tasks.
I can see one potential method whereby tags are added sequentially with each task. For instance,
- name: First task
shell: echo “Kilroy Was Here” > /home/mgoldsb/Hello.txt
failed_when: “{{ First }} == true”
tags:
- First_Task
- name: Second task
shell: echo “Kilroy Was Here” > /home/mgoldsb/World.txt
failed_when: “{{ Second }} == true”
tags:
- First_Task
- Second_Task
- name: Third task
#shell: echo “Kilroy Was Here” > /home/mgoldsb/Hows.txt
shell: rm -f testthis.txt
failed_when: “{{ Third }} == true”
tags:
- First_Task
- Second_Task
- Third_Task
- name: Fourth task
shell: echo “Kilroy Was Here” > /home/mgoldsb/It.txt
failed_when: “{{ Fourth }} == true”
tags:
- First_Task
- Second_Task
- Third_Task
- Fourth_Task
- name: Fifth task
shell: echo “Kilroy Was Here” > /home/mgoldsb/Going.txt
failed_when: “{{ Fifth }} == true”
tags:
- First_Task
- Second_Task
- Third_Task
- Fourth_Task
- First_Task
However, I would much rather prefer only having a single tag for each task that uniquely refers to that task.
Can anyone offer any suggestions?
Thanks in advance.