Forum Discussion

R13's avatar
R13
Icon for Nimbostratus rankNimbostratus
Feb 27, 2024

Error when running bigip_command Playbook against LTM : Syntax Error: unexpected argument /bin/sh\n

I am running a Playbook to test bigip_command using ansible [core 2.15.3] against LTM running 15.1.6.1. When I run the playbook I get the following message:

UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo $HOME/tmp"&& mkdir "echo $HOME/tmp/ansible-tmp-1709037153.0021555-3167181-73985055078518" && echo ansible-tmp-1709037153.0021555-3167181-73985055078518="echo $HOME/tmp/ansible-tmp-1709037153.0021555-3167181-73985055078518" ), exited with result 1”,
“unreachable”: true
}

When I run the Playbook with -vvv flags I see the following line just before the error message pasted above: Failed to connect to the host via ssh: Syntax Error: unexpected argument “/bin/sh”

Similarly, if I test the ssh I also see this same unexpected argument message:

ansible all -m shell -a id -vvv

Syntax Error: unexpected argument “/bin/sh”\n’

I have tried editing various things in hosts file and ansible.cfg but nothing I have tried seems to have made a difference. Is anyone familiar with this and what is needed to resolve this. Any help is greatly appreciated!

4 Replies

  • do you have that “/bin/sh”\n’ in the ansible file?

    if no, probably you ansible input file contains DOS format line ending (\r\n) which different from unix format (\n).
    use "dos2unix" command to quickly remove the "\r".

    you can also try to change builtin shell to /bin/bash because anyway /bin/sh is actually link to /bin/bash in F5.

    [root@ltm1:Active:Standalone] config # ls -la /bin/sh
    lrwxrwxrwx. 1 root root 4 Dec  1 11:57 /bin/sh -> bash
    [root@ltm1:Active:Standalone] config # ls -la /bin/bash
    -rwxr-xr-x. 1 root root 964584 Dec  1 10:37 /bin/bash
    [root@ltm1:Active:Standalone] config #

     

    • R13's avatar
      R13
      Icon for Nimbostratus rankNimbostratus

      Thank for your reply. I tried adding executable = /bin/bash to ansible.cfg but it produced the same error but with bash:

      Syntax Error: unexpected argument "/bin/bash"

      • zamroni777's avatar
        zamroni777
        Icon for Cumulonimbus rankCumulonimbus

        ensure that the cfg file doesnt contain dos format line ending.

        there is also error message "Failed to create temporary directory..." which usually means no write permission.
        /tmp is usually owned by root
        i usually use /var/tmp as it usually user writable