# Ansible Ad-Hoc command - raw module not working on Cisco IOS devices

**URL:** <https://forum.ansible.com/t/ansible-ad-hoc-command-raw-module-not-working-on-cisco-ios-devices/36689>\
**Category:** Ansible Project\
**Created:** [June 4, 2022, 11:57pm UTC](https://forum.ansible.com/t/ansible-ad-hoc-command-raw-module-not-working-on-cisco-ios-devices/36689 "2022-06-04T23:57:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdellah\_Chadid](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Abdellah\_Chadid](https://forum.ansible.com/u/Abdellah_Chadid)\
**Post date:** [June 4, 2022, 11:57pm UTC](https://forum.ansible.com/t/ansible-ad-hoc-command-raw-module-not-working-on-cisco-ios-devices/36689/1 "2022-06-04T23:57:28Z")

</div>

trying to use Ad Hoc commands on both my Cisco ios Router and Switch with the _ **-m raw** _ Module. But getting the following error instead.

**$ansible -i inventory\_file02.ini netgrp -m raw -a “show version” -u abdo -K**

**Error====**

BECOME password: R1 | FAILED | rc=127 \>\> /bin/sh: 1: show: not found non-zero return code SW1 | FAILED | rc=127 \>\> /bin/sh: 1: show: not found non-zero return code

**Inventory file=====**

R1 ansible\_host=192.168.20.1 SW1 ansible\_host=192.168.10.2 [netgrp] R1 SW1

**group\_vars/netgrp.yml===**

— ansible\_connection: network\_cli ansible\_network\_os: ios ansible\_user: abdo absible\_password: kali/abdo ansible\_become: yes ansible\_become\_method: enable ansible\_ssh\_pass: kali/abdo

**$ ansible -i inventory\_file02.ini netgrp -m raw -a “show version” -u abdo -kK -vvv**

ansible [core 2.12.6] config file = /etc/ansible/ansible.cfg configured module search path = [‘/home/kali/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’] ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible ansible collection location = /home/kali/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0] jinja version = 3.0.3 libyaml = True Using /etc/ansible/ansible.cfg as config file SSH password: BECOME password[defaults to SSH password]: host\_list declined parsing /home/kali/ansible\_play01/net\_play02/inventory\_file02.ini as it did not pass its verify\_file() method script declined parsing /home/kali/ansible\_play01/net\_play02/inventory\_file02.ini as it did not pass its verify\_file() method auto declined parsing /home/kali/ansible\_play01/net\_play02/inventory\_file02.ini as it did not pass its verify\_file() method yaml declined parsing /home/kali/ansible\_play01/net\_play02/inventory\_file02.ini as it did not pass its verify\_file() method Parsed /home/kali/ansible\_play01/net\_play02/inventory\_file02.ini inventory source with ini plugin Skipping callback ‘default’, as we already have a stdout callback. Skipping callback ‘minimal’, as we already have a stdout callback. Skipping callback ‘oneline’, as we already have a stdout callback. META: ran handlers redirecting (type: connection) ansible.builtin.network\_cli to ansible.netcommon.network\_cli redirecting (type: connection) ansible.builtin.network\_cli to ansible.netcommon.network\_cli redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable \<192.168.10.2\> ESTABLISH LOCAL CONNECTION FOR USER: kali \<192.168.10.2\> EXEC show version \<192.168.20.1\> ESTABLISH LOCAL CONNECTION FOR USER: kali \<192.168.20.1\> EXEC show version SW1 | FAILED | rc=127 \>\> /bin/sh: 1: show: not found

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [June 7, 2022, 1:52pm UTC](https://forum.ansible.com/t/ansible-ad-hoc-command-raw-module-not-working-on-cisco-ios-devices/36689/2 "2022-06-07T13:52:53Z")

</div>

Hey,

You might want to use the ios\_command module for Cisco IOS specific commands.  
**ansible ios -m cisco.ios.ios\_command -a “commands=‘show version’” -vvvv**

Regards,  
Sagar Paul

---

<div class="post-metadata">

**Author:** ![abdo\_chadid](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@abdo\_chadid](https://forum.ansible.com/u/abdo_chadid)\
**Post date:** [June 7, 2022, 1:55pm UTC](https://forum.ansible.com/t/ansible-ad-hoc-command-raw-module-not-working-on-cisco-ios-devices/36689/3 "2022-06-07T13:55:46Z")

</div>

I’m not sure… I did try it, but it result with an error message indicating that the module should be used in a playbook not on ad-hoc command… have you tried that yourself !?

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [June 8, 2022, 5:01pm UTC](https://forum.ansible.com/t/ansible-ad-hoc-command-raw-module-not-working-on-cisco-ios-devices/36689/4 "2022-06-08T17:01:57Z")

</div>

Hey,

Please check the op attached in the gist below  
[https://gist.github.com/KB-perByte/09397b462462bd6db3f52bac8c097d04](https://gist.github.com/KB-perByte/09397b462462bd6db3f52bac8c097d04)

Regards,  
Sagar Paul
