# Dependencies between tasks possible?

**URL:** <https://forum.ansible.com/t/dependencies-between-tasks-possible/16492>\
**Category:** Ansible Project\
**Created:** [October 13, 2014, 8:00am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492 "2014-10-13T08:00:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![berndadamowicz](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@berndadamowicz](https://forum.ansible.com/u/berndadamowicz)\
**Post date:** [October 13, 2014, 8:00am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492/1 "2014-10-13T08:00:27Z")

</div>

Hi All!

Just want to say hello to all first since this is my first post to this list!

My questions is if there is a way to have dependencies between tasks. Example: I have one task which puts a shell script in place, and the a second task which establishes a cron job which uses this script. So if copying of the script fails for whatever reason, it will make no sense to put the cron job in place. So is there a way to create such a dependency/requirement between tasks?

Maybe I could use handlers, but this seems to be a kind of misuse. Any suggestions appreciated.

Thanks  
Bernd

---

<div class="post-metadata">

**Author:** ![James\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@James\_Martin1](https://forum.ansible.com/u/James_Martin1)\
**Post date:** [October 14, 2014, 2:11am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492/2 "2014-10-14T02:11:14Z")

</div>

If the task that copies the shell script fails, then the following tasks (in this case the cron job task) will not execute for that host.

- James

---

<div class="post-metadata">

**Author:** ![berndadamowicz](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@berndadamowicz](https://forum.ansible.com/u/berndadamowicz)\
**Post date:** [October 14, 2014, 9:34am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492/3 "2014-10-14T09:34:57Z")

</div>

This will imply that the order in which tasks are executed in a playbook is from top to bottom and I only have to use the right order. Is this (the order of executing tasks) a guaranteed feature of Ansible?

Bernd

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [October 14, 2014, 9:37am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492/4 "2014-10-14T09:37:37Z")

</div>

Hi Bernd,

yes, it is how ansible works. Tasks are executed from top to bottom in order.

David

---

<div class="post-metadata">

**Author:** ![Tomasz\_Kontusz](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@Tomasz\_Kontusz](https://forum.ansible.com/u/Tomasz_Kontusz)\
**Post date:** [October 14, 2014, 9:38am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492/5 "2014-10-14T09:38:11Z")

</div>

berndadamowicz@googlemail.com napisał:

> This will imply that the order in which tasks are executed in a  
> playbook is  
> from top to bottom and I only have to use the right order. Is this (the
> 
> order of executing tasks) a guaranteed feature of Ansible?

Yes, it is. It's one of the selling points actually, as it makes orchestration simpler.

---

<div class="post-metadata">

**Author:** ![berndadamowicz](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@berndadamowicz](https://forum.ansible.com/u/berndadamowicz)\
**Post date:** [October 14, 2014, 10:16am UTC](https://forum.ansible.com/t/dependencies-between-tasks-possible/16492/6 "2014-10-14T10:16:22Z")

</div>

OK. Thanks to all for clarifying!

Bernd
