# Sequencing of handlers between roles

**URL:** <https://forum.ansible.com/t/sequencing-of-handlers-between-roles/13715>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [October 18, 2013, 12:14pm UTC](https://forum.ansible.com/t/sequencing-of-handlers-between-roles/13715 "2013-10-18T12:14:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 18, 2013, 12:14pm UTC](https://forum.ansible.com/t/sequencing-of-handlers-between-roles/13715/1 "2013-10-18T12:14:39Z")

</div>

[The Manifesto for Agentic Automation](http://www.ansibleworks.com/docs/playbooks.html#handlers-running-operations-on-change) says:

“These ‘notify’ actions are triggered at the end of each block of tasks in a playbook”

What’s a block of tasks: the set of tasks within a role, or all the tasks in all roles combined?

It looks like the latter. I tried to use a handler to do an apt update cache only if a new PPA has been added, but it fails:

==\> s1-macmini.yml \<==

# This playbook runs against the localhost, assuming it is a Mac Mini

# and is acting in the s1 role

- hosts: s1  
connection: local  
roles:
- macmini-ubuntu-repos
- macmini-ubuntu-packages

==\> roles/macmini-ubuntu-repos/tasks/main.yml \<==

# These are the repos which should be available on a Mac Mini

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 18, 2013, 1:30pm UTC](https://forum.ansible.com/t/sequencing-of-handlers-between-roles/13715/2 "2013-10-18T13:30:41Z")

</div>

“What’s a block of tasks: the set of tasks within a role, or all the tasks in all roles combined?”

All tasks in “pre\_tasks”, “roles/tasks”, and “post\_tasks” are seperate blocks.

You can also force handler execution with:

- meta: flush\_handlers

as a task line.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 18, 2013, 3:10pm UTC](https://forum.ansible.com/t/sequencing-of-handlers-between-roles/13715/3 "2013-10-18T15:10:41Z")

</div>

> You can also force handler execution with:
> 
> - meta: flush\_handlers
> 
> as a task line.

That was the solution, thanks!

- apt\_repository: repo=ppa:mactel-support  
notify: apt update cache
- meta: flush\_handlers

Regards,

Brian.
