Ansible v2.4.0 - Handlers from included roles fail

Hello,

I’ve been playing with ansible for a couple of days and ran into some trouble with Ansible v2.4.0 (the “git” version).

Following the best practices of the documentation, I use roles and my project has basically the following structure (I’m just showing the relevant files for the sake of readability):

.
├── roles
│ ├── cassandra
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── tasks
│ │ │ └── main.yml
│ ├── common
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── tasks
│ │ │ └── main.yml
│ ├── email
│ │ ├── handlers
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
│ ├── NTP
│ │ ├── handlers
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
│ └── unattended_upgrades
│ ├── tasks
│ └── main.yml
└── site.yml

My playbook (the site.yml file) references the following roles:

roles:

  • common
  • unattended_upgrades
  • cassandra

Then in turn the unattended_upgrades and cassandra tasks reference respectively the email and NTP roles via an include directive.

Here are the problems I run into when I execute my playbook:

  1. Handlers from common role seem to fail silently: I don’t see any “RUNNING HANDLER” in the standard output nor any error. What seems weird to me is that handlers from the cassandra role get executed correctly. Am I missing something here?

  2. Handlers from roles included in roles (even with static: true) fail with the following error: ERROR! The requested handler was not found in either the main handlers list nor in the listening handlers list. It seems there is already a GitHub issue about this one.

So, any idea about problem #1 and a workaround for problem #2 (apart from adding the roles to the roles’ list of the playbook)?

Thanks!

PS: I don’t think it matters but I’m running ansible from “bash on Ubuntu on Windows” (Ubuntu 16.04 / Windows 10 x64).

Update:

After going through the documentation again I realized I made a mistake including roles in other roles: I was just including the tasks/main.yml file of the other role instead of the the whole role (by declaring a dependency in a meta/main.yml file, see role-dependencies for more details).

As a matter of fact it solved my first problem too, all handlers from my different roles are now executed at the end of the playbook (once all the tasks from the different roles have been executed). By the way, it makes me wonder why the handlers don’t get executed at the end of each role, since documentation states:

Roles are described later on, but it’s worthwhile to point out that:

  • handlers notified within pre_tasks, tasks, and post_tasks sections are automatically flushed in the end of section where they were notified;

Does it mean that roles listed in the roles’ list of my playbook are somewhat merged together at “compilation time” (resulting in single merged tasks and handlers sections)?

Sylvain