Tag Archives: apt-error

Ansible Failed – apt lock

Environment

  • On Ubuntu 16.04/Ubuntu 14.04
  • Ansible 2.3.2.0

updateApt.yml

- name: APT Update
  hosts: webservers
  become: True
  tasks:
    - name: Update apt
      apt:
        update_cache: yes

错误:

fatal: [testserver2]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to lock apt for exclusive operation"}
- name: APT Update hosts: webservers become: True tasks: - name: Update apt apt: update_cache: yes cache_valid_time: 3600

,并在目标机上执行此操作

sudo apt-get clean 
sudo apt-get update

这为我解决了它,运行它在目标机器上