就我而言,ansible 是“永远挂起”,因为 apt-get 试图问我一个问题!我是怎么想出来的?我去了目标服务器并运行ps -aef | grep apt
,然后kill
执行了适当的“卡住”apt-get
命令。
在我这样做之后,我的 ansible playbook 立即恢复了活力并报告(提供了ansible-playbook -vvv
选项):
" ==> Deleted (by you or by a script) since installation.",
" ==> Package distributor has shipped an updated version.",
" What would you like to do about it ? Your options are:",
" Y or I : install the package maintainer's version",
" N or O : keep your currently-installed version",
" D : show the differences between the versions",
" Z : start a shell to examine the situation",
" The default action is to keep your current version.",
"*** buildinfo.txt (Y/I/N/O/D/Z) [default=N] ? "
在阅读了有用的诊断输出后,我立即意识到我需要一些适当的 dpkg 选项(例如,参见这篇 devops 帖子)。就我而言,我选择了:
apt:
name: '{{ item }}'
state: latest
update_cache: yes
# Force apt to always update to the newer config files in the package:
dpkg_options: 'force-overwrite,force-confnew'
loop: '{{ my_packages }}'
另外,不要忘记在您终止 ansible 会话后进行清理,否则您的安装仍然可能会失败:
sudo dpkg --configure -a