1

I've been trying to build my Vagrant configuration on Atlas. Also I'm using ansible for provisioning and i have some sudo issues.

After setting up VM while trying to run ansible playbook on Atlas I get this error:

virtualbox-iso: failed: [127.0.0.1] => {"failed": true, "item": ""}
virtualbox-iso: msg: Failed to lock apt for exclusive operation

So I've found on internet that sudo permissions may be the issue. In my main playbook file permissions are set to:

sudo: true
remote_user: vagrant

And the whole thing breakes righ after running playbook, when I need sudo permission, on this cmd in playbook:

-name: Update apt
sudo: yes
apt: update_cache=yes

Does anyone know how to resolve this situation ? How do I fix sudo permissions on ansible ?

NOTE. When I'm trying to build this machine locally it works like a charm but when I run it on Atlas I get the issue.

UPDATE: I believe that sudo access is real issue here I've removed that part of config and it keeps failing on other parts that require sudo.

virtualbox-iso: failed: [127.0.0.1] => (item=curl,wget,python-software-  properties) => {"failed": true, "item": "curl,wget,python-software-properties"}
 virtualbox-iso: stderr: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
virtualbox-iso: E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
toplomj3r
  • 111
  • 3

1 Answers1

1

Failed to lock apt for exclusive operation means that some other application is holding the apt lock. Maybe there is some other install process running on the system?

Check ps aux | grep apt output for suspicious processes.

The error message could also be caused by insufficient privileges. You might want to check if the Ansible user gets full root access via sudo. To check that open the sudoers on the host with visudo. You should have a line like

ansible_user ALL=(ALL) NOPASSWD: ALL

Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39