Issue 1:
Issue Type:

Bug Report

Ansible Version:

1.4.4

Environment:

Oracle Enterprise Linux 5.9

Summary:

I've encountered an error in a file module task running on OEL 5.9 that doesn't seem to have the same issue running on CentOS 5.x:

Steps To Reproduce:

- name: ensure /mnt/s3/quantumcloud exists
file: path=/mnt/s3/quantumcloud owner=root group=root mode=0755 state=directory
sudo: True

Expected Results:

If directory exists, a no change response

Actual Results:

fatal: [hostXXX.domainXXX] => failed to parse:
SUDO-SUCCESS-szammrqwhpjmcnhwvqnlnvdrpggamxsj
Traceback (most recent call last):
File "/home/jrosengren/.ansible/tmp/ansible-1392144575.3-31016918420544/file", line 1378, in ?
main()
File "/home/jrosengren/.ansible/tmp/ansible-1392144575.3-31016918420544/file", line 269, in main
changed = module.set_directory_attributes_if_different(file_args, changed)
File "/home/jrosengren/.ansible/tmp/ansible-1392144575.3-31016918420544/file", line 833, in set_directory_attributes_if_different
changed = self.set_mode_if_different(
File "/home/jrosengren/.ansible/tmp/ansible-1392144575.3-31016918420544/file", line 796, in set_mode_if_different
raise e
OSError: [Errno 5] Input/output error: '/mnt/s3/quantumcloud'

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

ssh.py from plugins/connection module

ANSIBLE VERSION

ansible 2.2.0

CONFIGURATION

N/A

OS / ENVIRONMENT

Centos 7 with Python 3.4.3

SUMMARY

When you try lo login into a server, the user name generated is not valid. There is a duplicated call to the to_bytes method when applying the ANSIBLE_REMOTE_USER.

STEPS TO REPRODUCE

When we try to make a ping to our openstack group:

ansible openstack -m ping

Where our /etc/ansible/hosts is:

[openstack]
bootstrap ansible_host=10.200.0.130 ansible_user=cloud-user ansible_ssh_private_key_file=/home/uarrien/Documents/stratio/certs/testKeyPair.pem

EXPECTED RESULTS

bootstrap | SUCCESS => {
"changed": false,
"ping": "pong"
}

ACTUAL RESULTS

bootstrap | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}

If we execute the command verbose:

No config file found; using defaults
Using module file /root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/ansible/modules/core/system/ping.py
<10.200.0.130> ESTABLISH SSH CONNECTION FOR USER: cloud-user
<10.200.0.130> SSH: EXEC ssh -q -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/uarrien/Documents/stratio/certs/testKeyPair.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User=b'"'"'cloud-user'"'"'' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.200.0.130 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1475234121.3512669-205100461461219 `" && echo ansible-tmp-1475234121.3512669-205100461461219="` echo $HOME/.ansible/tmp/ansible-tmp-1475234121.3512669-205100461461219 `" ) && sleep 0'"'"''
bootstrap | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}

We can see that the User is not well formed:

'User=b'"'"'cloud-user'"'"''

To fix this, we should remove the to_bytes call from the following line:

https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/connection/ssh.py#L197

We have tested with the following line of code and it works properly:

("-o", "User={0}".format(self._play_context.remote_user))