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

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 :

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