A basic ansible command cannot go through

Hi I am a little new to ansible. Anyone can take a look at the below why the command cannot go through? Thank you!

admin1@Len:~$ ansible lab-hosts -m raw -a “show run” -u admin -k | grep ‘hostname| system mtu’
Traceback (most recent call last):
File “/usr/bin/ansible”, line 34, in
from ansible import context
File “/usr/local/lib/python3.8/dist-packages/ansible/context.py”, line 18, in
from ansible.module_utils.common._collections_compat import Mapping, Set
ModuleNotFoundError: No module named ‘ansible.module_utils’

I have not used the raw module ever. That being said … I believe generally ad hoc comands need the arduments to be quoted as a whole.

Do I wonder whether this may work better?

ansible lab-hosts -m raw -a “show run -u admin -k | grep ‘hostname| system mtu’”

I am used to single quotes around arguments. But as you have some in the grep portion of your command already I’d try double quotes aroung the entire argument as used above

Also going through your error … ModuleNotFoundError: No module named ‘ansible.module_utils’ sounds suspicious.
Can you display the manual via ansible-doc raw ?

looks like your installation is messed up.

What does ‘ansible --version’ say?

Hi Dick, Thanks for your reply. I tried it with different quotes. all of them cannot work.
any other suggestions?

The quoting was to make it clear what should be typed at the command line.
So you should not type quotes. Just type

ansible --version

Are you connecting to a Cisco network device? If so this commend will fail, as the you need to you a different method of connecting an execution since Cisco switches don’t support python.

Hello Kevin,

Please refer to the Ansible Network Getting Started doc for guidance on how to execute commands on supported network devices.

Thank you.