ansible - 使用 Ansible 安装 Debian 软件包 (.deb) 时出现问题

标签 ansible ansible-2.x

我正在尝试使用 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/

相关文章:

linux - 将 rsa token 复制到组内的远程主机

ansible - 如何拥有详细的 ansible 日志并保持控制台输出非详细?

ansible - 如何解决模板运行时错误: no test named 'equalto' in Ansible?

mysql - 无法连接为使用 Ansible 创建的 MySQL 用户

jinja2 - 检查变量是否在 Ansible 字典中的列表中

macos - Ansible 2.3 无法通过 SSH 连接到 Mac OS X 上的 AWS 实例 - 权限被拒绝

python - 从另一个 Ansible 模块调用一个 Ansible 模块?

ansible - Ansible 中的条件角色包含失败

ansible - 使用 Ansible 检查 HTTP 资源的最佳方法是什么?

linux - Ansible将两个不同的文件变量调用到单个任务中循环遍历多个文件