<p dir="auto"><strong>Issue Type:</strong> Bug Report, Regression from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="152893515" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/15713" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/15713/hovercard" href="https://github.com/ansible/ansible/issues/15713">#15713</a></p>
<p dir="auto"><strong>Component Name:</strong> handlers</p>
<p dir="auto"><strong>Ansible Version:</strong> 2.2.0.0</p>
<p dir="auto"><strong>Environment:</strong> OS X 10.11.6</p>
<p dir="auto"><strong>Summary:</strong> Under Ansible 2.2.0.0, Jinja variables contained in a handler <code class="notranslate">name</code> are no longer populated. Under Ansible 1.9.x and 2.1.1.0, they were populated. Here's a quick example:</p>
<p dir="auto"><strong>Steps To Reproduce:</strong></p>
<ol dir="auto">
<li>
<p dir="auto">Write this content to <code class="notranslate">playbook.yml</code>:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: localhost
  connection: local
  vars:
    appname: someapp
  handlers:
  # The following line, when the handler is executed, does not populate {{ appname }}
  - name: restart {{ appname }}
    debug:
      msg: some bogus module call in handler {{ appname }}
  tasks:
  - name: bogus task with notify for {{ appname }}
    command: ls
    notify: restart {{ appname }}"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">connection</span>: <span class="pl-s">local</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">appname</span>: <span class="pl-s">someapp</span>
  <span class="pl-ent">handlers</span>:
  <span class="pl-c"><span class="pl-c">#</span> The following line, when the handler is executed, does not populate {{ appname }}</span>
  - <span class="pl-ent">name</span>: <span class="pl-s">restart {{ appname }}</span>
    <span class="pl-ent">debug</span>:
      <span class="pl-ent">msg</span>: <span class="pl-s">some bogus module call in handler {{ appname }}</span>
  <span class="pl-ent">tasks</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">bogus task with notify for {{ appname }}</span>
    <span class="pl-ent">command</span>: <span class="pl-s">ls</span>
    <span class="pl-ent">notify</span>: <span class="pl-s">restart {{ appname }}</span></pre></div>
</li>
<li>
<p dir="auto">Run the playbook: <code class="notranslate">ansible-playbook --connection=local playbook.yml</code></p>
</li>
</ol>
<p dir="auto"><strong>Expected Results:</strong> In the output of the playbook run, any mention of <code class="notranslate">{{ appname }}</code> should not appear, but replaced with <code class="notranslate">someapp</code>, per the given variables.</p>
<p dir="auto"><strong>Actual Results:</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  [WARNING]: Host file not found: /usr/local/etc/ansible/hosts

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


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

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

TASK [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart {{ appname }}] ****************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;some bogus module call in handler someapp&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">  [WARNING]: Host file not found: /usr/local/etc/ansible/hosts

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


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

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

TASK [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart {{ appname }}] ****************************************
ok: [localhost] =&gt; {
    "msg": "some bogus module call in handler someapp"
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   
</code></pre></div>
<p dir="auto">Note that in the <code class="notranslate">RUNNING HANDLER</code> line, the Jinja template syntax is printed literally, rather than being populated with the variable that clearly exists, since it's populated elsewhere. This is a regression from <a href="https://github.com/ansible/ansible/issues/14082" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/14082/hovercard">1.9.x</a> and <a href="https://github.com/ansible/ansible/issues/16922#issuecomment-251805585" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/16922/hovercard">2.1.1.0</a>.</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report (same as <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="152893515" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/15713" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/15713/hovercard" href="https://github.com/ansible/ansible/issues/15713">#15713</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="128227674" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/14082" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/14082/hovercard" href="https://github.com/ansible/ansible/issues/14082">#14082</a>)</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<ul dir="auto">
<li>Handlers and variable interpolation</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.3.0 (devel 9962245b92) last updated 2016/10/06 09:55:33 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 0ee774ff15) last updated 2016/10/06 09:55:59 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 5cc72c3f06) last updated 2016/10/06 09:55:59 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.3.0 (devel 9962245b92) last updated 2016/10/06 09:55:33 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 0ee774ff15) last updated 2016/10/06 09:55:59 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 5cc72c3f06) last updated 2016/10/06 09:55:59 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook 2.2.0.0 (stable-2.2 be6396d5e9) last updated 2016/10/05 17:40:02 (GMT -400)
  lib/ansible/modules/core: (detached HEAD a6b8215e62) last updated 2016/10/05 17:45:10 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD d42975e068) last updated 2016/10/05 17:45:11 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook play.yaml 
 [WARNING]: provided hosts list is empty, only localhost is available"><pre class="notranslate"><code class="notranslate">ansible-playbook 2.2.0.0 (stable-2.2 be6396d5e9) last updated 2016/10/05 17:40:02 (GMT -400)
  lib/ansible/modules/core: (detached HEAD a6b8215e62) last updated 2016/10/05 17:45:10 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD d42975e068) last updated 2016/10/05 17:45:11 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook play.yaml 
 [WARNING]: provided hosts list is empty, only localhost is available
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook 2.1.2.0 (stable-2.1 a7d0cc6e61) last updated 2016/10/05 17:42:07 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 4602021670) last updated 2016/10/05 17:43:21 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD d312f34d9b) last updated 2016/10/05 17:43:22 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook play.yaml 
 [WARNING]: provided hosts list is empty, only localhost is available"><pre class="notranslate"><code class="notranslate">ansible-playbook 2.1.2.0 (stable-2.1 a7d0cc6e61) last updated 2016/10/05 17:42:07 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 4602021670) last updated 2016/10/05 17:43:21 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD d312f34d9b) last updated 2016/10/05 17:43:22 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook play.yaml 
 [WARNING]: provided hosts list is empty, only localhost is available
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.2.0 (detached HEAD 29f2f26278) last updated 2016/10/06 11:25:15 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 17ee1cfaf9) last updated 2016/10/06 11:30:32 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD d312f34d9b) last updated 2016/10/06 11:30:32 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook --connection=local play.yaml
 [WARNING]: Host file not found: /etc/ansible/hosts"><pre class="notranslate"><code class="notranslate">ansible 2.1.2.0 (detached HEAD 29f2f26278) last updated 2016/10/06 11:25:15 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 17ee1cfaf9) last updated 2016/10/06 11:30:32 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD d312f34d9b) last updated 2016/10/06 11:30:32 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook --connection=local play.yaml
 [WARNING]: Host file not found: /etc/ansible/hosts
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.1.0 (detached HEAD 780c363482) last updated 2016/10/06 11:32:54 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 242368e99b) last updated 2016/10/06 11:32:58 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 14887a9ea8) last updated 2016/10/06 11:32:58 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0 (detached HEAD 780c363482) last updated 2016/10/06 11:32:54 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 242368e99b) last updated 2016/10/06 11:32:58 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 14887a9ea8) last updated 2016/10/06 11:32:58 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.0.0.2 (stable-2.0.0.1 3b5d7400de) last updated 2016/10/06 11:11:52 (GMT -400)
  lib/ansible/modules/core: (detached HEAD ce6619bf5d) last updated 2016/10/06 11:11:55 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 29af26884e) last updated 2016/10/06 11:11:55 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.0.0.2 (stable-2.0.0.1 3b5d7400de) last updated 2016/10/06 11:11:52 (GMT -400)
  lib/ansible/modules/core: (detached HEAD ce6619bf5d) last updated 2016/10/06 11:11:55 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 29af26884e) last updated 2016/10/06 11:11:55 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">No change.</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<ul dir="auto">
<li>Ansible manager: Lubuntu 16.04.1</li>
<li>Ansible worker: Ubuntu Server 16.04.1</li>
<li>Python 2.7.12</li>
</ul>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Ansible 2.1.2.0, 2.1.1.0, and branches devel, stable-2.2, stable-2.1, and stable-2.0.0.1 do not resolve variable references in handler names.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<ul dir="auto">
<li>See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="152893515" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/15713" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/15713/hovercard" href="https://github.com/ansible/ansible/issues/15713">#15713</a>.</li>
</ul>
<h5 dir="auto">EXPECTED RESULTS</h5>
<ul dir="auto">
<li>See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="152893515" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/15713" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/15713/hovercard" href="https://github.com/ansible/ansible/issues/15713">#15713</a>.</li>
</ul>
<p dir="auto">Ansible 2.1.0.0 produces the correct result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible --version
ansible 2.1.0.0 (detached HEAD b599477242) last updated 2016/10/06 11:36:36 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 04a871d007) last updated 2016/10/06 11:36:38 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD b5fa2b3416) last updated 2016/10/06 11:36:38 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook --connection=local play.yaml
 [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 [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart someapp] **********************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;some bogus module call in handler someapp&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   
"><pre class="notranslate"><code class="notranslate">derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible --version
ansible 2.1.0.0 (detached HEAD b599477242) last updated 2016/10/06 11:36:36 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 04a871d007) last updated 2016/10/06 11:36:38 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD b5fa2b3416) last updated 2016/10/06 11:36:38 (GMT -400)
  config file = 
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook --connection=local play.yaml
 [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 [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart someapp] **********************************************
ok: [localhost] =&gt; {
    "msg": "some bogus module call in handler someapp"
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   

</code></pre></div>
<p dir="auto">Ansible 2.0.2.0 on branch stable-2.0 produces the correct result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible --version
ansible 2.0.2.0 (stable-2.0 26078418e9) last updated 2016/10/06 11:13:05 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 1e68326ea6) last updated 2016/10/06 11:13:07 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 4eb177e545) last updated 2016/10/06 11:13:07 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook --connection=local play.yaml
 [WARNING]: provided hosts list is empty, only localhost is available


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

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

TASK [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart someapp] **********************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;some bogus module call in handler someapp&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   
"><pre class="notranslate"><code class="notranslate">derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible --version
ansible 2.0.2.0 (stable-2.0 26078418e9) last updated 2016/10/06 11:13:05 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 1e68326ea6) last updated 2016/10/06 11:13:07 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 4eb177e545) last updated 2016/10/06 11:13:07 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
derek@derek-HP-EliteOne-800-G1-AiO:~$ ansible-playbook --connection=local play.yaml
 [WARNING]: provided hosts list is empty, only localhost is available


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

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

TASK [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart someapp] **********************************************
ok: [localhost] =&gt; {
    "msg": "some bogus module call in handler someapp"
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   

</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">Results for Ansible 2.1.2.0, 2.1.1.0, and branches devel, stable-2.2, stable-2.1, and stable-2.0.0.1:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" [WARNING]: provided hosts list is empty, only localhost is available


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

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

TASK [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart {{ appname }}] ****************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;some bogus module call in handler someapp&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   
"><pre class="notranslate"><code class="notranslate"> [WARNING]: provided hosts list is empty, only localhost is available


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

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

TASK [bogus task with notify for someapp] **************************************
changed: [localhost]

RUNNING HANDLER [restart {{ appname }}] ****************************************
ok: [localhost] =&gt; {
    "msg": "some bogus module call in handler someapp"
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0   

</code></pre></div>