<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">RHEL 7</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When with_items is used on the yum module and it fails, the detailed information normally emitted during a task failure is missing.</p>
<p dir="auto">This is particularly confusing because the task does abort the run, or trigger <code class="notranslate">block/rescue</code> logic, but <em>is logged as success</em>.</p>
<p dir="auto">Note, if I modify the yum module's <code class="notranslate">module.fail_json</code> to include an <code class="notranslate">rc=</code> parameter, this fails correctly. It is my guess the ansible logic handling faliure logging or with_items munging is not checking the module's returncode and only evaluating the json object.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# on (or modify to have a remote target) a RHEL 7 machine
# as this needs to execute the yum module to demo
git clone https://gist.github.com/2cc7844d3994e98bdb8b5410212d268b.git"><pre class="notranslate"><code class="notranslate"># on (or modify to have a remote target) a RHEL 7 machine
# as this needs to execute the yum module to demo
git clone https://gist.github.com/2cc7844d3994e98bdb8b5410212d268b.git
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i localhost, with_items-doesnt-show-as-failed.yaml"><pre class="notranslate"><code class="notranslate">ansible-playbook -i localhost, with_items-doesnt-show-as-failed.yaml
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto"><strong>Normal output</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [localhost]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;No Package matching 'foobar' found available, installed or updated&quot;, &quot;rc&quot;: 0, &quot;results&quot;: [&quot;ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed&quot;]}"><pre class="notranslate"><code class="notranslate">fatal: [localhost]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "No Package matching 'foobar' found available, installed or updated", "rc": 0, "results": ["ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed"]}
</code></pre></div>
<p dir="auto"><strong>Snipped debugging details</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{&quot;changed&quot;: false, &quot;results&quot;: [&quot;ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed&quot;], &quot;failed&quot;: true, &quot;rc&quot;: 0, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;name&quot;: [&quot;ansible&quot;, &quot;foobar&quot;], &quot;list&quot;: null, &quot;disable_gpg_check&quot;: false, &quot;conf_file&quot;: null, &quot;install_repoquery&quot;: true, &quot;state&quot;: &quot;installed&quot;, &quot;disablerepo&quot;: null, &quot;update_cache&quot;: false, &quot;enablerepo&quot;: null, &quot;exclude&quot;: null, &quot;validate_certs&quot;: true}}, &quot;msg&quot;: &quot;No Package matching 'foobar' found available, installed or updated&quot;}
, stderr=
 38409 1468349672.93083: done with _execute_module (yum, {'_ansible_version': '2.1.1.0', '_ansible_selinux_special_fs': ['fuse', 'nfs', 'vboxsf', 'ramfs'], u'name': u'ansible,foobar', '_ansible_verbosity': 5, '_ansible_syslog_facility': 'LOG_USER', '_ansible_diff': False, '_ansible_debug': True, '_ansible_check_mode': False, '_ansible_no_log': False})
 38409 1468349672.93096: handler run complete
 38409 1468349672.93114: attempt loop complete, returning result
 38409 1468349672.93119: _execute() done
 38409 1468349672.93123: dumping result to json
 38409 1468349672.93137: done dumping result, returning
 38409 1468349672.93149: done running TaskExecutor() for localhost/TASK: yum
 38409 1468349672.93154: sending task result
 38409 1468349672.93199: done sending task result
 38409 1468349672.93337: WORKER PROCESS EXITING
 38353 1468349672.93346: worker 0 has data to read
 38353 1468349672.93417: got a result from worker 0: &lt;ansible.executor.task_result.TaskResult object at 0x22f3f90&gt;
