<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">yum</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.2.0"><pre class="notranslate"><code class="notranslate">ansible 2.1.2.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Running on Ubuntu 14.04<br>
Managing CentOS 7.2</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">The tasks outputs OK but actually failed. This happens only when using with_items.<br>
Because of the wrong output. In Big playbooks it's hard to find the error.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
  - name: Test yum install
    hosts: somehost
    tasks:
      - name: install package
        become: yes
        yum:
          state: present
          name: &quot;{{ item }}&quot;
        with_items:
          - bash
          - doesnotexist"><pre class="notranslate"><code class="notranslate">
---
  - name: Test yum install
    hosts: somehost
    tasks:
      - name: install package
        become: yes
        yum:
          state: present
          name: "{{ item }}"
        with_items:
          - bash
          - doesnotexist
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [install package] *********************************************************
fatal: [somehost]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;No Package matching 'doesnotexisthere' found available, installed or updated&quot;, &quot;rc&quot;: 0, &quot;results&quot;: []}"><pre class="notranslate"><code class="notranslate">TASK [install package] *********************************************************
fatal: [somehost]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "No Package matching 'doesnotexisthere' found available, installed or updated", "rc": 0, "results": []}
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [install package] *********************************************************
ok: [somehost] =&gt; (item=[u'bash', u'doesnotexist'])

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @/home/user/stuff/ansible/playbooks/test.retry

PLAY RECAP *********************************************************************
somehost              : ok=0    changed=0    unreachable=0    failed=1   
"><pre class="notranslate"><code class="notranslate">TASK [install package] *********************************************************
ok: [somehost] =&gt; (item=[u'bash', u'doesnotexist'])

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @/home/user/stuff/ansible/playbooks/test.retry

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

</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>