sudo: not found - but installed

Hi,

i have a strange problem with one of my ansible managed hosts.
Error message:

FAILED! => {“changed”: false, “failed”: true, “module_stderr”: “”, “module_stdout”: “sudo: not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}

But sudo is installed and i managed the host for months with out problems.

me@example:/home/me # whereis sudo

sudo: /usr/local/bin/sudo /usr/local/man/man8/sudo.8.gz /usr/ports/security/sudo

uname -a:

FreeBSD me.example.org 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64

Here is the verbose error message:

<hostname.example.org> ESTABLISH SSH CONNECTION FOR USER: ansible

<hostname.example.org> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt hostname.example.org ‘/bin/sh -c ‘"’"’( umask 22 && mkdir -p “echo $HOME/.ansible/tmp/ansible-tmp-1460277972.44-221877909670031” && echo “echo $HOME/.ansible/tmp/ansible-tmp-1460277972.44-221877909670031” )‘"’"‘’

<hostname.example.org> PUT /tmp/tmpj07XGK TO /home/ansible/.ansible/tmp/ansible-tmp-1460277972.44-221877909670031/setup

<hostname.example.org> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r ‘[hostname.example.org]’

<hostname.example.org> ESTABLISH SSH CONNECTION FOR USER: ansible

<hostname.example.org> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt hostname.example.org ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“'echo BECOME-SUCCESS-hnsuuegbwwfxovpkaayhtkvdzmguwtww; /bin/sh -c '”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘“‘LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/local/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1460277972.44-221877909670031/setup; rm -rf “/home/ansible/.ansible/tmp/ansible-tmp-1460277972.44-221877909670031/” > /dev/null 2>&1’”’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“'”‘"’“‘’”‘"’“'”‘"’“'”‘"’‘"’"‘’

fatal: [hostname.example.org]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_name”: “setup”}, “module_stderr”: “OpenSSH_7.2p2, OpenSSL 1.0.1s-freebsd 1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 6633\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 127\r\nShared connection to hostname.example.org closed.\r\n”, “module_stdout”: “sudo: not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}

I have this problem only with one host, all others are working fine.

Does anyone have an idea?

Thanks

Mark

It looks like /usr/local/bin is not in the path when ansible logs in (it does not do an interactive login so if you are setting the path there it won’t be available to ansible), try setting sudo_exe=/usr/local/bin/sudo in ansible.cfg