Issue 1:
Issue Type:

Bug Report

Ansible Version:

ansible 1.6.6

Environment:

Mac OSX 10.9.3

Summary:

When firing a handler from a task with notify: limited to specific hosts via a when: clause, play_hosts in the handler reflects only the hosts that triggered a notify:

Steps To Reproduce:

runn playbook and inventory from https://drive.google.com/file/d/0B7vhBal_UqRNMGdwTkNxSzZmRTg/edit?usp=sharing

see example output below.

Expected Results:

play_hosts should reflect the host in the play, regardless of limit

Actual Results:

[nhruby@badhorse ../ansible-handler-play-hosts]$ ansible-playbook -i test.inv test.yml

PLAY [test handler from role] *************************************************

GATHERING FACTS ***************************************************************
ok: [test2]
ok: [test1]

TASK: [testhandler | this is a test role task for all] ************************
changed: [test1] => {
"changed": true,
"play_hosts": [
"test1",
"test2"
]
}
changed: [test2] => {
"changed": true,
"play_hosts": [
"test1",
"test2"
]
}

TASK: [testhandler | this is a test role task limited and notifies] ***********
skipping: [test2]
changed: [test1] => {
"changed": true,
"play_hosts": [
"test1",
"test2"
]
}

NOTIFIED: [testhandler | this is a test role handler] *************************
ok: [test1] => {
"play_hosts": [
"test1"
]
}

PLAY RECAP ********************************************************************
test1 : ok=4 changed=2 unreachable=0 failed=0
test2 : ok=2 changed=1 unreachable=0 failed=0

[nhruby@badhorse ../ansible-handler-play-hosts]$

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

ios_command

ANSIBLE VERSION

ansible --version
2.3.0 (commit 20160706.246e32a)
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

inventory = ./hosts

gathering = explicit

roles_path = /home/actionmystique/Program-Files/Ubuntu/Ansible/git-Ansible/Roles/roles

private_role_vars = yes

log_path = /var/log/ansible.log

fact_caching = redis

fact_caching_timeout = 86400

retry_files_enabled = False

OS / ENVIRONMENT

Local host: Ubuntu 16.10 4.8

Target nodes: IOSv 15.6(2)T

IOSv_L2 15.2(4.0.55)E

SUMMARY

This exception happens with different types of targets (IOSv & IOSv_L2), although there is no issue running ios_facts with the same targets.

STEPS TO REPRODUCE

With config=running-config or config=startup-config

- name: Fetching config from the remote node
ios_command:
provider: "{{ connections.ssh }}"
commands:
- "show {{ config }}"
register: configuration

EXPECTED RESULTS

Successful "show running-config" or "show startup-config"

ACTUAL RESULTS

TASK [ios_pull_config : Fetching config from the remote node] ***************************************************************************************************************
task path: /home/actionmystique/Program-Files/Ubuntu/Ansible/Roles/roles/ios_pull_config/tasks/main.yml:76
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/network/ios/ios_command.py
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/network/ios/ios_command.py
<172.21.100.210> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.210> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534 `" && echo ansible-tmp-1479307602.12-88135957770534="` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534 `" ) && sleep 0'
<172.21.100.220> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.220> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858 `" && echo ansible-tmp-1479307602.13-213866714018858="` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858 `" ) && sleep 0'
<172.21.100.220> PUT /tmp/tmpT5ggUh TO /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ios_command.py
<172.21.100.210> PUT /tmp/tmpqxKZuu TO /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ios_command.py
<172.21.100.220> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ios_command.py && sleep 0'
<172.21.100.210> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ios_command.py && sleep 0'
<172.21.100.220> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ios_command.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/" > /dev/null 2>&1 && sleep 0'
<172.21.100.210> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ios_command.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 126, in run
res = self._execute()
File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 502, in _execute
result = self._handler.run(task_vars=variables)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/normal.py", line 33, in run
results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))
File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 662, in _execute_module
data['stdout_lines'] = data.get('stdout', u'').splitlines()
AttributeError: 'list' object has no attribute 'splitlines'

fatal: [IOSv_L2_10]: FAILED! => {
"failed": true,
"msg": "Unexpected failure during module execution.",
"stdout": ""
}

Despite being able to retrieve its facts with ios_facts:

name: Fetching facts from the remote node

ios_facts:

gather_subset: all

provider: "{{ connections.ssh }}"

register: facts

TASK [ios_pull_facts : Fetching facts from the remote node] *****************************************************************************************************************
ok: [IOSv_L2_10] => {"ansible_facts": {"ansible_net_all_ipv4_addresses": ["172.21.100.210"], "ansible_net_all_ipv6_addresses": [], "ansible_net_config": "Building configuration...\n\nCurrent configuration : 7126 bytes\n!\n! Last configuration change at 14:42:21 UTC Wed Nov 16 2016 by admin\n!\nversion 15.2\nservice timestamps debug datetime msec\nservice timestamps log datetime msec\nservice password-encryption\nservice compress-config\n!\nhostname IOSv_L2_10\n!\nboot-start-marker\nboot-end-marker\n!\n!\nenable se
...nged": false, "failed_commands": []}