I have a specific task run “shell: sudo script” in a playbook, where the script on the remote host must be executed via sudo but we can’t access the shell as root. The task is specified as the following:
shell: sudo /usr/local/sbin/script {{ dir_path }}/{{ item }}
with_items:
- “{{ dirs.stdout_lines }}”
With Ansible 1.7, I am getting the “failed to parse: [sudo] password” error when running ansible-playbook with -K -vvvv.
ESTABLISH CONNECTION FOR USER: me
REMOTE_MODULE command sudo /usr/local/sbin/script /data/builds/175 #USE_SHELL
EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-eyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=me’, ‘-o’, ‘ConnectTimeout=10’, ‘ap.uw.edu’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1428972729.79-247009978596627 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1428972729.79-247009978596627 && echo $HOME/.ansible/tmp/ansible-tmp-1428972729.79-247009978596627’”]
PUT /tmp/tmp75nx9A TO /usr/lusers/me/.ansible/tmp/ansible-tmp-1428972729.79-247009978596627/command
EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-eyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=me’, ‘-o’, ‘ConnectTimeout=10’, ‘ap.uw.edu’, u"/bin/sh -c ‘LANG=en_US.UTF-8 C_CTYPE=en_US.UTF-8 /usr/bin/python /usr/lusers/me/.ansible/tmp/ansible-tmp-1428972729.79-247009978596627/command’"]
fatal: [ap.uw.edu] => failed to parse: [sudo] password for me:
{“changed”: true, “end”: “2015-04-13 17:57:11.391966”, “stdout”: “”, “cmd”: "sudo /usr/local/sbin/script /data/builds/175 ", “start”: “2015-04-13 17:52:11.282850”, “delta”: “0:05:00.109116”, “stderr”: “”, “rc”: 1}
Would Ansible allow doing “shell: sudo script” in a playbook?