I am running my ansible playbooks from containers for a while (I didn’t want to mess up my Mac). After I’ve started to use data-only containers. I’ve got the following message.
I’ve got the following message:
Failed to connect to the host via ssh: Control socket connect(/home/dev/.ansible/cp/ansible-ssh-10.88.157.131-22-root): Connection refused Failed to connect to new control master
Digging around, I could find the following post: “Multiplex/shared SSH connections not connecting: “Control socket connect Connection refused. Failed to connect to new control master”
Base on that info, I’ve just need to Change the ControlPath to shared memory. Seems the filesystem I am using won’t work well with unix socket. Maybe because I am using a volume from my data-only container (overlayfs).
Base on the details below, I am using my ControlPath at $HOME folder.
TASK [bridges : Pull facts on hypervisor] ************************************** Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py <10.88.157.131> ESTABLISH SSH CONNECTION FOR USER: root <10.88.157.131> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/dev/.ansible/cp/ansible-ssh-%h-%p-%r 10.88.157.131 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1490052386.11-256666980522156 `" && echo ansible-tmp-1490052386.11-256666980522156="` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1490052386.11-256666980522156 `" ) && sleep 0'"'"'' fatal: [localhost]: UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Control socket connect(/home/dev/.ansible/cp/ansible-ssh-10.88.157.131-22-root): Connection refused\r\nFailed to connect to new control master\r\n", "unreachable": true }
Then, I set a different path on my ansible.cfg file at my playbook folder with the following content:
[defaults] host_key_checking=false log_path = /var/log/ansible/ansible-packet-nuagevns.log remote_tmp = /tmp/.ansible-${USER}/tmp [ssh_connection] ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s control_path = /dev/shm/cp%%h-%%p-%%r
And now It’s working as you can appreciate on the following:
TASK [bridges : Pull facts on hypervisor] ************************************** task path: /home/dev/packet-nuagevns/roles/bridges/tasks/main.yml:7 Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py <10.88.157.131> ESTABLISH SSH CONNECTION FOR USER: root <10.88.157.131> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/dev/shm/cp%h-%p-%r 10.88.157.131 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1490052526.68-192550473212879 `" && echo ansible-tmp-1490052526.68-192550473212879="` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1490052526.68-192550473212879 `" ) && sleep 0'"'"'' <10.88.157.131> PUT /tmp/tmpYs_Wx0 TO /tmp/.ansible-root/tmp/ansible-tmp-1490052526.68-192550473212879/setup.py <10.88.157.131> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/dev/shm/cp%h-%p-%r '[10.88.157.131]' <10.88.157.131> ESTABLISH SSH CONNECTION FOR USER: root <10.88.157.131> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/dev/shm/cp%h-%p-%r 10.88.157.131 '/bin/sh -c '"'"'chmod u+x /tmp/.ansible-root/tmp/ansible-tmp-1490052526.68-192550473212879/ /tmp/.ansible-root/tmp/ansible-tmp-1490052526.68-192550473212879/setup.py && sleep 0'"'"'' <10.88.157.131> ESTABLISH SSH CONNECTION FOR USER: root <10.88.157.131> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/dev/shm/cp%h-%p-%r -tt 10.88.157.131 '/bin/sh -c '"'"'/usr/bin/python /tmp/.ansible-root/tmp/ansible-tmp-1490052526.68-192550473212879/setup.py; rm -rf "/tmp/.ansible-root/tmp/ansible-tmp-1490052526.68-192550473212879/" > /dev/null 2>&1 && sleep 0'"'"'' ok: [localhost -> 10.88.157.131]
See ya!