title: Ansible not detecting Role default variables in its handler
body: <p>Does ansible pass Role Default variables to the Handlers within the same Role?</p>
  
  <p>Here's a minimal excerpt of the playbook that has the issue:</p>
  
  <p><strong>Role hierarchy</strong></p>
  
  <pre><code>- playbook.yml
  - roles/
    - gunicorn/
      - defaults/
        - main.yml
      - handlers/
        - main.yml
    - code-checkout/
      - tasks/
        - main.yml
  </code></pre>
  
  <p>Here's the file contents</p>
  
  <p><strong>gunicorn/defaults/main.yml</strong></p>
  
  <pre><code>---
  gu_log: "/tmp/gunicorn.log"
  </code></pre>
  
  <p><strong>gunicorn/handlers/main.yml</strong></p>
  
  <pre><code>---
  - name: Clear Gunicorn Log
    shell: rm {{ gu_log }}
  </code></pre>
  
  <p><strong>finalize/tasks/main.yml</strong></p>
  
  <pre><code>---
  - name: Test Handlers
    shell: ls
    notify:
      - Restart Gunicorn
  </code></pre>
  
  <p><strong>playbook.yml</strong></p>
  
  <pre><code>---
    - name: Deploy
      hosts: webservers
      tasks:
        - include: roles/finalize/tasks/main.yml
      handlers:
        - include: roles/gunicorn/handlers/main.yml
  </code></pre>
  
  <p>AFAIK everything looks good. However, I get this error during the playbook execution</p>
  
  <blockquote>
    <p>FAILED! => {"failed": true, "msg": "the field 'args' has an invalid
    value, which appears to include a variable that is undefined. The
    error was: 'gu_log' is undefined\n\nThe error appears to have been in
    '/roles/gunicorn/handlers/main.yml':
    line 3, column 3, but may\nbe elsewhere in the file depending on the
    exact syntax problem.\n\nThe offending line appears to be:\n\n\n-
    name: Restart Gunicorn\n  ^ here\n"}</p>
  </blockquote>
  
  <p>Using Ansible 2.2 on Ubuntu 12.04 LTS</p>
  
  <p>Here's a modified version of techraf's script that creates all the directories and demonstrates my issue</p>
  
  <pre><code>#!/bin/bash
  
  mkdir -p ./rtindru-test/roles/gunicorn
  mkdir -p ./rtindru-test/roles/gunicorn/defaults
  mkdir -p ./rtindru-test/roles/gunicorn/handlers
  mkdir -p ./rtindru-test/roles/finalize/tasks
  
  cat &gt;./rtindru-test/roles/finalize/tasks/main.yml &lt;&lt;HANDLERS_END
  ---
  - name: Test Handlers
    shell: rm {{ gu_log }}
  HANDLERS_END
  
  cat &gt;./rtindru-test/roles/gunicorn/handlers/main.yml &lt;&lt;HANDLERS_END
  ---
  - name: Clear Gunicorn Log
    shell: rm {{ gu_log }}
  HANDLERS_END
  
  cat &gt;./rtindru-test/roles/gunicorn/defaults/main.yml &lt;&lt;DEFAULTS_END
  ---
  gu_log: "/tmp/gunicorn.log"
  DEFAULTS_END
  
  cat &gt;./rtindru-test/playbook.yml &lt;&lt;PLAYBOOK_END
  ---
    - name: Deploy
      hosts: localhost
      tasks:
        - include: roles/finalize/tasks/main.yml
      handlers:
        - include: roles/gunicorn/handlers/main.yml
  PLAYBOOK_END
  
  touch /tmp/gunicorn.log
  ls -l /tmp/gunicorn.log
  ansible-playbook ./rtindru-test/playbook.yml
  ls -l /tmp/gunicorn.log
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <blockquote>
    <p>PLAY [Deploy]</p>
    
    <hr>
    
    <p>TASK [setup]
    ******************************************************************* ok: [localhost]</p>
    
    <p>TASK [Test Handlers]
    *********************************************************** fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has
    an invalid value, which appears to include a variable that is
    undefined. The error was: 'gu_log' is undefined\n\nThe error appears
    to have been in '/rtindru-test/roles/finalize/tasks/main.yml': line 2,
    column 3, but may\nbe elsewhere in the file depending on the exact
    syntax problem.\n\nThe offending line appears to be:\n\n---\n- name:
    Test Handlers\n  ^ here\n"}   to retry, use: --limit
    @/rtindru-test/playbook.retry</p>
    
    <p>PLAY RECAP
    ********************************************************************* localhost                  : ok=1    changed=0    unreachable=0<br>
    failed=1</p>
  </blockquote>