# Ansible 2.1.0: "Interactive authentication required." when operating with sudo ?

**URL:** <https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936>\
**Category:** Ansible Project\
**Created:** [March 20, 2016, 8:11pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936 "2016-03-20T20:11:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![TJG](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@TJG](https://forum.ansible.com/u/TJG)\
**Post date:** [March 20, 2016, 8:11pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/1 "2016-03-20T20:11:27Z")

</div>

Hi all;

Just looking for a little help to spot what I might be missing. Against a Centos 7 box, using Ansible 2.1.0, this task:

`

- name: restart httpd  
service:  
name: httpd  
state: restarted

`

is giving me an “Interactive authentication required.” error when run under Ansible 2.1.0 via:

`  
ansible-playbook -i inventory test.yml --sudo --ask-sudo-pass --ask-become-pass --sudo -vvvv

`

My playbook is set with:

`

# The user that logs into the machine

remote\_user: apps

# Indicates that we also want to be become the user we log in as, for running tasks

# (otherwise the user defaults to root)

become: yes  
become\_user: apps  
`

and on the Centos 7 box, my “apps” user is in the “wheel” group, and the wheel group is covered with sudoer permissions as follows:

`

## Allows people in group wheel to run all commands

%wheel ALL=(ALL) ALL

## Same thing without a password

%wheel ALL=(ALL) NOPASSWD: ALL

`

I understood that with my playbook set to use “become”, and “become\_user”, that this task would run as sudo?

So, why the “Interactive authentication required” error?

Of course, I can resort to:

`

- name: Restart apache  
shell: sudo systemctl restart httpd

`

which doesn’t prompt me, but I’d like to understand why the advocated method isn’t observing that I’m running under sudo?

Many thanks,  
Tim

---

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [March 20, 2016, 9:31pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/2 "2016-03-20T21:31:08Z")

</div>

comment out

#%wheel ALL=(ALL) ALL

## Same thing without a password  
%wheel ALL=(ALL) NOPASSWD: ALL

---

<div class="post-metadata">

**Author:** ![TJG](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@TJG](https://forum.ansible.com/u/TJG)\
**Post date:** [March 20, 2016, 11:37pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/3 "2016-03-20T23:37:30Z")

</div>

Hi John;

Thanks for the suggestion, but nope: with that line commented out in sudoers (so that only the one with NOPASSWD is in effect", the error is the same.

“Failed to stop httpd.service: Interactive authentication required.”

Besides, I’d have thought that the latter statement would have overridden the former statement anyways, in a top-to-bottom processing.

So, still scratching my head…

Tim

---

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [March 21, 2016, 2:34am UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/4 "2016-03-21T02:34:13Z")

</div>

What happens when you run the command as that user? If it still asks for a password either your sudoers file is an issue or user/group might be.

---

<div class="post-metadata">

**Author:** ![Tim\_Griffin](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@Tim\_Griffin](https://forum.ansible.com/u/Tim_Griffin)\
**Post date:** [March 21, 2016, 2:54am UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/5 "2016-03-21T02:54:34Z")

</div>

Hi John,

I very much appreciate your attention.

When I run “sudo systemctl restart httpd” directly, when logged in as my ‘apps’ user, I am not prompted for a password.

Bizarre, eh?

My guess is my httpd configuration… perhaps how Ansible is telling it to restart or how it’s choosing to restart. I’ll play with its service config and report back.

Tim

---

<div class="post-metadata">

**Author:** ![Uditha\_Desilva](https://avatars.discourse-cdn.com/v4/letter/u/f475e1/32.png) [@Uditha\_Desilva](https://forum.ansible.com/u/Uditha_Desilva)\
**Post date:** [March 23, 2016, 11:49am UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/6 "2016-03-23T11:49:12Z")

</div>

Try adding

Defaults:username !requiretty

to /etc/sudoers.

---

<div class="post-metadata">

**Author:** ![Deepak\_Raj](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@Deepak\_Raj](https://forum.ansible.com/u/Deepak_Raj)\
**Post date:** [August 18, 2016, 9:54am UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/7 "2016-08-18T09:54:18Z")

</div>

Hi Tim,

I am a newbee to Ansible and I am facing the same problem. Did you resolve this?

Regards  
Deepak

---

<div class="post-metadata">

**Author:** ![Tim\_Griffin](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@Tim\_Griffin](https://forum.ansible.com/u/Tim_Griffin)\
**Post date:** [August 18, 2016, 4:47pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/8 "2016-08-18T16:47:47Z")

</div>

No, Sorry Deepak; I was also working on RHEL SELinux and that environment, I’m sure was complicating things. I had to abandon my efforts with Ansible.

T

---

<div class="post-metadata">

**Author:** ![Kavita\_Goel](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@Kavita\_Goel](https://forum.ansible.com/u/Kavita_Goel)\
**Post date:** [June 15, 2017, 2:28pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/9 "2017-06-15T14:28:05Z")

</div>

Deepak, its already been a year. But I ran into this issue. Adding the following lines resoved:

FAILED:

- name: PostgreSQL service stop  
service:

name: postgresql-9.5  
state: stopped

RESOLVED:

- name: PostgreSQL service stop  
sudo: yes  
sudo\_user: root  
service:  
name: postgresql-9.5  
state: stopped

---

<div class="post-metadata">

**Author:** ![middlewareinventory](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@middlewareinventory](https://forum.ansible.com/u/middlewareinventory)\
**Post date:** [July 10, 2018, 10:38pm UTC](https://forum.ansible.com/t/ansible-2-1-0-interactive-authentication-required-when-operating-with-sudo/20936/10 "2018-07-10T22:38:06Z")

</div>

adding a become and become\_user in the playbook has resolved our issue.

handlers:

- name: restart apache  
become: yes  
become\_user: root  
service: name=httpd state=restarted
