# apt module fails with non-root sudoer ("Permission denied")

**URL:** <https://forum.ansible.com/t/apt-module-fails-with-non-root-sudoer-permission-denied/19515>\
**Category:** Ansible Project\
**Created:** [October 15, 2015, 3:45pm UTC](https://forum.ansible.com/t/apt-module-fails-with-non-root-sudoer-permission-denied/19515 "2015-10-15T15:45:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Jaquier](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@Kevin\_Jaquier](https://forum.ansible.com/u/Kevin_Jaquier)\
**Post date:** [October 15, 2015, 3:45pm UTC](https://forum.ansible.com/t/apt-module-fails-with-non-root-sudoer-permission-denied/19515/1 "2015-10-15T15:45:34Z")

</div>

I’m having trouble executing my script from a user with sudo access instead of root.

I’m getting “permission denied” errors when playing the playbook, but if I execute the commands manually on the server it works just fine.  
I did use “become” to execute the tasks with sudo and the right user.

The (relevant part of the) playbook :

---

<div class="post-metadata">

**Author:** ![Markus\_Ellers](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Markus\_Ellers](https://forum.ansible.com/u/Markus_Ellers)\
**Post date:** [October 15, 2015, 9:35pm UTC](https://forum.ansible.com/t/apt-module-fails-with-non-root-sudoer-permission-denied/19515/2 "2015-10-15T21:35:04Z")

</div>

I think this way you are telling ansible to use sudo to execute the apt command as {{ user }}  
But you need it to become {{ user }} and the use sudo to execute the apt command as root.

To do this in ansible you can tell ansible to use sudo per task and use the become for the play and then use sudo to root on the task

Try
