I am trying to install a deb package on a remote server using ansible, using the following construction
- name: Install debdelegate_to: app1apt:deb: https://example.com/deb/package.deb
or
- name: Install debdelegate_to: app1apt:deb: /path/to/deb
playbook works, says that everything is ok, but in fact the package is not installed, if you connect to a remote server and manually run apt install /path/to/deb
, then the package is installed. I tried to copy deb to the server using ansible and install it by downloading the package from an Internet resource, the result is always the same
Best Answer
You have to use the privilege escalation methods become
and become_method: sudo
for Ansible. Installing a package need sudo
privilege.
- name: Install debdelegate_to: app1apt:deb: /path/to/debbecome: true
The following modification of the task helped
- name: Install debcommand: apt install /path/to/package.deb -y --allow-downgrades
The allow_downgrade directive for the apt module appeared, starting with the ansible 2.12 version in my 2.9 it did not work, as the force directive did not work, I had to implement the task using a not very nice method.