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!

1 Like

Can you share the task from your playbook?

Thank you for the reply. This is the Playbook:

  • name: Check NTP Configuration on LTM
    hosts: all
    gather_facts: false
    vars:
    ansible_connection: ssh
    ansible_network_os: f5networks.f5_bigip.bigip
    ansible_remote_tmp: $HOME/tmp
    ansible_user: [OMITTED]
    ansible_ssh_pass: [OMITTED]
    tasks:
    • name: Check NTP Timezone
      bigip_command:
      commands: list sys ntp | grep time

I’m not familiar with F5, we don’t use them, but it looks like Ansible is trying to create a temp folder on the F5 to contain whatever temporary execution data. Does F5 support creating that directory? What happens if you try your playbook without the ansible_remote_temp: $HOME/tmp line?

Also, for all of my Cisco and A10 Load Balancer playbooks I use “connection: local” to tell ansible that the local host and modules will deal with the connection. Have you tried this?

Do either of these playbooks work for you?

---
# Test Playbook 1
name: Check NTP Configuration on LTM
hosts: all
connection: local
gather_facts: false
vars:
  ansible_connection: ssh
  ansible_network_os: f5networks.f5_bigip.bigip
  ansible_remote_tmp: $HOME/tmp
  ansible_user: [OMITTED]
  ansible_ssh_pass: [OMITTED]

tasks:
    name: Check NTP Timezone
    bigip_command:
    commands: list sys ntp | grep time
---
# Test Playbook 1
name: Check NTP Configuration on LTM
hosts: all
gather_facts: false
vars:
  ansible_connection: ssh
  ansible_network_os: f5networks.f5_bigip.bigip
  ansible_user: [OMITTED]
  ansible_ssh_pass: [OMITTED]

tasks:
    name: Check NTP Timezone
    bigip_command:
    commands: list sys ntp | grep time```

Thank you for the replay and suggestions. I tried both test Playbooks and the result was the same both times. If suppose my next step will be to see if this /tmp folder is allowed. Thanks again!

1 Like

Hello,

I am facing the same issue,
Did you find the solution, if yes? will you please share the procedure

Yes, the fix for me was (as listed above) using connection: local. Initially, as also indicated above, it didn’t work for me because there were some other separate issues but, ultimately, the fix was to change the connection from ssh to local. Hope this helps!