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

**URL:** <https://forum.ansible.com/t/have-a-script-start-running-at-a-certain-tag-and-run-for-every-task-that-follows/21839>\
**Category:** Ansible Project\
**Created:** [June 22, 2016, 10:08pm UTC](https://forum.ansible.com/t/have-a-script-start-running-at-a-certain-tag-and-run-for-every-task-that-follows/21839 "2016-06-22T22:08:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgoldsb](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mgoldsb](https://forum.ansible.com/u/mgoldsb)\
**Post date:** [June 22, 2016, 10:08pm UTC](https://forum.ansible.com/t/have-a-script-start-running-at-a-certain-tag-and-run-for-every-task-that-follows/21839/1 "2016-06-22T22:08:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 23, 2016, 7:49am UTC](https://forum.ansible.com/t/have-a-script-start-running-at-a-certain-tag-and-run-for-every-task-that-follows/21839/2 "2016-06-23T07:49:29Z")

</div>

Sounds like you might need --start-at-task see [http://docs.ansible.com/ansible/playbooks\_startnstep.html](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

---

<div class="post-metadata">

**Author:** ![mgoldsb](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mgoldsb](https://forum.ansible.com/u/mgoldsb)\
**Post date:** [June 23, 2016, 2:19pm UTC](https://forum.ansible.com/t/have-a-script-start-running-at-a-certain-tag-and-run-for-every-task-that-follows/21839/3 "2016-06-23T14:19:13Z")

</div>

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:

[![](https://lh3.googleusercontent.com/-6k5Hy4EPWnk/V2vvv9qTw1I/AAAAAAAABhw/e9anxP_9bbckAAtTGyhcwiNY35PYTKl9wCLcB/s320/JobTemplate.PNG)](https://lh3.googleusercontent.com/-6k5Hy4EPWnk/V2vvv9qTw1I/AAAAAAAABhw/e9anxP_9bbckAAtTGyhcwiNY35PYTKl9wCLcB/s1600/JobTemplate.PNG)
