Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems installing a Debian package (.deb) using Ansible

I'm trying to install a Debian package in several remote servers using Ansible. The package has been uploaded in a folder in the target server. I created an Ansible playbook using the apt module:

- name: Installing Agent
  apt:
    deb: /home/administrator/ftp/SentinelAgent_linux_v4_4_2_3.deb

During execution I got the following error:

TASK [Installing Agent]
***********************************************
fatal: [brw.01.bwt]: FAILED! => {"changed": false, "msg": "Unable to install package: E:Invalid archive member header"}

In a different server, I was able to install the package manually using the dpkg command, that tells me there is nothing wrong with the .deb file.

Any clue on why this playbook isn't working would be appreciated. I'm using Ansible version 2.9.6 in an Ubuntu 20.04.1 Virtual Machine.

like image 276
olg32 Avatar asked Apr 21 '26 19:04

olg32


1 Answers

As pointed out by hedgie in the comments, the package xz-utils needs to be installed for Ansible to install .deb packages via the apt module. This requirement is described in the official Ansible documentation for the apt module. For the deb parameter, it says it takes a string which is:

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.

The solution is, before your apt: task, add another task:

- name: Install prerequisites for Ansible to install .deb via apt module
  apt:
    name:
    - xz-utils
like image 163
bitinerant Avatar answered Apr 26 '26 01:04

bitinerant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!