Issues with ssh and Ansible

When running an ansible task (with a script action), I'm getting this error message:

stderr: OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to 10.0.2.222 closed.

Now, there are a bunch of tasks targeting the same host before this one, and they all work fine.I know it's the client, because the client is Debian; the thing being provisioned is Centos.

When I tried to look up this error message, I discovered (to my chagrin) that what I got is usually the first part of some longer message for some other problem. I tried adding

Host 10.0.2.222
  ControlMaster no

to the beginning of my /etc/ssh/ssh_config because of this question out of pure desperation, but it didn't work and I genuinely don't know what could have gone wrong; I don't know enough about how SSH works to even figure out what the most likely culprit would be.


Solution 1:

This fixed the problem mentioned in the question (problems still exist with the ssh connection, but that's for another question).

By default, ansible adds some options which override ssh_config options. Specifically, it adds:

-o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/devel/.ansible/cp/ansible-ssh-%h-%p-%r"

Figured that out by using -vvv with ansible-playbook.

You can fix / override those options by specifying ssh_args in the [ssh_connection] section of your .ansible.cfg as specified here. Also worth noting is that, counter to what you might infer from the name, changing ssh_args doesn't actually change all of the args. Ansible also passes -C -tt -v -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o ConnectTimeout=10 and other options (e.g. -o PasswordAuthentication=no -o User=root), some of which are simply immutable defaults, and some of which depend on variables you've specified in the playbook.