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 ? > On 01/19/2022 5:39 AM Kevin Y <[email protected]> wrote: > > > 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' > > > -- > 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 [email protected] > mailto:[email protected] . > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/c3cebbc6-937c-46d7-b316-d950f7d9cb9dn%40googlegroups.com > > https://groups.google.com/d/msgid/ansible-project/c3cebbc6-937c-46d7-b316-d950f7d9cb9dn%40googlegroups.com?utm_medium=email&utm_source=footer > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/49327839.521177.1642588986510%40office.mailbox.org.
