2 things:

1) Ansible requires FULL sudo access, i.e

selvam ALL=(ALL) NOPASSWD: ALL

2) You may also need to allow sudo for this user to not require a tty:

Defaults:selvam !requiretty


On Monday, 21 March 2016 13:24:31 UTC, selvam vasu wrote:
>
> Hi,
> I am newbie to ansible. You can find it easily through this dump question. 
> I have limited access to one user(selvam) which can ran limited commands 
> using sudo option.
> My sudoers file looks like below.
>  
> selvam  ALL=(ALL) NOPASSWD: /usr/sbin/service,/usr/bin/apt-get
>
> I have tried to install apt package in remote machine using ansible 
> playbooks as selvam user with sudo option.
>
> Here is playbook file contents.
>
> playbook.yml
> ---
> - hosts: host1
>   remote_user: selvam
>   tasks:
>     - name: users package
>       apt: name={{ item }} state=latest
>       become: yes
>       with_items:
>         - nginx
>
> But the problem is when i run this playbook, I am getting the error as 
> "Missing become password". I need to install the package with passwordless.
>
> When run this below command manually from my ansible host, it is working 
> fine with passwordless. How can i accomplish the same through ansible 
> playbook.
>
> [selvam@host1] $ ssh host1 sudo -u root apt-get install nginx
>
> Ansible version:
> *******************
>
> $ ansible-playbook --version
> ansible-playbook 1.9.4
>   configured module search path = None
>
> Let me know where I have to  modify my configs. 
>
> Thanks in Advance.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f8602f3a-54ef-4105-b9b0-c1f76366c7ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to