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.
2
Answers
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
andbecome_method: sudo
As pointed out by hedgie in the comments, the package
xz-utils
needs to be installed for Ansible to install .deb packages via theapt
module. This requirement is described in the official Ansible documentation for the apt module. For thedeb
parameter, it says it takes astring
which is:The solution is, before your
apt:
task, add another task: