我接手了一个运行在Ansible上的用于服务器配置和管理的项目。我对Ansible相当陌生,但多亏了这些好的文档,我才开始对它感兴趣。但是,我仍然有一个错误,它的输出如下:
失败:build => { "Failed ":true,"item":“software-properties-python”,“python”,"openssh-server","ufw",“ufw”,“无人值守-升级”,"vim","curl","git","ntp","msg":“未能锁定专用操作”}
游戏手册是与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 }发布于 2017-07-24 08:59:21
在提供Ubuntu (可能还有其他发行版)时,这是非常常见的情况。您尝试在后台运行自动更新时运行Ansible (这是在设置新机器之后发生的情况)。当APT使用信号量时,Ansible就会被踢出。
剧本是可以的,最简单的验证方法是稍后运行它(在自动更新过程完成之后)。
为了永久解决问题,你可能想:
发布于 2018-08-19 16:27:50
我刚刚在一个新的VM上遇到了同样的问题。我尝试了许多方法,包括重新尝试apt命令,但最终唯一的方法是删除无人值守的升级。
我在这里使用raw命令,因为此时VM还没有安装Python,所以我需要先安装它,但是我需要一个可靠的apt。
因为它是一个VM,而且我正在通过将它重置为快照来测试剧本,所以系统日期被关闭了,这迫使我使用date -s命令,以便在apt命令期间不会出现apt证书问题。此date -s触发无人值守的升级。
因此,这个剧本片段基本上是与禁用新系统中无人值守的升级相关的部分。它们是我在新系统上发布的第一个命令。
- name: Disable timers for unattended upgrade, so that none will be triggered by the `date -s` call.
raw: systemctl disable --now {{item}}
with_items:
- 'apt-daily.timer'
- 'apt-daily-upgrade.timer'
- name: Reload systemctl daemon to apply the new changes
raw: systemctl daemon-reload
# Syncing time is only relevant for testing, because of the VM's outdated date.
#- name: Sync time
# raw: date -s "{{ lookup('pipe', 'date') }}"
- name: Wait for any possibly running unattended upgrade to finish
raw: systemd-run --property="After=apt-daily.service apt-daily-upgrade.service" --wait /bin/true
- name: Purge unattended upgrades
raw: apt-get -y purge unattended-upgrades
- name: Update apt cache
raw: apt-get -y update
- name: If needed, install Python
raw: test -e /usr/bin/python || apt-get -y install python其他任何东西都会导致apt命令随机失败,因为无人值守的升级会导致锁定问题。
https://stackoverflow.com/questions/45269225
复制相似问题