Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

yum

ANSIBLE VERSION

ansible 2.1.2.0

CONFIGURATION

OS / ENVIRONMENT

Running on Ubuntu 14.04

Managing CentOS 7.2

SUMMARY

The tasks outputs OK but actually failed. This happens only when using with_items.

Because of the wrong output. In Big playbooks it's hard to find the error.

STEPS TO REPRODUCE

---
- name: Test yum install
hosts: somehost
tasks:
- name: install package
become: yes
yum:
state: present
name: "{{ item }}"
with_items:
- bash
- doesnotexist

EXPECTED RESULTS

TASK [install package] *********************************************************
fatal: [somehost]: FAILED! => {"changed": false, "failed": true, "msg": "No Package matching 'doesnotexisthere' found available, installed or updated", "rc": 0, "results": []}

ACTUAL RESULTS

TASK [install package] *********************************************************
ok: [somehost] => (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

Issue 2:
I looked but couldn't see an obvious issue for this

ISSUE TYPE

Bug Report

ANSIBLE VERSION

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

CONFIGURATION

[defaults]
inventory = hosts
roles_path = roles
retry_files_enabled = False

OS / ENVIRONMENT

Docker container FROM: centos:6.8

SUMMARY

Using yum and with_items returns OK instead of FATAL in the task, followed by NO MORE HOSTS LEFT, when an item fails.

STEPS TO REPRODUCE

# 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 }}"

docker run -dt --name centos68 centos:6.8 /sbin/init
ansible-playbook -i 'centos68,' foo.yml -c docker -vvv

EXPECTED RESULTS

The task should output an obvious fatal message

fatal: [centos68]: FAILED! => {"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": []}

Note I get the fatal message if I remove the with_items.

ACTUAL RESULTS

I get an OK response followed by an initially confusing NO MORE HOSTS LEFT message

$ 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] *******************************************************************
<centos68> ESTABLISH DOCKER CONNECTION FOR USER: root
<centos68> EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783 `" && echo ansible-tmp-1467802796.84-176847019920783="` echo $HOME/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783 `" ) && sleep 0\'']
<centos68> PUT /var/folders/_j/pvqg__g512v5jgc3kl9vnlvd_6vfxx/T/tmpEkhN1i TO /root/.ansible/tmp/ansible-tmp-1467802796.84-176847019920783/setup
<centos68> 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/" > /dev/null 2>&1 && sleep 0\'']
ok: [centos68]

TASK [configure the packages] **************************************************
task path: /tmp/foo.yml:7
<centos68> ESTABLISH DOCKER CONNECTION FOR USER: root
<centos68> EXEC ['/usr/local/bin/docker', 'exec', '-i', 'centos68', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718 `" && echo ansible-tmp-1467802797.72-8724224930718="` echo $HOME/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718 `" ) && sleep 0\'']
<centos68> PUT /var/folders/_j/pvqg__g512v5jgc3kl9vnlvd_6vfxx/T/tmpytRzHJ TO /root/.ansible/tmp/ansible-tmp-1467802797.72-8724224930718/yum
<centos68> 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/" > /dev/null 2>&1 && sleep 0\'']
ok: [centos68] => (item={u'name': u'mongodb-server'}) => {"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