Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible 1.9.4 : Failed to lock apt for exclusive operation

Tags:

ansible

I bumped into Failed to lock apt for exclusive operation issue: https://github.com/geerlingguy/ansible-role-apache/issues/50

I posted a lot of details in GitHub.

I googled a lot of "Failed to lock apt for exclusive operation" Ansible complaints, but no simple answer. Any help?

like image 706
Hristo Stoyanov Avatar asked Nov 06 '15 09:11

Hristo Stoyanov


Video Answer


3 Answers

I'm also getting this error, while setting up a couple of new boxes. I'm connecting as root, so I didn't think it was necessary, but it is:

become: yes

Now everything works as intended.

like image 87
kqw Avatar answered Oct 06 '22 19:10

kqw


Running the following commands in the same sequence as below should resolve this issue :

sudo rm -rf /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get update
like image 7
Digvijay Sinha Avatar answered Oct 06 '22 18:10

Digvijay Sinha


I know this question has been answered a long time ago, but for me, the solution was different. The problem was the update_cache step. I had this with every install step, and somehow that caused the "apt failed lock error". the solution was adding the update_cache as a seperate step, like so:

- tasks:
  - name: update apt list
    apt:
      update_cache: yes
like image 12
swvo Avatar answered Oct 06 '22 18:10

swvo