#### This result object is correctly identified as a failure.
 38353 1468349672.93430: sending result: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x22f3f90&gt;']
 38353 1468349672.93436: done sending result
 38348 1468349672.93694: got result from result worker: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x263e950&gt;']
 38348 1468349672.93702: marking localhost as failed
 38348 1468349672.93709: marking host localhost failed, current state: HOST STATE: block=3, task=1, rescue=0, always=0, role=None, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349672.93714: ^ failed state is now: HOST STATE: block=3, task=1, rescue=0, always=0, role=None, run_state=ITERATING_RESCUE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349672.93718: getting the next task for host localhost
 38348 1468349672.93722: done getting next task for host localhost
 38348 1468349672.93726:  ^ task is: TASK: Installing multiple packages (csv) dies OK
 38348 1468349672.93730:  ^ state is: HOST STATE: block=3, task=1, rescue=1, always=0, role=None, run_state=ITERATING_RESCUE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
fatal: [localhost]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;conf_file&quot;: null, &quot;disable_gpg_check&quot;: false, &quot;disablerepo&quot;: null, &quot;enablerepo&quot;: null, &quot;exclude&quot;: null, &quot;install_repoquery&quot;: true, &quot;list&quot;: null, &quot;name&quot;: [&quot;ansible&quot;, &quot;foobar&quot;], &quot;state&quot;: &quot;installed&quot;, &quot;update_cache&quot;: false, &quot;validate_certs&quot;: true}, &quot;module_name&quot;: &quot;yum&quot;}, &quot;msg&quot;: &quot;No Package matching 'foobar' found available, installed or updated&quot;, &quot;rc&quot;: 0, &quot;results&quot;: [&quot;ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed&quot;]}
 38348 1468349672.93824: no more pending results, returning what we have
 38348 1468349672.93831: results queue empty
 38348 1468349672.93833: checking for any_errors_fatal
 38348 1468349672.93839: done checking for any_errors_fatal
 38348 1468349672.93842: checking for max_fail_percentage
 38348 1468349672.93844: done checking for max_fail_percentage
 38348 1468349672.93846: getting the remaining hosts for this loop
 38348 1468349672.93851: done getting the remaining hosts for this loop
 38348 1468349672.93870: building list of next tasks for hosts
 38348 1468349672.93874: getting the next task for host localhost"><pre class="notranslate"><code class="notranslate">{"changed": false, "results": ["ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed"], "failed": true, "rc": 0, "invocation": {"module_args": {"name": ["ansible", "foobar"], "list": null, "disable_gpg_check": false, "conf_file": null, "install_repoquery": true, "state": "installed", "disablerepo": null, "update_cache": false, "enablerepo": null, "exclude": null, "validate_certs": true}}, "msg": "No Package matching 'foobar' found available, installed or updated"}
, stderr=
 38409 1468349672.93083: done with _execute_module (yum, {'_ansible_version': '2.1.1.0', '_ansible_selinux_special_fs': ['fuse', 'nfs', 'vboxsf', 'ramfs'], u'name': u'ansible,foobar', '_ansible_verbosity': 5, '_ansible_syslog_facility': 'LOG_USER', '_ansible_diff': False, '_ansible_debug': True, '_ansible_check_mode': False, '_ansible_no_log': False})
 38409 1468349672.93096: handler run complete
 38409 1468349672.93114: attempt loop complete, returning result
 38409 1468349672.93119: _execute() done
 38409 1468349672.93123: dumping result to json
 38409 1468349672.93137: done dumping result, returning
 38409 1468349672.93149: done running TaskExecutor() for localhost/TASK: yum
 38409 1468349672.93154: sending task result
 38409 1468349672.93199: done sending task result
 38409 1468349672.93337: WORKER PROCESS EXITING
 38353 1468349672.93346: worker 0 has data to read
 38353 1468349672.93417: got a result from worker 0: &lt;ansible.executor.task_result.TaskResult object at 0x22f3f90&gt;
#### This result object is correctly identified as a failure.
 38353 1468349672.93430: sending result: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x22f3f90&gt;']
 38353 1468349672.93436: done sending result
 38348 1468349672.93694: got result from result worker: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x263e950&gt;']
 38348 1468349672.93702: marking localhost as failed
 38348 1468349672.93709: marking host localhost failed, current state: HOST STATE: block=3, task=1, rescue=0, always=0, role=None, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349672.93714: ^ failed state is now: HOST STATE: block=3, task=1, rescue=0, always=0, role=None, run_state=ITERATING_RESCUE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349672.93718: getting the next task for host localhost
 38348 1468349672.93722: done getting next task for host localhost
 38348 1468349672.93726:  ^ task is: TASK: Installing multiple packages (csv) dies OK
 38348 1468349672.93730:  ^ state is: HOST STATE: block=3, task=1, rescue=1, always=0, role=None, run_state=ITERATING_RESCUE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
fatal: [localhost]: FAILED! =&gt; {"changed": false, "failed": true, "invocation": {"module_args": {"conf_file": null, "disable_gpg_check": false, "disablerepo": null, "enablerepo": null, "exclude": null, "install_repoquery": true, "list": null, "name": ["ansible", "foobar"], "state": "installed", "update_cache": false, "validate_certs": true}, "module_name": "yum"}, "msg": "No Package matching 'foobar' found available, installed or updated", "rc": 0, "results": ["ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed"]}
 38348 1468349672.93824: no more pending results, returning what we have
 38348 1468349672.93831: results queue empty
 38348 1468349672.93833: checking for any_errors_fatal
 38348 1468349672.93839: done checking for any_errors_fatal
 38348 1468349672.93842: checking for max_fail_percentage
 38348 1468349672.93844: done checking for max_fail_percentage
 38348 1468349672.93846: getting the remaining hosts for this loop
 38348 1468349672.93851: done getting the remaining hosts for this loop
 38348 1468349672.93870: building list of next tasks for hosts
 38348 1468349672.93874: getting the next task for host localhost
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">Instead I see the following and then an immediate abort.</p>
<p dir="auto"><strong>Normal output</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ok: [localhost] =&gt; (item=[u'ansible', u'foobar'])"><pre class="notranslate"><code class="notranslate">ok: [localhost] =&gt; (item=[u'ansible', u'foobar'])
</code></pre></div>
<p dir="auto"><strong>Snipped debugging details</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{&quot;changed&quot;: false, &quot;results&quot;: [&quot;ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed&quot;], &quot;failed&quot;: true, &quot;rc&quot;: 0, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;name&quot;: [&quot;ansible&quot;, &quot;foobar&quot;], &quot;list&quot;: null, &quot;disable_gpg_check&quot;: false, &quot;conf_file&quot;: null, &quot;install_repoquery&quot;: true, &quot;state&quot;: &quot;installed&quot;, &quot;disablerepo&quot;: null, &quot;update_cache&quot;: false, &quot;enablerepo&quot;: null, &quot;exclude&quot;: null, &quot;validate_certs&quot;: true}}, &quot;msg&quot;: &quot;No Package matching 'foobar' found available, installed or updated&quot;}
, stderr=
 38448 1468349674.12175: done with _execute_module (yum, {'_ansible_version': '2.1.1.0', '_ansible_selinux_special_fs': ['fuse', 'nfs', 'vboxsf', 'ramfs'], 'name': [u'ansible', u'foobar'], '_ansible_verbosity': 5, '_ansible_syslog_facility': 'LOG_USER', u'state': u'installed', '_ansible_diff': False, '_ansible_debug': True, '_ansible_check_mode': False, '_ansible_no_log': False})
 38448 1468349674.12186: handler run complete
 38448 1468349674.12200: attempt loop complete, returning result
 38448 1468349674.12248: dumping result to json
 38448 1468349674.12260: done dumping result, returning
 38448 1468349674.12274: done running TaskExecutor() for localhost/TASK: yum
 38448 1468349674.12281: sending task result
 38353 1468349674.12396: worker 0 has data to read
 38353 1468349674.12463: got a result from worker 0: &lt;ansible.executor.task_result.TaskResult object at 0x22f0410&gt;
