Sequencing of handlers between roles

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

“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.

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.