I am connecting to centos 7 virtual and physical machines using ansible with a user called ansible that has passwordless sudo permissions on all the boxes. On most machines it works, but on one box I get this error:
FAILED! => {
"changed": false,
"module_stderr": "Shared connection to ... closed.\r\n",
"module_stdout": "/var/tmp/sclpbsoCZ: line 8: -H: command not found\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 127
}
I set up passwordless sudo using advice from this link: https://code-maven.com/enable-ansible-passwordless-sudo (basically, edit /etc/sudoers to let user ansible sudo without a password)
I thought these machines were identical, but obviously something is amiss.
Adding -vvv to the ansible-playbook command lets me see that the command it is trying to run is:
'/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '
How is it that this one machine isn't working with ansible?