#### This result object should be a failure, not ok.
 38353 1468349674.12473: sending result: [u'v2_runner_item_on_ok', u'&lt;ansible.executor.task_result.TaskResult object at 0x22f0410&gt;']
 38353 1468349674.12479: done sending result
 38448 1468349674.12486: done sending task result
 38448 1468349674.12493: WORKER PROCESS EXITING
 38348 1468349674.12615: got result from result worker: [u'v2_runner_item_on_ok', u'&lt;ansible.executor.task_result.TaskResult object at 0x264b150&gt;']
ok: [localhost] =&gt; (item=[u'ansible', u'foobar'])
 38353 1468349674.12668: worker 0 has data to read
 38353 1468349674.12723: got a result from worker 0: &lt;ansible.executor.task_result.TaskResult object at 0x22f3f50&gt;
 38353 1468349674.12732: sending result: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x22f3f50&gt;']
 38353 1468349674.12736: done sending result
 38348 1468349674.12841: got result from result worker: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x2649e90&gt;']
 38348 1468349674.12849: marking localhost as failed
 38348 1468349674.12857: marking host localhost failed, current state: HOST STATE: block=4, task=1, rescue=0, always=0, role=None, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349674.12862: ^ failed state is now: HOST STATE: block=4, task=1, rescue=0, always=0, role=None, run_state=ITERATING_RESCUE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349674.12866: getting the next task for host localhost"><pre class="notranslate"><code class="notranslate">{"changed": false, "results": ["ansible-2.1.1.0-0.1.rc1.el7.centos.noarch providing ansible is already installed"], "failed": true, "rc": 0, "invocation": {"module_args": {"name": ["ansible", "foobar"], "list": null, "disable_gpg_check": false, "conf_file": null, "install_repoquery": true, "state": "installed", "disablerepo": null, "update_cache": false, "enablerepo": null, "exclude": null, "validate_certs": true}}, "msg": "No Package matching 'foobar' found available, installed or updated"}
, stderr=
 38448 1468349674.12175: done with _execute_module (yum, {'_ansible_version': '2.1.1.0', '_ansible_selinux_special_fs': ['fuse', 'nfs', 'vboxsf', 'ramfs'], 'name': [u'ansible', u'foobar'], '_ansible_verbosity': 5, '_ansible_syslog_facility': 'LOG_USER', u'state': u'installed', '_ansible_diff': False, '_ansible_debug': True, '_ansible_check_mode': False, '_ansible_no_log': False})
 38448 1468349674.12186: handler run complete
 38448 1468349674.12200: attempt loop complete, returning result
 38448 1468349674.12248: dumping result to json
 38448 1468349674.12260: done dumping result, returning
 38448 1468349674.12274: done running TaskExecutor() for localhost/TASK: yum
 38448 1468349674.12281: sending task result
 38353 1468349674.12396: worker 0 has data to read
 38353 1468349674.12463: got a result from worker 0: &lt;ansible.executor.task_result.TaskResult object at 0x22f0410&gt;
#### This result object should be a failure, not ok.
 38353 1468349674.12473: sending result: [u'v2_runner_item_on_ok', u'&lt;ansible.executor.task_result.TaskResult object at 0x22f0410&gt;']
 38353 1468349674.12479: done sending result
 38448 1468349674.12486: done sending task result
 38448 1468349674.12493: WORKER PROCESS EXITING
 38348 1468349674.12615: got result from result worker: [u'v2_runner_item_on_ok', u'&lt;ansible.executor.task_result.TaskResult object at 0x264b150&gt;']
