executing the previleage adhoc command

10 views
Skip to first unread message

Kannappan M

unread,
May 21, 2018, 11:51:08 AM5/21/18
to Ansible Project
Hi Team, 

When i  try  to shutdown the connected  node  using  ansible  am  getting the  below  error  kindly   assist

128  ansible iaf -m shell "/usr/sbin/shutdown -h now" -b
  129  ansible iaf -m shell "/usr/sbin/shutdown -h now" --become
  130  ansible iaf -m shell '/usr/sbin/shutdown -h now' --become
 154  ansible iaf -a "/usr/sbin/shutdown -h now" --become
  155  ansible iaf -a "sudo /usr/sbin/shutdown -h now"


for the  155  command  am  getting  message  as  user  is  not in the sudoers  list

but  i  have  already  made  an  entry  in sudoers  file  and  also  added  to  wheel  group

cat /etc/group |grep wheel
wheel:x:10:tester

tester ALL=NOPASSWD: ALL




Kai Stian Olstad

unread,
May 21, 2018, 12:22:50 PM5/21/18
to ansible...@googlegroups.com
On 21.05.2018 17:51, Kannappan M wrote:
> When i try to shutdown the connected node using ansible am
> getting
> the below error kindly assist
>
> 128 ansible iaf -m shell "/usr/sbin/shutdown -h now" -b
> 129 ansible iaf -m shell "/usr/sbin/shutdown -h now" --become
> 130 ansible iaf -m shell '/usr/sbin/shutdown -h now' --become

None of these are valid, they are missing -a, and Ansible should write
an error message.


> 154 ansible iaf -a "/usr/sbin/shutdown -h now" --become

This one has the correct syntax.


> 155 ansible iaf -a "sudo /usr/sbin/shutdown -h now"

This should work, but I would recommend the previous one.


> for the 155 command am getting message as user is not in the
> sudoers list
>
> but i have already made an entry in sudoers file and also
> added
> to wheel group
>
> cat /etc/group |grep wheel
> wheel:x:10:tester
>
> tester ALL=NOPASSWD: ALL

Does sudo work when you login manually and test?
Are you sure you are using the user tester in Ansible?

And you need to run ansible with -vvvv to get some more verbose output
about what is happing.

--
Kai Stian Olstad

Kannappan M

unread,
May 21, 2018, 12:55:55 PM5/21/18
to ansible...@googlegroups.com
Hi Kai,

Please  find the o/p  below


[tester@ansi root]$ ansible iaf -a "sudo /usr/sbin/shutdown -h now" ^C
[tester@ansi root]$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                RkK5xV-p9HC-Em5C-8Ryx-8dVU-Pp9i-Uj1WvB
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-05-18 02:03:44 +0530
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                1KyJY9-BLjP-HvbH-GjgH-UTNA-9qvS-deTXGq
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-05-18 02:03:44 +0530
  LV Status              available
  # open                 1
  LV Size                <17.47 GiB
  Current LE             4472
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0


Regards
Kannappan M
 

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/CdO9kvdvTIg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@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/eca14ede-e0e4-44bd-819f-8825991953ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages