title: How to share handlers?
body: <p><a href="http://docs.ansible.com/ansible/playbooks_roles.html#introduction" rel="noreferrer">The docs</a> says:</p>
  <blockquote>
  <p>Since handlers are tasks too, you can also include handler files from the ‘handlers:’ section.</p>
  </blockquote>
  <p>What I do, <code>playbook.yml</code>:</p>
  <pre><code>- hosts: all
    handlers:
      - include: handlers.yml
      # - name: h1
        # debug: msg=h1
    tasks:
      - debug: msg=test
        notify: h1
        changed_when: true
  </code></pre>
  <p><code>handlers.yml</code>:</p>
  <pre><code>- name: h1
    debug: msg=h1
  </code></pre>
  <p>Then,</p>
  <pre><code>$ ansible-playbook playbook.yml -i localhost, -k -e ansible_python_interpreter=python2 -v
  ...
  TASK [debug] *******************************************************************
  ok: [localhost] =&gt; {
      &quot;msg&quot;: &quot;test&quot;
  }
  
  PLAY RECAP *********************************************************************
  localhost                  : ok=3    changed=1    unreachable=0    failed=0
  ...
  </code></pre>
  <p>But when I uncomment the lines, I see</p>
  <pre><code>$ ansible-playbook playbook.yml -i localhost, -k -e ansible_python_interpreter=python2 -v
  ...
  TASK [debug] *******************************************************************
  ok: [localhost] =&gt; {
      &quot;msg&quot;: &quot;test&quot;
  }
  
  RUNNING HANDLER [h1] ***********************************************************
  ok: [localhost] =&gt; {
      &quot;msg&quot;: &quot;h1&quot;
  }
  
  PLAY RECAP *********************************************************************
  localhost                  : ok=3    changed=1    unreachable=0    failed=0
  ...
  </code></pre>
  <p>I'm running <code>ansible-2.1.0.0</code>.</p>
  <p>What am I doing wrong? That's <strong>the first thing</strong> I'd like to know. Workarounds come second.</p>
  <p><strong>UPD</strong></p>
  <blockquote>
  <p>Includes can also be used in the ‘handlers’ section, for instance, if you want to define how to restart apache, you only have to do that once for all of your playbooks. You might make a handlers.yml that looks like:</p>
  <pre><code>---
  # this might be in a file like handlers/handlers.yml
  - name: restart apache
    service: name=apache state=restarted
  </code></pre>
  <p>And in your main playbook file, just include it like so, at the bottom of a play:</p>
  <pre><code>handlers:
    - include: handlers/handlers.yml
  </code></pre>
  </blockquote>