Have a script start running at a certain tag and run for every task that follows

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.

Sounds like you might need --start-at-task see http://docs.ansible.com/ansible/playbooks_startnstep.html
It’s been a while since I looked at the Tower ui but I think its an option on the each job from what I remember.

Hope this helps,

Jon

Yeah, I think I heard about --start-at-task, but unfortunately I’m not sure if there’s any way to implement that in a Tower job template. Here’s a screenshot of what the job template UI looks like: