Hi Kai,

Did not know that I had use shell. Thanks . Works OK.

ansible -i ./ec2.py 192.168.108.53  -m shell -s -u ansible -a "rpm -qa 
--last | grep kernel"

Regards,
Abey

On Tuesday, March 27, 2018 at 2:54:19 PM UTC+1, Kai Stian Olstad wrote:
>
> On Tuesday, 27 March 2018 15.50.48 CEST Abey Thomas wrote: 
> > I would like to use ansible to execute commands on a host. 
> > 
> > This works 
> > ansible -i ./ec2.py 192.168.108.53  -s -u ansible -a "rpm -qa --last 
> kernel" 
> > 
> > This does not work as expected the output of rpm is given as the final 
> > output. I would like to filter the output further. 
> > 
> > ansible -i ./ec2.py 192.168.108.53  -s -u ansible -a "rpm -qa --last | 
> grep 
> > kernel" 
>
> command module doesn't support pipe and redirect, only shell and raw do 
> that. 
>
> Ansible ad-hoc uses command module as default, so you need add "-m shell" 
> to make pipes work. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2afbde75-3147-4cd9-821d-dc258a6e0523%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to