我接手了一个使用 Ansible 进行服务器配置和管理的项目。虽然我对 Ansible 还比较陌生,但多亏了好的文档,我正在逐渐了解它。 但是我遇到了一个错误,输出如下:
failed: [build] (item=[u'software-properties-common', u'python-pycurl', u'openssh-server', u'ufw', u'unattended-upgrades', u'vim', u'curl', u'git', u'ntp']) => {"failed": true, "item": ["software-properties-common", "python-pycurl", "openssh-server", "ufw", "unattended-upgrades", "vim", "curl", "git", "ntp"], "msg": "Failed to lock apt for exclusive operation"}
这个 Playbook 是以 sudo: yes
的权限运行的,所以我不明白为什么会出现这个错误(看起来像是权限错误)。有没有办法追踪问题根源呢?
- name: "Install very important packages"
apt: pkg={{ item }} update_cache=yes state=present
with_items:
- software-properties-common # for apt repository management
- python-pycurl # for apt repository management (Ansible support)
- openssh-server
- ufw
- unattended-upgrades
- vim
- curl
- git
- ntp
实战手册:
- hosts: build.url.com
sudo: yes
roles:
- { role: postgresql, tags: postgresql }
- { role: ruby, tags: ruby }
- { role: build, tags: build }
become: true
吗?如果这样不行,可能值得检查一下是否能够手动安装软件包,否则尝试重新启动服务器。这里有一些建议:链接 - Abhishek Balaji R