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 ?
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.