Issue 1:
Hi,

ISSUE TYPE

Bug Report

COMPONENT NAME

include_role

ANSIBLE VERSION

ansible 2.2.1.0
config file = /home/stephane/.ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

Nothing special

OS / ENVIRONMENT

Ansible running from ArchLinux, managing an OpenBSD machine, but the problem is with any managed machine.

SUMMARY

When the include_role module is used within an handler, the calling role fails, before knowing if the handler will be called.

STEPS TO REPRODUCE

Create the simple following role:

calling-role/tasks/main.yml

---
- name: task with notify
debug: msg="test"

calling-role/handlers/main.yml

---
- name: handler
include_role: name=called-role

called-role can be any role, with at least on task.

I run this role with this playbook:

---
- hosts:
- all
roles:
- calling-role

EXPECTED RESULTS

I expect the playbook to run.

ACTUAL RESULTS

The playbook doesn't run, it fails immediately.

Using /home/stephane/.ansible.cfg as config file

PLAYBOOK: main.yml *************************************************************
1 plays in main.yml

PLAY [all] *********************************************************************
ERROR! Unexpected Exception: 'Task' object has no attribute 'listen'
the full traceback was:

Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 103, in <module>
exit_code = cli.run()
File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 159, in run
results = pbex.run()
File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 154, in run
result = self._tqm.run(play=play)
File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 248, in run
self._initialize_notified_handlers(new_play)
File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 143, in _initialize_notified_handlers
if handler.listen:
AttributeError: 'Task' object has no attribute 'listen'
zsh: exit 250 ansible-playbook main.yml -vvv

The problem still exists with the devel branch (216e2c8).

Let me know if I can be of any help concerning this issue!

Stéphane

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

ANSIBLE VERSION

ansible 2.1.2.0
config file =
configured module search path = Default w/o overrides

OS / ENVIRONMENT

Ubunty 16.04, created irtual environment with pip install ansible

SUMMARY

Error handling/displaying not working in loops properly

STEPS TO REPRODUCE

- name: Install packages
yum:
name: "{{ item }}"
state: present
with_items:
- non-existing-package

EXPECTED RESULTS

PLAY [test playbook] ***********************************************************

TASK [install packages] ********************************************************
failed: [test] (item=non-existing-package) => {"changed": false, "failed": true, "item": "non-existing-package", "msg": "No Package matching 'non-existing-package' found available, installed or updated", "rc": 0, results: []}

NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @test.retry

PLAY RECAP *********************************************************************
test : ok=0 changed=0 unreachable=0 failed=1

ACTUAL RESULTS

PLAY [test playbook] ***********************************************************

TASK [install packages] ********************************************************
ok: [test] => (item=[u'non-existing-package'])

NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @test.retry

PLAY RECAP *********************************************************************
test : ok=0 changed=0 unreachable=0 failed=1

I've dig a little bit into this issue, and I've found, that if a result key is exists in the returned dictionary (even if it's empty array), the display will be ok:

If I delete the the result from dict, It's working fine (res.pop('result', None) in yum.py

If I run the command directly (without loop), it displays it correctly