Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible 2.2.0.0: Variables in handler names not populated #19898

Closed
command-tab opened this issue Jan 4, 2017 · 2 comments · Fixed by #41837
Closed

Ansible 2.2.0.0: Variables in handler names not populated #19898

command-tab opened this issue Jan 4, 2017 · 2 comments · Fixed by #41837
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@command-tab
Copy link
Contributor

command-tab commented Jan 4, 2017

Issue Type: Bug Report, Regression from #15713

Component Name: handlers

Ansible Version: 2.2.0.0

Environment: OS X 10.11.6

Summary: Under Ansible 2.2.0.0, Jinja variables contained in a handler name are no longer populated. Under Ansible 1.9.x and 2.1.1.0, they were populated. Here's a quick example:

Steps To Reproduce:

  1. Write this content to playbook.yml:

    ---
    - 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 }}
  2. Run the playbook: ansible-playbook --connection=local playbook.yml

Expected Results: In the output of the playbook run, any mention of {{ appname }} should not appear, but replaced with someapp, per the given variables.

Actual Results:

  [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] => {
    "msg": "some bogus module call in handler someapp"
}

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

Note that in the RUNNING HANDLER 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 1.9.x and 2.1.1.0.

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report needs_triage Needs a first human triage before being processed. labels Jan 4, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jan 6, 2017
@lucafavatella
Copy link

I understand this is a duplicate of #17922

@ansibot ansibot added needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. and removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Mar 30, 2017
@command-tab
Copy link
Contributor Author

@ansibot Nope, it's right there in my original issue description: "Component Name: handlers"

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@ansible ansible locked and limited conversation to collaborators Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants