A basic ansible command cannot go through

89 views
Skip to first unread message

Kevin Y

unread,
Jan 18, 2022, 11:39:48 PM1/18/22
to Ansible Project
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 <module>
    from ansible import context
  File "/usr/local/lib/python3.8/dist-packages/ansible/context.py", line 18, in <module>
    from ansible.module_utils.common._collections_compat import Mapping, Set
ModuleNotFoundError: No module named 'ansible.module_utils'

dulh...@mailbox.org

unread,
Jan 19, 2022, 5:44:01 AM1/19/22
to ansible...@googlegroups.com
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 ?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c3cebbc6-937c-46d7-b316-d950f7d9cb9dn%40googlegroups.com.

Dick Visser

unread,
Jan 19, 2022, 5:51:58 AM1/19/22
to ansible...@googlegroups.com
looks like your installation is messed up.
What does 'ansible --version' say?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c3cebbc6-937c-46d7-b316-d950f7d9cb9dn%40googlegroups.com.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Kevin Y

unread,
Jan 19, 2022, 10:40:25 AM1/19/22
to Ansible Project
Hi Dick, Thanks for your reply. I tried it with different quotes. all of them cannot work. 
any other suggestions?

Dick Visser

unread,
Jan 20, 2022, 1:54:17 PM1/20/22
to ansible...@googlegroups.com
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





--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Evan Hisey

unread,
Jan 22, 2022, 12:41:00 PM1/22/22
to Ansible Project
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.

Nilashish Chakraborty

unread,
Jan 31, 2022, 1:59:53 AM1/31/22
to ansible...@googlegroups.com
Hello Kevin,

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

Thank you.

Reply all
Reply to author
Forward
0 new messages