Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

include_role

ANSIBLE VERSION

2.3.0.0

SUMMARY

Handlers are not found in include_role.

STEPS TO REPRODUCE

roles/test/
├── included
│ └── handlers
│ └── main.yml
└── main
└── tasks
└── main.yml

roles/test/main/tasks/main.yml

- debug: msg="ping"
changed_when: yes
notify: pong

- include_role:
name: test/included

roles/test/included/handlers/main.yml

- name: pong
debug: msg="pong"

playbook

- hosts: all
roles:
- role: test/main

handlers:
- name: other
debug: msg="other"

Note handlers section, works fine without it!

ACTUAL RESULTS

PLAY [all] *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [setup] **********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [all]

TASK [test/main : debug] **********************************************************************************************************************************************************************************************************************************************************************************************************************************************
ERROR! The requested handler 'pong' was not found in either the main handlers list nor in the listening handlers list

Clone of #26698 that was closed instead of waiting for an update, good job @abadger.

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

include_role module

ANSIBLE VERSION

ansible 2.2.0.0
config file =
configured module search path = Default w/o overrides

Installed with:

pip2 install --user --upgrade git+https://github.com/ansible/ansible.git@v2.2.0.0-0.2.rc2#egg=ansible

CONFIGURATION

No config file.

OS / ENVIRONMENT

Sample to reproduce runs on gentoo with target also being gentoo.

SUMMARY

If I include a role with the include_role module from a play with handlers then its handlers from the role are not available.

STEPS TO REPRODUCE

iwana@iwana-nb.concurrent.co.za:/var/tmp
$ git clone https://gitlab.com/iwan.aucamp/issue-ansible-201610-000-include_role.git
Cloning into 'issue-ansible-201610-000-include_role'...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 10 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (10/10), done.
Checking connectivity... done.
iwana@iwana-nb.concurrent.co.za:/var/tmp
$ cd issue-ansible-201610-000-include_role
iwana@iwana-nb.concurrent.co.za:/var/tmp/issue-ansible-201610-000-include_role
(failed reverse-i-search)`ansibile -p': cd issue-^Csible-201610-000-include_role
iwana@iwana-nb.concurrent.co.za:/var/tmp/issue-ansible-201610-000-include_role
$ ansible-playbook main.yml

iwana@iwana-nb.concurrent.co.za:/var/tmp/issue-ansible-201610-000-include_role
$ find . -name .git -prune -o -type f ! -name 'README*' -print | sort | xargs grep '^'
./main.yml:# vim: set sts=2 ts=2 sw=2 filetype=yaml expandtab:
./main.yml:---
./main.yml:- hosts: localhost
./main.yml: tasks:
./main.yml: - name: "this should trigger main-handler-one"
./main.yml: command: "uname -a"
./main.yml: notify: "main-handler-one"
./main.yml: - include_role: { name: "test.irh", static: yes }
./main.yml: handlers:
./main.yml: - name: "main-handler-one"
./main.yml: debug: { msg: "in main-handler-one" }
./roles/test.irh/handlers/main.yml:# vim: set sts=2 ts=2 sw=2 filetype=yaml expandtab:
./roles/test.irh/handlers/main.yml:---
./roles/test.irh/handlers/main.yml:- name: test.irh-handler-one
./roles/test.irh/handlers/main.yml: debug: { msg: "in test.irh-handler-one" }
./roles/test.irh/tasks/main.yml:# vim: set sts=2 ts=2 sw=2 filetype=yaml expandtab:
./roles/test.irh/tasks/main.yml:---
./roles/test.irh/tasks/main.yml:- name: "this should trigger test.irh-handler-one"
./roles/test.irh/tasks/main.yml: command: "uname -a"
./roles/test.irh/tasks/main.yml: notify: test.irh-handler-one

EXPECTED RESULTS

I expected test.irh-handler-one to run.

ACTUAL RESULTS

Could not find test.irh-handler-one.

$ ansible-playbook main.yml
[WARNING]: Host file not found: /etc/ansible/hosts

[WARNING]: provided hosts list is empty, only localhost is available

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [this should trigger main-handler-one] ************************************
changed: [localhost]

TASK [test.irh : this should trigger test.irh-handler-one] *********************
ERROR! The requested handler 'test.irh-handler-one' was not found in either the main handlers list nor in the listening handlers list