I'm getting 'msg: Failed to lock apt for exclusive operation' when trying to install some dependencies in a playbook using apt, with the vagrant user. I'm suspecting it tells me this because it can't authenticate the vagrant user while running the task.
This is the role declaration I'm using.
- name: ruby installer
hosts: all
sudo: True
sudo_user: vagrant
roles:
- ruby
And this is the task that fails:
- name: Install ruby building dependencies
apt: name={{ item }}
state=installed
update_cache=yes
with_items:
- dependency
When removing "update_cache=yes" and re-running the playbook I'm getting: E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Obviously when running it with root it works perfectly fine, but I need it to run under a different user other then root because of some ruby (rvm, rbenv specific) tasks.
How do I properly authenticate the vagrant user when running my playbook? Can someone point me in the right direction?