Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

ansible-playbook

ANSIBLE VERSION

ansible 2.4.2.0
config file = /ansible/ansible.cfg
configured module search path = ['/ansible/library', '/usr/share/ansible']
ansible python module location = /usr/local/lib/python3.5/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170118]

CONFIGURATION

OS / ENVIRONMENT

I'm using docker as an environment host in Windows 10. My docker version is:

Version 17.09.0-ce-win33 (13620)
Channel: stable
8c56a3b

The Docker File I use to run the environment:

FROM debian:stable-slim

RUN apt-get update && \
apt-get install -y \
cowsay \
mysql-client \
openssh-client \
rsync \
python3 \
python3-pip \
python3-mysqldb

RUN pip3 install \
ansible \
boto \
boto3 \
awscli \
colorama \
jmespath \
passlib

VOLUME "/ansible"
VOLUME "/root/.aws"
WORKDIR "/ansible"

I then build and then start it up with something like:

docker run -it --rm --mount type=bind,source=C:\git\my_ansible,target=/ansible --mount source=C:\Users\Me\.aws,target=/root/.aws ansible

$root@....> ansible-playbook _test.yaml

I am also using the "stock" ec2.py dynamic inventory.

SUMMARY

Occasionally simple playbooks explode with a bunch of errors at the end of an invocation

STEPS TO REPRODUCE

This is the playbook that "sometimes" barfs (run it a couple of times)

- hosts: localhost
become: no
tasks:
- debug: msg="{{'a' if what is defined else 'b'}}"

root@2c92f553e7c7:/ansible# ansible-playbook _test.yml -vvvv
ansible-playbook 2.4.2.0
config file = /ansible/ansible.cfg
configured module search path = ['/ansible/library', '/usr/share/ansible']
ansible python module location = /usr/local/lib/python3.5/dist-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170118]
Using /ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /ansible/ec2.py inventory source with script plugin
Parsed /ansible/ansible_hosts.ini inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python3.5/dist-packages/ansible/plugins/callback/__init__.py
_____________________
< PLAYBOOK: _test.yml >
---------------------
1 plays in _test.yml
__________________
< PLAY [localhost] >
------------------
META: ran handlers
______________
< TASK [debug] >
--------------

task path: /ansible/_test.yml:5
ok: [localhost] => {
"msg": "b"
}
META: ran handlers
META: ran handlers
____________
< PLAY RECAP >
------------
localhost : ok=1 changed=0 unreachable=0 failed=0

Then this is repeated 26 times

Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fa5c4a9e950>
Traceback (most recent call last):
File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable

EXPECTED RESULTS

Less ignored exceptions

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

ansible-playbook

ANSIBLE VERSION

ansible 2.3.0
config file = /home/…/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

forks = 100, pipelining = True

OS / ENVIRONMENT

Distributor ID:	Debian
Description:	Debian GNU/Linux 8.7 (jessie)
Release:	8.7
Codename:	jessie

SUMMARY

Sometimes, like once every 10 runs, I'm getting a whole lot of (like 20 times, all have the exact same address):

Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f51bb741950>
Traceback (most recent call last):
File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable

STEPS TO REPRODUCE

I can reproduce it with a --limit on one host and a --start-at-task with an unexisting task, so the playbook is doing like nothing apart skipping hosts.