<p dir="auto">Consider:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: all

  tasks:

    - name: echo stuff
      command: 'echo &quot;{{ item }}&quot;'
      notify: notifier {{ item }}
      with_items: 
        - &quot;a&quot;
        - &quot;b&quot;
        - &quot;c&quot;

  handlers:

    - name: notifier a
      command: 'echo &quot;A OK&quot;'

    - name: notifier b
      command: 'echo &quot;B OK&quot;'

    - name: notifier c
      command: 'echo &quot;C OK&quot;'"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">all</span>

  <span class="pl-ent">tasks</span>:

    - <span class="pl-ent">name</span>: <span class="pl-s">echo stuff</span>
      <span class="pl-ent">command</span>: <span class="pl-s"><span class="pl-pds">'</span>echo "{{ item }}"<span class="pl-pds">'</span></span>
      <span class="pl-ent">notify</span>: <span class="pl-s">notifier {{ item }}</span>
      <span class="pl-ent">with_items</span>: 
        - <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span>
        - <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>
        - <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span>

  <span class="pl-ent">handlers</span>:

    - <span class="pl-ent">name</span>: <span class="pl-s">notifier a</span>
      <span class="pl-ent">command</span>: <span class="pl-s"><span class="pl-pds">'</span>echo "A OK"<span class="pl-pds">'</span></span>

    - <span class="pl-ent">name</span>: <span class="pl-s">notifier b</span>
      <span class="pl-ent">command</span>: <span class="pl-s"><span class="pl-pds">'</span>echo "B OK"<span class="pl-pds">'</span></span>

    - <span class="pl-ent">name</span>: <span class="pl-s">notifier c</span>
      <span class="pl-ent">command</span>: <span class="pl-s"><span class="pl-pds">'</span>echo "C OK"<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">This errors (on ansible 1.8.2) with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [test_server_3]
ok: [test_server_2]
ok: [test_server_1]

TASK: [echo stuff] ************************************************************
changed: [test_server_2] =&gt; (item=a)
changed: [test_server_3] =&gt; (item=a)
changed: [test_server_1] =&gt; (item=a)
changed: [test_server_2] =&gt; (item=b)
changed: [test_server_1] =&gt; (item=b)
changed: [test_server_3] =&gt; (item=b)
changed: [test_server_1] =&gt; (item=c)
changed: [test_server_2] =&gt; (item=c)
changed: [test_server_3] =&gt; (item=c)
ERROR: change handler (notifier {{ item }}) is not defined"><pre class="notranslate"><code class="notranslate">PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [test_server_3]
ok: [test_server_2]
ok: [test_server_1]

TASK: [echo stuff] ************************************************************
changed: [test_server_2] =&gt; (item=a)
changed: [test_server_3] =&gt; (item=a)
changed: [test_server_1] =&gt; (item=a)
changed: [test_server_2] =&gt; (item=b)
changed: [test_server_1] =&gt; (item=b)
changed: [test_server_3] =&gt; (item=b)
changed: [test_server_1] =&gt; (item=c)
changed: [test_server_2] =&gt; (item=c)
changed: [test_server_3] =&gt; (item=c)
ERROR: change handler (notifier {{ item }}) is not defined
</code></pre></div>
<p dir="auto">It would awesome to define handlers with variable reference.</p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.5.3</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Parent task unable to call handlers of child</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="production.yml
roles/
  upstart/
    tasks/
      main.yml
    templates/
      upstart.conf.j2
  graphite-web/
    handlers/
      main.yml
    meta/
      main.yml"><pre class="notranslate"><code class="notranslate">production.yml
roles/
  upstart/
    tasks/
      main.yml
    templates/
      upstart.conf.j2
  graphite-web/
    handlers/
      main.yml
    meta/
      main.yml
</code></pre></div>
<p dir="auto">roles/upstart/tasks/main.yml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: config | {{ name }} | upstart template
  sudo: yes
  template: src=upstart.conf.j2 dest=/etc/init/{{ name }}.conf
  ignore_errors: true
  notify: restart {{ name }}"><pre class="notranslate"><code class="notranslate">- name: config | {{ name }} | upstart template
  sudo: yes
  template: src=upstart.conf.j2 dest=/etc/init/{{ name }}.conf
  ignore_errors: true
  notify: restart {{ name }}
</code></pre></div>
<p dir="auto">roles/upstart/templates/upstart.conf.j2:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="description '{{ name }} upstart script'
author 'Joel'

start on (local-filesystems and net-device-up)
stop on shutdown

instance &quot;{{ name }}&quot;

respawn
respawn limit 5 60
limit nofile 165962 165962

script
  {{script}}
end script"><pre class="notranslate"><code class="notranslate">description '{{ name }} upstart script'
author 'Joel'

start on (local-filesystems and net-device-up)
stop on shutdown

instance "{{ name }}"

respawn
respawn limit 5 60
limit nofile 165962 165962

script
  {{script}}
end script
</code></pre></div>
<p dir="auto">roles/graphite-web/handlers/main.yml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: restart graphite
  sudo: yes
  service: name=graphite-web state=restarted"><pre class="notranslate"><code class="notranslate">- name: restart graphite
  sudo: yes
  service: name=graphite-web state=restarted
</code></pre></div>
<p dir="auto">roles/graphite-web/meta/main.yml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
dependencies:
  - { role: upstart, name: graphite-web, script: &quot;/bin/true&quot; }"><pre class="notranslate"><code class="notranslate">
---
dependencies:
  - { role: upstart, name: graphite-web, script: "/bin/true" }
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Play should run without errors, roles/upstart/tasks/main.yml should be able to call a notify on roles/graphite-web/handlers/main.yml</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">ERROR: change handler (restart graphite-web) is not defined<br>
Ansible failed to complete successfully. Any error output should be<br>
visible above. Please fix these errors and try again.</p>