# executing the  previleage  adhoc  command

**URL:** <https://forum.ansible.com/t/executing-the-previleage-adhoc-command/27580>\
**Category:** Ansible Project\
**Created:** [May 21, 2018, 3:51pm UTC](https://forum.ansible.com/t/executing-the-previleage-adhoc-command/27580 "2018-05-21T15:51:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanna3k6](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kanna3k6/32/11075_2.png) [@kanna3k6](https://forum.ansible.com/u/kanna3k6)\
**Post date:** [May 21, 2018, 3:51pm UTC](https://forum.ansible.com/t/executing-the-previleage-adhoc-command/27580/1 "2018-05-21T15:51:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [May 21, 2018, 4:22pm UTC](https://forum.ansible.com/t/executing-the-previleage-adhoc-command/27580/2 "2018-05-21T16:22:35Z")

</div>

> 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  
> &nbsp;&nbsp;129 ansible iaf -m shell "/usr/sbin/shutdown -h now" --become  
> &nbsp;&nbsp;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.

> &nbsp;&nbsp;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.

---

<div class="post-metadata">

**Author:** ![kanna3k6](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kanna3k6/32/11075_2.png) [@kanna3k6](https://forum.ansible.com/u/kanna3k6)\
**Post date:** [May 21, 2018, 4:55pm UTC](https://forum.ansible.com/t/executing-the-previleage-adhoc-command/27580/3 "2018-05-21T16:55:16Z")

</div>

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
