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!

  • 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"

      • pranay48's avatar
        pranay48
        Icon for Nimbostratus rankNimbostratus

        Hello,

        I am facing the same issue, did you find any solution? If yes, can you please list the procedure