# sudo permissions with apt module

**URL:** <https://forum.ansible.com/t/sudo-permissions-with-apt-module/20870>\
**Category:** Ansible Project\
**Created:** [March 15, 2016, 9:28am UTC](https://forum.ansible.com/t/sudo-permissions-with-apt-module/20870 "2016-03-15T09:28:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rishabh\_Goyal](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Rishabh\_Goyal](https://forum.ansible.com/u/Rishabh_Goyal)\
**Post date:** [March 15, 2016, 9:28am UTC](https://forum.ansible.com/t/sudo-permissions-with-apt-module/20870/1 "2016-03-15T09:28:44Z")

</div>

Hi,

I am trying to use apt module for installing multiple packages on my remote host. My user is not in sudoers list. However, I do have permissions to run following commands on remote host

sudo apt-get update  
sudo apt-get install top

Now when I am trying to achieve same using ansible playbook, I am getting following error -

**FAILED! =\> {“failed”: true, “msg”: “Missing sudo password”}**

Following is my task definition

- name: install basic packages  
apt: name={{item}} update\_cache=yes  
become: yes  
become\_method: sudo  
with\_items:
- tree
- nload
- htop

I have tried removing **become** and **become\_method.** Then I am getting standard dpkg lock error with -vvv flag -  
Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n

What could be potential issue here ?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 19, 2016, 3:31am UTC](https://forum.ansible.com/t/sudo-permissions-with-apt-module/20870/2 "2016-03-19T03:31:42Z")

</div>

ansible is not using those commands and will not work with restricted sudo in that way, it needs full sudo to accomplish these tasks. Most of the work of the apt module is using the apt-python API.

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [March 19, 2016, 11:24am UTC](https://forum.ansible.com/t/sudo-permissions-with-apt-module/20870/3 "2016-03-19T11:24:20Z")

</div>

So either change your permissions on the system or use the shell or  
command modules instead of the apt module. I would go for the first one...

Regards,  
Johannes
