<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">include_role</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2.3.0.0"><pre class="notranslate"><code class="notranslate">2.3.0.0
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Handlers are not found in <code class="notranslate">include_role</code>.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="roles/test/
├── included
│   └── handlers
│       └── main.yml
└── main
    └── tasks
        └── main.yml"><pre class="notranslate"><code class="notranslate">roles/test/
├── included
│   └── handlers
│       └── main.yml
└── main
    └── tasks
        └── main.yml
</code></pre></div>
<p dir="auto">roles/test/main/tasks/main.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- debug: msg=&quot;ping&quot;
  changed_when: yes
  notify: pong

- include_role:
    name: test/included
"><pre class="notranslate">- <span class="pl-ent">debug</span>: <span class="pl-s">msg="ping"</span>
  <span class="pl-ent">changed_when</span>: <span class="pl-s">yes</span>
  <span class="pl-ent">notify</span>: <span class="pl-s">pong</span>

- <span class="pl-ent">include_role</span>:
    <span class="pl-ent">name</span>: <span class="pl-s">test/included</span>
</pre></div>
<p dir="auto">roles/test/included/handlers/main.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: pong
  debug: msg=&quot;pong&quot;"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">pong</span>
  <span class="pl-ent">debug</span>: <span class="pl-s">msg="pong"</span></pre></div>
<p dir="auto">playbook</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: all
  roles:
    - role: test/main

  handlers:
    - name: other
      debug: msg=&quot;other&quot;
"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">all</span>
  <span class="pl-ent">roles</span>:
    - <span class="pl-ent">role</span>: <span class="pl-s">test/main</span>

  <span class="pl-ent">handlers</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">other</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">msg="other"</span>
</pre></div>
<p dir="auto">Note <code class="notranslate">handlers</code> section, works fine without it!</p>

<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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
"><pre class="notranslate"><code class="notranslate">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

</code></pre></div>
<p dir="auto">Clone of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="242378008" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/26698" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/26698/hovercard" href="https://github.com/ansible/ansible/issues/26698">#26698</a> that was closed instead of waiting for an update, good job <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/abadger/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/abadger">@abadger</a>.</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">include_role module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides
</code></pre></div>
<p dir="auto">Installed with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip2 install --user --upgrade git+https://github.com/ansible/ansible.git@v2.2.0.0-0.2.rc2#egg=ansible"><pre class="notranslate"><code class="notranslate">pip2 install --user --upgrade git+https://github.com/ansible/ansible.git@v2.2.0.0-0.2.rc2#egg=ansible
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">No config file.</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Sample to reproduce runs on gentoo with target also being gentoo.</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">If I include a role with the <code class="notranslate">include_role</code> module from a play with handlers then its handlers from the role are not available.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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: &quot;this should trigger main-handler-one&quot;
./main.yml:    command: &quot;uname -a&quot;
./main.yml:    notify: &quot;main-handler-one&quot;
./main.yml:  - include_role: { name: &quot;test.irh&quot;, static: yes }
./main.yml:  handlers:
./main.yml:  - name: &quot;main-handler-one&quot;
./main.yml:    debug: { msg: &quot;in main-handler-one&quot; }
./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: &quot;in test.irh-handler-one&quot; }
./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: &quot;this should trigger test.irh-handler-one&quot;
./roles/test.irh/tasks/main.yml:  command: &quot;uname -a&quot;
./roles/test.irh/tasks/main.yml:  notify: test.irh-handler-one"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">I expected <code class="notranslate">test.irh-handler-one</code> to run.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">Could not find <code class="notranslate">test.irh-handler-one</code>.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ 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"><pre class="notranslate"><code class="notranslate">$ 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
</code></pre></div>