# tasks ordering:: is it guaranteed by register/when usage?

**URL:** <https://forum.ansible.com/t/tasks-ordering-is-it-guaranteed-by-register-when-usage/37472>\
**Category:** Ansible Project\
**Created:** [December 15, 2022, 3:48pm UTC](https://forum.ansible.com/t/tasks-ordering-is-it-guaranteed-by-register-when-usage/37472 "2022-12-15T15:48:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adriansev](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/adriansev/32/4866_2.png) [@adriansev](https://forum.ansible.com/u/adriansev)\
**Post date:** [December 15, 2022, 3:48pm UTC](https://forum.ansible.com/t/tasks-ordering-is-it-guaranteed-by-register-when-usage/37472/1 "2022-12-15T15:48:28Z")

</div>

Hi! Would the tasks be automatically ordered when  
i register a task1\_status and then i require task2  
a when: task1\_status is succeeded ?

Is there any chance even if the ordering in file  
is "task1 -\> task2" that task2 is skipped because  
task1 did not get to run and register task1\_status?

Thanks a lot!  
Adrian

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 15, 2022, 3:58pm UTC](https://forum.ansible.com/t/tasks-ordering-is-it-guaranteed-by-register-when-usage/37472/2 "2022-12-15T15:58:15Z")

</div>

Tasks are always executed in order for a specific host, even with non  
linear strategies the most you can have is hosts at a different task,  
but none skipping task order.

---

<div class="post-metadata">

**Author:** ![adriansev](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/adriansev/32/4866_2.png) [@adriansev](https://forum.ansible.com/u/adriansev)\
**Post date:** [December 30, 2022, 8:12am UTC](https://forum.ansible.com/t/tasks-ordering-is-it-guaranteed-by-register-when-usage/37472/3 "2022-12-30T08:12:10Z")

</div>

Thanks a lot for clarification!  
But then what is the actual intent/usage of pre\_tasks and post\_tasks?

Thanks a lot!  
Adrian

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 31, 2022, 11:44pm UTC](https://forum.ansible.com/t/tasks-ordering-is-it-guaranteed-by-register-when-usage/37472/4 "2022-12-31T23:44:31Z")

</div>

pre\_tasks run before roles:, which run before tasks: , post\_tasks are  
really not needed, they run after tasks:
