Monday, January 3, 2022

[SOLVED] Is it possible to manage at the same time in playbook APK and APT packages managers in Ansible?

Issue

I managed to create playbooks to backup an existing running Wordpress server by installing a VM backup server on Debian, so using APT package manager in Ansible.

Now I would like to be able to use the same playbooks but for installing at the same time the backup on an Alpine linux server.

Is there a more generic way than using APT or APK modules ? If not what would you recommend me ?

Regards, FB


Solution

Yes, and it's called package module, check https://docs.ansible.com/ansible/2.9/modules/package_module.html

Package names, however, might be different from distro to distro, and you still will have to provide distro-specific instructions. Quoting doc:

Package names also vary with package manager; this module will not "translate" them per distro. For example libyaml-dev, libyaml-devel.

The usual way to avoid it is to create distro-specific subtasks for different os families, or distro-specific variables, which are included with some condition.



Answered By - Andrew