Breaking down the play.
$ ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/tmp/ansible-ssh-%h-%p-%r” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 10.X.X.193 /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=benehbanetqnytmmkklumnbvsiyukasg] password: " -u root /bin/sh -c '”’“‘echo BECOME-SUCCESS-benehbanetqnytmmkklumnbvsiyukasg; LANG=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1438377089.9-208037963158211/hostname’”‘"’’
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 1474
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 12
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
[command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
prompt] [-u user] [VAR=value] [-i|-s] []
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
prompt] [-u user] file …
debug3: mux_client_read_packet: read header failed: Broken pipe
Odd, improper invocation of sudo? Break down of the sudo commands.
$ /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=benehbanetqnytmmkklumnbvsiyukasg] password: " -u root /bin/sh -c '”’“‘echo BECOME-SUCCESS-benehbanetqnytmmkklumnbvsiyukasg; LANG=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1438377089.9-208037963158211/hostname’”‘"’’
[sudo via ansible, key=benehbanetqnytmmkklumnbvsiyukasg] password:
BECOME-SUCCESS-benehbanetqnytmmkklumnbvsiyukasg
{“changed”: false, “name”: “tester”, “ansible_facts”: {“ansible_hostname”: “tester”}}
That seems to work.
Test the ssh command.
$ ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/tmp/ansible-ssh-%h-%p-%r” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 10.X.X.193
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 1474
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 12
Last login: Fri Jul 31 16:33:09 2015 from 172.X.X.100
ansible@tester:~$
That seems to work.
Test the first sudo command, /bin/sh -c ‘sudo -k’
$ ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/tmp/ansible-ssh-%h-%p-%r” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 10.X.X.193 /bin/sh -c ‘sudo -k’
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 1474
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 12
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
[command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
prompt] [-u user] [VAR=value] [-i|-s] []
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
prompt] [-u user] file …
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
Not expected! Just over to the target system.
$ /bin/sh -c ‘sudo -k’
$ echo $?
0
So something about executing /bin/sh -c ‘sudo -k’ via ssh is breaking thing?