3

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.

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
olg32
  • 305
  • 2
  • 6
  • 19

2 Answers2

3

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
Zeitounator
  • 38,476
  • 7
  • 53
  • 66
bitinerant
  • 1,168
  • 7
  • 24
  • 1
    Yes, xz-utils is pre-installed in all the servers. $ apt -qq list xz-utils xz-utils/bionic,now 5.2.2-1.3 amd64 [installed] However I'm still getting the "invalid archive member header" – olg32 Jan 06 '21 at 16:37
0

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

  • There is an apt module made just for that that will manage idempotency for you. Why would you use shell in this case? – Zeitounator Jan 06 '21 at 06:46
  • I tested your suggestion using shell and it works! But as Zeitounator said, the rule of thumb on Ansible scripting would be using modules created for specific tasks first and use the generic shell module if there is no alternative, so I'd try to see if I can manage to make the apt module work. Thanks. – olg32 Jan 06 '21 at 17:13