# Ansible make\_sudo\_cmd not working in the 1.4.1

**URL:** <https://forum.ansible.com/t/ansible-make-sudo-cmd-not-working-in-the-1-4-1/14193>\
**Category:** Ansible Project\
**Created:** [December 20, 2013, 12:14pm UTC](https://forum.ansible.com/t/ansible-make-sudo-cmd-not-working-in-the-1-4-1/14193 "2013-12-20T12:14:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristobal\_Rosa](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Cristobal\_Rosa](https://forum.ansible.com/u/Cristobal_Rosa)\
**Post date:** [December 20, 2013, 12:14pm UTC](https://forum.ansible.com/t/ansible-make-sudo-cmd-not-working-in-the-1-4-1/14193/1 "2013-12-20T12:14:22Z")

</div>

Hi guys,

I have two different versions of ansible in my systems. One of them is ansible 1.2 and the other one is 1.4.1. (I’m trying to update the systems from 1.2 to 1.4)

I’m using a private key and certificates in order to get ansible sudo commands running without passwords.

When I run the same command in both installations the system whose ansible version is 1.4 doesn’t work. The command hangs

The ansible command I’m running is: ansible XXX.XXX.XXX.XXX -vvv -s -m shell -a “uptime”

Command with ansible 1.2

\<XXX.XXX.XXX.XXX\> ESTABLISH CONNECTION FOR USER: myuser  
\<XXX.XXX.XXX.XXX\> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘IdentityFile=mycert.pem’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘XXX.XXX.XXX.XXX’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1387539732.06-150122069933302 && chmod a+rx $HOME/.ansible/tmp/ansible-1387539732.06-150122069933302 && echo $HOME/.ansible/tmp/ansible-1387539732.06-150122069933302’”]  
\<XXX.XXX.XXX.XXX\> REMOTE\_MODULE command uptime #USE\_SHELL  
\<XXX.XXX.XXX.XXX\> PUT /tmp/tmpf1tkYz TO /home/myuser/.ansible/tmp/ansible-1387539732.06-150122069933302/command  
\<XXX.XXX.XXX.XXX\> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘IdentityFile=mycert.pem’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘XXX.XXX.XXX.XXX’, ‘/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=gfgeicunrdbbmktjrauegdbvbdjdazhc] password: " -u root /bin/sh -c '”'“'/usr/bin/python /home/myuser/.ansible/tmp/ansible-1387539732.06-150122069933302/command; rm -rf /home/myuser/.ansible/tmp/ansible-1387539732.06-150122069933302/ \>/dev/null 2\>&1'”'"''’]  
XXX.XXX.XXX.XXX | success | rc=0 \>\>  
12:42:12 up 25 min, 4 users, load average: 0.00, 0.02, 0.07

The same command with ansible 1.4.1:

\<XXX.XXX.XXX.XXX\> ESTABLISH CONNECTION FOR USER: myuser  
\<XXX.XXX.XXX.XXX\> EXEC [‘ssh’, ‘-tt’, ‘-vvv’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘IdentityFile=mycert.pem’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘XXX.XXX.XXX.XXX’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1387539725.72-214926055344642 && chmod a+rx $HOME/.ansible/tmp/ansible-1387539725.72-214926055344642 && echo $HOME/.ansible/tmp/ansible-1387539725.72-214926055344642’”]  
\<XXX.XXX.XXX.XXX\> REMOTE\_MODULE command uptime #USE\_SHELL  
\<XXX.XXX.XXX.XXX\> PUT /tmp/tmp6B6Ewf TO /home/myuser/.ansible/tmp/ansible-1387539725.72-214926055344642/command  
\<XXX.XXX.XXX.XXX\> EXEC [‘ssh’, ‘-tt’, ‘-vvv’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘IdentityFile=mycert.pem’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘XXX.XXX.XXX.XXX’, ‘/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=pgsdnkquhwjufslqsipwaonzwmgwahog] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-pgsdnkquhwjufslqsipwaonzwmgwahog; /usr/bin/python /home/myuser/.ansible/tmp/ansible-1387539725.72-214926055344642/command; rm -rf /home/myuser/.ansible/tmp/ansible-1387539725.72-214926055344642/ \>/dev/null 2\>&1'”'"''’]

Command hangs

