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
error :
fatal: [testserver2]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to lock apt for exclusive operation"}
Change the playbook as:
- name: APT Update
hosts: webservers
become: True
tasks:
- name: Update apt
apt:
update_cache: yes
cache_valid_time: 3600
and do this on target machine
sudo apt-get clean
sudo apt-get update
this fixed it for me, running it on target machine
本文介绍了一种在Ubuntu系统上使用Ansible更新APT缓存时遇到的问题及解决方案。当Ansible执行更新操作时,可能会遇到APT锁文件导致的任务失败。通过调整Ansible剧本并在目标机器上手动清理和更新APT缓存解决了这一问题。
1442

被折叠的 条评论
为什么被折叠?