ok: [localhost] =&gt; (item=[u'ansible', u'foobar'])
 38353 1468349674.12668: worker 0 has data to read
 38353 1468349674.12723: got a result from worker 0: &lt;ansible.executor.task_result.TaskResult object at 0x22f3f50&gt;
 38353 1468349674.12732: sending result: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x22f3f50&gt;']
 38353 1468349674.12736: done sending result
 38348 1468349674.12841: got result from result worker: [u'host_task_failed', u'&lt;ansible.executor.task_result.TaskResult object at 0x2649e90&gt;']
 38348 1468349674.12849: marking localhost as failed
 38348 1468349674.12857: marking host localhost failed, current state: HOST STATE: block=4, task=1, rescue=0, always=0, role=None, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349674.12862: ^ failed state is now: HOST STATE: block=4, task=1, rescue=0, always=0, role=None, run_state=ITERATING_RESCUE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? None, rescue child state? None, always child state? None, did start at task? False
 38348 1468349674.12866: getting the next task for host localhost
</code></pre></div>
<p dir="auto">I looked but couldn't see an obvious issue for this</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook 2.1.0.0
  config file = /Users/g.lynch/git/tos/ansible_pulp/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible-playbook 2.1.0.0
  config file = /Users/g.lynch/git/tos/ansible_pulp/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[defaults]
inventory = hosts
roles_path = roles
retry_files_enabled = False"><pre class="notranslate"><code class="notranslate">[defaults]
inventory = hosts
roles_path = roles
retry_files_enabled = False
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Docker container FROM: centos:6.8</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Using yum and with_items returns OK instead of FATAL in the task, followed by NO MORE HOSTS LEFT, when an item fails.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# foo.yml

---
- hosts: all
  vars:
    mongodb_packages:
      - name: mongodb-server
  tasks:
    - name: configure the packages
      yum:
        name: &quot;{{ item.name }}&quot;
        state: &quot;{{ item.state|default('present') }}&quot;
      with_items: &quot;{{ mongodb_packages }}&quot;"><pre class="notranslate"><code class="notranslate"># foo.yml

---
- hosts: all
  vars:
    mongodb_packages:
      - name: mongodb-server
  tasks:
    - name: configure the packages
      yum:
        name: "{{ item.name }}"
        state: "{{ item.state|default('present') }}"
      with_items: "{{ mongodb_packages }}"
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker run -dt --name centos68 centos:6.8 /sbin/init
ansible-playbook -i 'centos68,' foo.yml -c docker -vvv"><pre class="notranslate"><code class="notranslate">docker run -dt --name centos68 centos:6.8 /sbin/init
ansible-playbook -i 'centos68,' foo.yml -c docker -vvv
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">The task should output an obvious fatal message</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [centos68]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;conf_file&quot;: null, &quot;disable_gpg_check&quot;: false, &quot;disablerepo&quot;: null, &quot;enablerepo&quot;: null, &quot;exclude&quot;: null, &quot;install_repoquery&quot;: true, &quot;list&quot;: null, &quot;name&quot;: [&quot;mongodb-server&quot;], &quot;state&quot;: &quot;present&quot;, &quot;update_cache&quot;: false, &quot;validate_certs&quot;: true}, &quot;module_name&quot;: &quot;yum&quot;}, &quot;msg&quot;: &quot;No Package matching 'mongodb-server' found available, installed or updated&quot;, &quot;rc&quot;: 0, &quot;results&quot;: []}"><pre class="notranslate"><code class="notranslate">fatal: [centos68]: FAILED! =&gt; {"changed": false, "failed": true, "invocation": {"module_args": {"conf_file": null, "disable_gpg_check": false, "disablerepo": null, "enablerepo": null, "exclude": null, "install_repoquery": true, "list": null, "name": ["mongodb-server"], "state": "present", "update_cache": false, "validate_certs": true}, "module_name": "yum"}, "msg": "No Package matching 'mongodb-server' found available, installed or updated", "rc": 0, "results": []}
</code></pre></div>
<p dir="auto">Note I get the fatal message if I remove the with_items.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">I get an OK response followed by an initially confusing NO MORE HOSTS LEFT message</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -i 'centos68,' foo.yml -c docker -vvv
Using /tmp/ansible.cfg as config file

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

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
&lt;centos68&gt; ESTABLISH DOCKER CONNECTION FOR USER: root
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783 `&quot; &amp;&amp; echo ansible-tmp-1467802796.84-176847019920783=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783 `&quot; ) &amp;&amp; sleep 0\'']
&lt;centos68&gt; PUT /var/folders/_j/pvqg__g512v5jgc3kl9vnlvd_6vfxx/T/tmpEkhN1i TO /root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/setup
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/setup; rm -rf &quot;/root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0\'']
ok: [centos68]

