<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.6.6</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Mac OSX 10.9.3</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">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:</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">runn playbook and inventory from <a href="https://drive.google.com/file/d/0B7vhBal_UqRNMGdwTkNxSzZmRTg/edit?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B7vhBal_UqRNMGdwTkNxSzZmRTg/edit?usp=sharing</a></p>
<p dir="auto">see example output below.</p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">play_hosts should reflect the host in the play, regardless of limit</p>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[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] =&gt; {
    &quot;changed&quot;: true,
    &quot;play_hosts&quot;: [
        &quot;test1&quot;,
        &quot;test2&quot;
    ]
}
changed: [test2] =&gt; {
    &quot;changed&quot;: true,
    &quot;play_hosts&quot;: [
        &quot;test1&quot;,
        &quot;test2&quot;
    ]
}

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

NOTIFIED: [testhandler | this is a test role handler] *************************
ok: [test1] =&gt; {
    &quot;play_hosts&quot;: [
        &quot;test1&quot;
    ]
}

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]$"><pre class="notranslate"><code class="notranslate">[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] =&gt; {
    "changed": true,
    "play_hosts": [
        "test1",
        "test2"
    ]
}
changed: [test2] =&gt; {
    "changed": true,
    "play_hosts": [
        "test1",
        "test2"
    ]
}

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

NOTIFIED: [testhandler | this is a test role handler] *************************
ok: [test1] =&gt; {
    "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]$
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">ios_command</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible --version
2.3.0 (commit 20160706.246e32a)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible --version
2.3.0 (commit 20160706.246e32a)
  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">inventory   = ./hosts<br>
gathering = explicit<br>
roles_path = /home/actionmystique/Program-Files/Ubuntu/Ansible/git-Ansible/Roles/roles<br>
private_role_vars = yes<br>
log_path = /var/log/ansible.log<br>
fact_caching = redis<br>
fact_caching_timeout = 86400<br>
retry_files_enabled = False</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<ul dir="auto">
<li><strong>Local host</strong>: Ubuntu 16.10 4.8</li>
<li><strong>Target nodes</strong>: IOSv       15.6(2)T<br>
IOSv_L2 15.2(4.0.55)E</li>
</ul>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">This exception happens with different types of targets (IOSv &amp; IOSv_L2), although there is no issue running ios_facts with the same targets.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">With config=running-config or config=startup-config</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Fetching config from the remote node
  ios_command:
        provider: &quot;{{ connections.ssh }}&quot;
        commands:
          - &quot;show {{ config }}&quot;
  register: configuration"><pre class="notranslate"><code class="notranslate">- name: Fetching config from the remote node
  ios_command:
        provider: "{{ connections.ssh }}"
        commands:
          - "show {{ config }}"
  register: configuration
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Successful "show running-config" or "show startup-config"</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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
&lt;172.21.100.210&gt; ESTABLISH LOCAL CONNECTION FOR USER: root
&lt;172.21.100.210&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534 `&quot; &amp;&amp; echo ansible-tmp-1479307602.12-88135957770534=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534 `&quot; ) &amp;&amp; sleep 0'
&lt;172.21.100.220&gt; ESTABLISH LOCAL CONNECTION FOR USER: root
&lt;172.21.100.220&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858 `&quot; &amp;&amp; echo ansible-tmp-1479307602.13-213866714018858=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858 `&quot; ) &amp;&amp; sleep 0'
&lt;172.21.100.220&gt; PUT /tmp/tmpT5ggUh TO /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ios_command.py
&lt;172.21.100.210&gt; PUT /tmp/tmpqxKZuu TO /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ios_command.py
&lt;172.21.100.220&gt; 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 &amp;&amp; sleep 0'
&lt;172.21.100.210&gt; 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 &amp;&amp; sleep 0'
&lt;172.21.100.220&gt; EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ios_command.py; rm -rf &quot;/root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
&lt;172.21.100.210&gt; EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ios_command.py; rm -rf &quot;/root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File &quot;/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py&quot;, line 126, in run
    res = self._execute()
  File &quot;/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py&quot;, line 502, in _execute
    result = self._handler.run(task_vars=variables)
  File &quot;/usr/lib/python2.7/dist-packages/ansible/plugins/action/normal.py&quot;, line 33, in run
    results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))
  File &quot;/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py&quot;, 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! =&gt; {
    &quot;failed&quot;: true, 
    &quot;msg&quot;: &quot;Unexpected failure during module execution.&quot;, 
    &quot;stdout&quot;: &quot;&quot;
}"><pre class="notranslate"><code class="notranslate">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
&lt;172.21.100.210&gt; ESTABLISH LOCAL CONNECTION FOR USER: root
&lt;172.21.100.210&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534 `" &amp;&amp; echo ansible-tmp-1479307602.12-88135957770534="` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534 `" ) &amp;&amp; sleep 0'
&lt;172.21.100.220&gt; ESTABLISH LOCAL CONNECTION FOR USER: root
&lt;172.21.100.220&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858 `" &amp;&amp; echo ansible-tmp-1479307602.13-213866714018858="` echo $HOME/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858 `" ) &amp;&amp; sleep 0'
&lt;172.21.100.220&gt; PUT /tmp/tmpT5ggUh TO /root/.ansible/tmp/ansible-tmp-1479307602.13-213866714018858/ios_command.py
&lt;172.21.100.210&gt; PUT /tmp/tmpqxKZuu TO /root/.ansible/tmp/ansible-tmp-1479307602.12-88135957770534/ios_command.py
&lt;172.21.100.220&gt; 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 &amp;&amp; sleep 0'
&lt;172.21.100.210&gt; 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 &amp;&amp; sleep 0'
&lt;172.21.100.220&gt; 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/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
&lt;172.21.100.210&gt; 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/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; 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! =&gt; {
    "failed": true, 
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}
</code></pre></div>
<p dir="auto">Despite being able to retrieve its facts with ios_facts:</p>
<ul dir="auto">
<li>name: Fetching facts from the remote node<br>
ios_facts:<br>
gather_subset: all<br>
provider: "{{ connections.ssh }}"<br>
register: facts</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [ios_pull_facts : Fetching facts from the remote node] *****************************************************************************************************************
ok: [IOSv_L2_10] =&gt; {&quot;ansible_facts&quot;: {&quot;ansible_net_all_ipv4_addresses&quot;: [&quot;172.21.100.210&quot;], &quot;ansible_net_all_ipv6_addresses&quot;: [], &quot;ansible_net_config&quot;: &quot;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&quot;: false, &quot;failed_commands&quot;: []}"><pre class="notranslate"><code class="notranslate">TASK [ios_pull_facts : Fetching facts from the remote node] *****************************************************************************************************************
ok: [IOSv_L2_10] =&gt; {"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": []}
</code></pre></div>