Looking in both logs I’ve found that the command are differents:

‘/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=gfgeicunrdbbmktjrauegdbvbdjdazhc] password: " -u root /bin/sh -c '”'“'/usr/bin/python /home/myuser/.ansible/tmp/ansible-1387539732.06-150122069933302/command; rm -rf /home/myuser/.ansible/tmp/ansible-1387539732.06-150122069933302/ \>/dev/null 2\>&1'”'"''’

‘/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=pgsdnkquhwjufslqsipwaonzwmgwahog] password: " -u root /bin/sh -c '”'“' **echo SUDO-SUCCESS-pgsdnkquhwjufslqsipwaonzwmgwahog;** /usr/bin/python /home/myuser/.ansible/tmp/ansible-1387539725.72-214926055344642/command; rm -rf /home/myuser/.ansible/tmp/ansible-1387539725.72-214926055344642/ \>/dev/null 2\>&1'”'"''’

How can I solve this issue?

I think maybe this is an issue in the make\_sudo\_cmd ([https://github.com/ansible/ansible/commit/ea2ec6237aa97e6c434ccf4af124f0632747ef06](https://github.com/ansible/ansible/commit/ea2ec6237aa97e6c434ccf4af124f0632747ef06)) or maybe I should change something in my configuration.

My ansible configuration is:

_# config file for ansible – [http://ansible.github.com](http://ansible.github.com)_  
_# nearly all parameters can be overridden in ansible-playbook or with command line flags_  
_# ansible will read ~/.ansible.cfg or /etc/ansible/ansible.cfg, whichever it finds first_

_[defaults]_

_# location of inventory file, eliminates need to specify -i_

_hostfile = /etc/ansible/hosts_  
_host\_key\_checking = False_

_# location of ansible library, eliminates need to specify --module-path_

_library = /path/to/my/library_

_# default module name used in /usr/bin/ansible when -m is not specified_

_module\_name = command_

_# home directory where temp files are stored on remote systems. Should_  
_# almost always contain $HOME or be a directory writeable by all users_

_remote\_tmp = $HOME/.ansible/tmp_

_# the default pattern for ansible-playbooks (“hosts:”)_

_pattern = \*_

_# the default number of forks (parallelism) to be used. Usually you_  
_# can crank this up._

_forks=1_

_# the timeout used by various connection types. Usually this corresponds_  
_# to an SSH timeout_

_# A bug in ansible leads to failures when this option is active._  
_# Keep it commented until ansible devs fix it._  
_# timeout=5_

_# when using --poll or “poll:” in an ansible playbook, and not specifying_  
_# an explicit poll interval, use this interval_

_poll\_interval=15_

_# when specifying --sudo to /usr/bin/ansible or “sudo:” in a playbook,_  
_# and not specifying “–sudo-user” or “sudo\_user” respectively, sudo_  
_# to this user account_

_sudo\_user=root_

_# the following forces ansible to always ask for the sudo password (instead of having_  
_# to add -K to the commandline). Or you can use the environment variable (ANSIBLE\_ASK\_SUDO\_PASS)_

_ask\_sudo\_pass=False_

_# the following forces ansible to always ask for the ssh-password (-k)_  
_# can also be set by the environment variable ANSIBLE\_ASK\_PASS_

_#ask\_pass=True_

_# connection to use when -c \<connection\_type\> is not specified_

_transport=ssh_

_# remote SSH port to be used when --port or “port:” or an equivalent inventory_  
_# variable is not specified._

_remote\_port=22_

_# if set, always run /usr/bin/ansible commands as this user, and assume this value_  
_# if “user:” is not set in a playbook. If not set, use the current Unix user_  
_# as the default_

_remote\_user=myuser_

_# the default sudo executable. If a sudo alternative with a sudo-compatible interface_  
_# is used, specify its executable name as the default_

_sudo\_exe=sudo_

_# the default flags passed to sudo_  
_# sudo\_flags=-H_

_# how to handle hash defined in several places_  
_# hash can be merged, or replaced_  
_# if you use replace, and have multiple hashes named ‘x’, the last defined_  
_# will override the previously defined one_  
_# if you use merge here, hash will cumulate their keys, but keys will still_  
_# override each other_  
_# replace is the default value, and is how ansible always handled hash variables_
