我正在尝试使用 Ansible 在多个远程服务器上安装 Debian 软件包。该包已上传到目标服务器的文件夹中。我使用 apt 模块创建了一个 Ansible 剧本:
- name: Installing Agent
apt:
deb: /home/administrator/ftp/SentinelAgent_linux_v4_4_2_3.deb
在执行过程中出现了以下错误:
TASK [Installing Agent]
***********************************************
fatal: [brw.01.bwt]: FAILED! => {"changed": false, "msg": "Unable to install package: E:Invalid archive member header"}
在不同的服务器上,我能够使用 dpkg 命令手动安装包,这告诉我 .deb 文件没有问题。
如能提供有关此剧本为何不起作用的任何线索,我们将不胜感激。我在 Ubuntu 20.04.1 虚拟机中使用 Ansible 版本 2.9.6。
最佳答案
正如 hedgie 在评论中指出的那样,Ansible 需要安装包 xz-utils
才能通过 apt
模块安装 .deb 包。 official Ansible documentation for the apt module 中描述了此要求.对于 deb
参数,它说它需要一个 string
,它是:
Path to a .deb package on the remote machine. If :// in the path, ansible will attempt to download deb before installing. (Version added 2.1) Requires the xz-utils package to extract the control file of the deb package to install.
解决方案是,在您的apt:
任务之前,添加另一个任务:
- name: Install prerequisites for Ansible to install .deb via apt module
apt:
name:
- xz-utils
关于ansible - 使用 Ansible 安装 Debian 软件包 (.deb) 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65586673/