TASK [configure the packages] **************************************************
task path: /tmp/foo.yml:7
&lt;centos68&gt; ESTABLISH DOCKER CONNECTION FOR USER: root
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718 `&quot; &amp;&amp; echo ansible-tmp-1467802797.72-8724224930718=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718 `&quot; ) &amp;&amp; sleep 0\'']
&lt;centos68&gt; PUT /var/folders/_j/pvqg__g512v5jgc3kl9vnlvd_6vfxx/T/tmpytRzHJ TO /root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/yum
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/yum; rm -rf &quot;/root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0\'']
ok: [centos68] =&gt; (item={u'name': u'mongodb-server'}) =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;conf_file&quot;: null, &quot;disable_gpg_check&quot;: false, &quot;disablerepo&quot;: null, &quot;enablerepo&quot;: null, &quot;exclude&quot;: null, &quot;install_repoquery&quot;: true, &quot;list&quot;: null, &quot;name&quot;: [&quot;mongodb-server&quot;], &quot;state&quot;: &quot;present&quot;, &quot;update_cache&quot;: false, &quot;validate_certs&quot;: true}, &quot;module_name&quot;: &quot;yum&quot;}, &quot;item&quot;: {&quot;name&quot;: &quot;mongodb-server&quot;}, &quot;msg&quot;: &quot;No Package matching 'mongodb-server' found available, installed or updated&quot;, &quot;rc&quot;: 0, &quot;results&quot;: []}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
centos68                   : ok=1    changed=0    unreachable=0    failed=1"><pre class="notranslate"><code class="notranslate">$ ansible-playbook -i 'centos68,' foo.yml -c docker -vvv
Using /tmp/ansible.cfg as config file

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

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
&lt;centos68&gt; ESTABLISH DOCKER CONNECTION FOR USER: root
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783 `" &amp;&amp; echo ansible-tmp-1467802796.84-176847019920783="` echo $HOME/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783 `" ) &amp;&amp; sleep 0\'']
&lt;centos68&gt; PUT /var/folders/_j/pvqg__g512v5jgc3kl9vnlvd_6vfxx/T/tmpEkhN1i TO /root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/setup
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/setup; rm -rf "/root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0\'']
ok: [centos68]

TASK [configure the packages] **************************************************
task path: /tmp/foo.yml:7
&lt;centos68&gt; ESTABLISH DOCKER CONNECTION FOR USER: root
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718 `" &amp;&amp; echo ansible-tmp-1467802797.72-8724224930718="` echo $HOME/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718 `" ) &amp;&amp; sleep 0\'']
&lt;centos68&gt; PUT /var/folders/_j/pvqg__g512v5jgc3kl9vnlvd_6vfxx/T/tmpytRzHJ TO /root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/yum
&lt;centos68&gt; EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/yum; rm -rf "/root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0\'']
ok: [centos68] =&gt; (item={u'name': u'mongodb-server'}) =&gt; {"changed": false, "failed": true, "invocation": {"module_args": {"conf_file": null, "disable_gpg_check": false, "disablerepo": null, "enablerepo": null, "exclude": null, "install_repoquery": true, "list": null, "name": ["mongodb-server"], "state": "present", "update_cache": false, "validate_certs": true}, "module_name": "yum"}, "item": {"name": "mongodb-server"}, "msg": "No Package matching 'mongodb-server' found available, installed or updated", "rc": 0, "results": []}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
centos68                   : ok=1    changed=0    unreachable=0    failed=1
</code></pre></div>