Ansible 1.9.4 : Failed to lock apt for exclusive operation
ansible apt
ansible python-apt
ansible apt example
ansible apt pin
failed to update apt cache
ansible apt fix broken
ansible apt allow-unauthenticated
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?
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.
"Failed to lock apt for exclusive operation" when running playbook , SUMMARY "Failed to lock apt for exclusive operation" when running ansible 2.8.1 config file = /etc/ansible/ansible.cfg configured module It looks like apt is locked (msg: Failed to lock apt for exclusive operation) meaning it got stuck in some other operation. Can you restart the server, or look here for more ideas? ansible/ansible#4355. You also need to make sure you use sudo or run the playbook as root so it can use apt.
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
Ansible 1.9.4 : Failed to lock apt for exclusive operation, 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: Module Repo Information. Hi! Thanks very much for your interest in Ansible. It sincerely means a lot to us. This appears to be a submission about a module, and aside from action_plugins, if you know what those are, the modules
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
Failed to lock apt for exclusive operation - bedrock, Hello, I have been facing some issue and i got throw it but i got stuck on the error below once it complaing i didnt get well. I believe it is a user [ansible-project] Failed to lock apt for exclusive operation George James Sat, 18 Apr 2020 05:05:13 -0700 I create a new user using ansible called `nginx`, `nginx` is part of the sudo group a, but when I try to do an apt install with this user I get the below error
The answer from @guaka was entirely correct for me. It lacks only one thing-- where to put become: yes
.
In the following, there are three places the become
might go. Only one of them is correct:
- name: setup nginx web server #1 become: yes include_role: name: nginx #2 become: yes vars: ansible_user: "{{ devops_ssh_user }}" #3 become: yes
In position #2 you will get an unexpected parameter error, because become
is not a parameter for the include_role
module.
In position #3 the play will run, but will not execute as sudo.
Only in position #1 does become: yes
do any good. become
is a parameter for the task, not for the module. It is not a variable like ansible_user
. Just to be clear, here's a working configuration:
- name: setup nginx web server become: yes include_role: name: nginx vars: ansible_user: "{{ devops_ssh_user }}"
Ansible - Failed to lock apt for exclusive operation, Сегодня ansible обновился с 1.9.4 до 2.0.0.2 При этом перестал работать с vagrant По ssh на него заходит, но при попытке sudo пишет "Failed to lock apt Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
On my hosts file, I have some hosts that use a different user for sudo
than the one Ansible uses for SSH so I had ansible_user
and ansible_become_user
specified for every host in the inventory.
In those hosts where ansible_user
== ansible_become_user
I got Failed to lock apt for exclusive operation
.
The solution for me was to remove ansible_become_user
line for those cases where the user is the same in both parameters.
Ansible 2 сломал sudo после обновления?, Today ansible has been updated from 1.9.4 to 2.0.0.2 This has stopped working with vagrant Ssh "Failed to lock apt for exclusive operation" well, in fact, ansible discussed https://github.com/ansible/ansible/issues/4355. You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
Vagrant - Ansible 2 broke sudo after upgrade?, https://github.com/ansible/ansible/issues/28991 apt module does not update cache Failed to lock apt for exclusive operation when /var/lib/apt/lists does not exist. and copy: can't locate their input files - 2.0.1.0 paths changed from 1.9.4 I have 2 instacies of the ansible and I run command: ansible all -i hosts -m apt -a "upgrade=yes" -u phudec -K I have tried all variotions witk arguments K, k, u,U. version: 1.7 result: Failed to lock apt for exclusive operation. version: 1.5.4 (release1.5.4 f1f6382) result: OK. The same control machine, the same command, the same hosts to update.
1. https://github.com/ansible/ansible/blob/devel/lib/ansible/modules , Ansible 1.9.4 : Failed to lock apt for exclusive operation; How to install PANDAseq in cygwin using apt-cyp? Error: apt-get install msodbcsql Job submit by Ansible Tower by got this "msg: Failed to lock apt for exclusive operation" #10604 sukenneth opened this issue Apr 2, 2015 · 3 comments Labels
apt by thoughtbot, [ansible-project] msg: Failed to lock apt for exclusive operation - apt: update_cache=yes [ansible-project] 'copy' operation on remote host? [ansible-project] Ansible copy module takes lot of time on same machine [ansible-project] ansible code reuse in roles [ansible-project] Ansible - Advanced shell command execution syntax
Comments
Failed to lock apt for exclusive operation
occurs due to permission issues. since you are usingbecome
, it should not occur. trysudo: True
in your playbook. orbecome_method = 'sudo'
- Thanks Frank, yes, I am designating ROOT as connection user in my inventory file, and become: yes should have been enough. Using the old style (sudo:yes) does not help. Trying some of these tips:
- please include the command (yml) and the full error (run ansible or ansible-playbook with
-vvvv
). - The command and all details are in the github link in the original question. thanks.
- Could you please add why this sequence of commands solves the OP's problem?
- I totally fail to understand why this was downvoted. In my case it was a similar issue ( see e.g. 1 or 2 ), and one would obviously have to investigate the
apt
locks in order to figure that out.