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

Unexpected Exception when using notify with an handler defined in another play by an imported role #44848

Closed
pilou- opened this issue Aug 29, 2018 · 1 comment · Fixed by #44852
Assignees
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.

Comments

@pilou-
Copy link
Contributor

pilou- commented Aug 29, 2018

SUMMARY

An exception occurs when a task tries to notify an handler from another play. This other play needs to use import_role in order to reproduce this error.

ERROR! Unexpected Exception, this is probably a bug: 'role1'
the full traceback was:

Traceback (most recent call last):
  File "ansible/bin/ansible-playbook", line 118, in <module>
    exit_code = cli.run()
  File "ansible/lib/ansible/cli/playbook.py", line 122, in run
    results = pbex.run()
  File "ansible/lib/ansible/executor/playbook_executor.py", line 156, in run
    result = self._tqm.run(play=play)
  File "ansible/lib/ansible/executor/task_queue_manager.py", line 291, in run
    play_return = strategy.run(iterator, play_context)
  File "ansible/lib/ansible/plugins/strategy/linear.py", line 267, in run
    results.extend(self._execute_meta(task, play_context, iterator, host))
  File "ansible/lib/ansible/plugins/strategy/__init__.py", line 1031, in _execute_meta
    self.run_handlers(iterator, play_context)
  File "/home/lilou/src/ansible/ansible.git/lib/ansible/plugins/strategy/__init__.py", line 885, in run_handlers
    result = self._do_handler_run(handler, handler_name, iterator=iterator, play_context=play_context)
  File "ansible/lib/ansible/plugins/strategy/__init__.py", line 928, in _do_handler_run
    host_results = self._wait_on_handler_results(iterator, handler, notified_hosts)
  File "ansible/lib/ansible/plugins/strategy/__init__.py", line 686, in _wait_on_handler_results
    results = self._process_pending_results(iterator)
  File "ansible/lib/ansible/plugins/strategy/__init__.py", line 117, in inner
    results = func(self, iterator, one_pass=one_pass, max_passes=max_passes)
  File "ansible/lib/ansible/plugins/strategy/__init__.py", line 656, in _process_pending_results
    for (entry, role_obj) in iteritems(iterator._play.ROLE_CACHE[original_task._role._role_name]):
KeyError: 'role1'
ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible 2.7.0.a1.post0 (devel c07ba82d3e) last updated 2018/08/29 18:24:02 (GMT +200)
CONFIGURATION

N/A

OS / ENVIRONMENT

Python 3.6

STEPS TO REPRODUCE
  • playbook:
- hosts: localhost
  gather_facts: yes
  tasks:
    - import_role:
        name: role1

- hosts: localhost
  gather_facts: yes
  tasks:
    - command: uname
      notify: test1
  • role:
# role1/tasks/main.yml
- command: uname
# role1/handlers/main.yml
- name: test1
  debug:
    msg: test1
EXPECTED RESULTS

ERROR! The requested handler 'test1' was not found in either the main handlers list nor in the listening handlers list

ACTUAL RESULTS

See backtrace in summary.

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. labels Aug 29, 2018
@sivel sivel self-assigned this Aug 29, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Aug 29, 2018
@sivel
Copy link
Member

sivel commented Aug 29, 2018

The above PR should resolve these issues.

@sivel sivel added the has_pr This issue has an associated PR. label Aug 29, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants