Issue 1:
I was unable to find a duplicate issue related to the script module similar to this issue.

ISSUE TYPE

Bug Report

COMPONENT NAME

script

ANSIBLE VERSION

ansible 2.5.0

CONFIGURATION

OS / ENVIRONMENT

Ubuntu 16.04.3 LTS

SUMMARY

Script module returns different results for same shell script depending if it is run locally or if it is run via ssh. Most particularly data printed by the script on stderr gets reported on stdin when executed over ssh but is correctly tagged when executed locally.

STEPS TO REPRODUCE

A script foo containing the following:

#!/bin/bash

echo this is stout
echo this is stderr >&2

is executed via ansible locally as follows:

ansible localhost -m script -a foo

It generates the output below:

[WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'

localhost | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "this is stderr\n",
"stdout": "this is stout\n",
"stdout_lines": [
"this is stout"
]
}

When executed via ssh as follows:

ansible -i inventory localhost -m script -a foo

it generates the following output:

localhost | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "Shared connection to localhost closed.\r\n",
"stdout": "this is stout\r\nthis is stderr\r\n",
"stdout_lines": [
"this is stout",
"this is stderr"
]
}

Details are committed here:

https://github.com/cfedde/ansible_shell_issue

EXPECTED RESULTS

I expected to see stderr output from the script "foo" to be in the stderr attribute:

localhost | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "this is stderr\n",
"stdout": "this is stout\n",
"stdout_lines": [
"this is stout"
]
}

ACTUAL RESULTS

Remote results did not identify scripts's stderr output.

localhost | SUCCESS => {
"changed": true,
"rc": 0,
"stderr": "Shared connection to localhost closed.\r\n",
"stdout": "this is stout\r\nthis is stderr\r\n",
"stdout_lines": [
"this is stout",
"this is stderr"
]
}

Issue 2:
I recently opened issue #13388 where I tried to introduce the --user=<user> option for Ansibles Docker connection plugin. I concluded within this issue, that my changes made the execution of Ansible tasks on Docker containers really slow.

Today I started a Playbook on another machine (at work), where I also deploy tasks to a container with the Docker connectio plugin and everything went fine, till I updated my Ansible installation. Since then every task executed on a Docker containe takes very long and Python consumes 100% CPU.

After some time of investigation it turns out that this behavior was caused by the pull request #13200 which was merged yesterday: bebd2c5.

Here is an example Playbook, which will reproduce the current behavior:

- name: this playbook is for testing purposes
hosts: localhost
tasks:

- name: run jenkins container
docker:
name: jenkinstest
image: jenkins
state: started
docker_user: root

- name: add container to inventory
add_host:
name: jenkinstest
ansible_connection: docker

- name: run a task inside the container
delegate_to: jenkinstest
file:
path: /root/test/me
state: directory

If you reset your local repository to the mentioned pull request, this playbook will hang on the third task and Python consumes 100% CPU for a long time. If you reset your local repository to the commit before, everything works as expected and the playbook should be executed within seconds.

The changes made are too sophisticated for my humble Python knowledge. So @amenonsen please have a look, what could cause the behavior. Maybe @abadger has some good ideas too.

This issue would enable feature request #13388.