olg32
olg32

Reputation: 345

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.

Upvotes: 3

Views: 6895

Answers (2)

bitinerant
bitinerant

Reputation: 1561

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

Upvotes: 4

hatem ben tayeb
hatem ben tayeb

Reputation: 49

I recommend using the shell module and exute dpkg -i Make sure to copy the deb file before you execute the shell Make sure to grand root access with become: yes and become_method: sudo

Upvotes: 0

Related Questions