Receiving non zero return code error while running raw module

Hello, I’m new to ansible and I need some help.
I have been trying to test running raw module to cisco devices but I keep receiving a failed error and get the following message:
FAILED! => {“changed”: true, “msg”: “non-zero return code”, “rc”: 127, “stderr”: “/bin/sh: 1: show: not found\n”, “stderr_lines”: [“/bin/sh: 1: show: not found”], “stdout”: “”, “stdout_lines”: }
How can I correct this issue? It just started today.

Hi,

Here is your issue:

“stderr_lines”: [“/bin/sh: 1: show: not found”]

It seems you are trying to run show command, which isn’t interpreted by shell in use (sh).

Raw module doc page states that:

  • Arguments given to raw are run directly through the configured remote shell.

I’m not sure about Cisco devices, but I think they use their own shell, be it IOS or Catalyst.

Could you share your playbook as well ?

Edit: Also note you can specify which shell to use if you know its path.


  • name: ARP
    hosts: all
    gather_facts: false

    tasks:

    • name: Show ARP
      raw: “show arp”
      register: print_output

    • debug: var=print_output.stdout_lines

Its really strange it has worked as is until today when ansible tried to update and I received a error

when ansible tried to update and I received a error

I don’t know about that; you could post your update error in another thread if you’d like assistance on this matter.

About the present issue, did you get the same error on all devices you ran your playbook on ?

I’m also wondering if some config changed on your devices; an OS upgrade perhaps ?

Anyways, as said before, you could look for your devices shell path, then specify it on executable raw module’s parameter.

I only get the error when i try to run a playbook using raw module.

My config on devices hasn’t been changed or upgraded, its a test enviroment.

I’m new to linux and ansible, not really sure what you mean in your last sentence, Sorry LOL

I’m new to linux and ansible, not really sure what you mean in your last sentence, Sorry LOL

raw module allows you to specify which shell to use to run your commands, so if you know which one is used on your remote device, you could use it to run raw commands. By defaults, raw module uses /bin/sh. I’m not familiar with Cisco devices, so I don’t know for sure how you could get this information, and I feel an echo $SHELL won’t cut it.

Anyways, you should probably use cisco.ios.ios_command module or ansible.netcommon.network_cli connection instead.

1 Like