Hi Kai, After posting this question, I went through the Ansible documentation again. It's working after using the -b and -K option as I have not configured passwordless sudo.
Thanks for the reply. -- Kaushik On Monday, April 9, 2018 at 1:08:56 AM UTC+5:30, Kai Stian Olstad wrote: > > On Sunday, 8 April 2018 18.57.38 CEST Kaushik Gosar wrote: > > I am trying to execute an Ad-Hoc command which requires sudo privileges > on > > a remote machine. > > > > Below is the command and the error it throws up > > > > kaushik@Machine_1:~$ ansible all -a "cat /etc/shadow" -u kaushik > > --ask-become-pass > > SUDO password: > > 192.168.101.12 | FAILED | rc=1 >> > > cat: /etc/shadow: Permission denied > > > > kaushik@Machine_1~$ > > > > If I ssh to the machine and execute the same command "cat /etc/shadow" , > it > > works without any errors. > > > > Any idea how to fix this? > > --ask-become-pass doesn't imply become so you need add -b or --become to > use become. > > -- > 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 firstname.lastname@example.org. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7b979f5c-8149-43df-b4b2-1bd6b71100e2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.