borgbase / ansible-role-borgbackup

Ansible role to set up Borg and Borgmatic
MIT License
221 stars 98 forks source link

allow to installation via os package manager or pip #106

Closed moregeek closed 1 year ago

moregeek commented 1 year ago

This PR allows for using packages provided in the official distribution repository instead of installation via pip. Defaults to pip, no impact on existing role usages.

Example for arch

borgmatic_install_method: package-manager
borg_packages:
  - borgmatic
m3nu commented 1 year ago

Hi and sorry for the delay. I think this is a good change. How about adding this:

moregeek commented 1 year ago

Hi m3nu, no problem.

We already have vars for different OS. How about adding the package names there? So users don't need to look them up? This would replace the borg_packages variable.

I decided against the adding of the package names into the existing variable borg_packages because this would install the packages also when installation method pip is used and would result in installation of the packages via pip and package manager in parallel.

I added a new variable (borg_system_packages) that contains the name of the borg/borgmatic package as provided by the distributions package manager.

A note about the possibility of outdated distribution packages is added in the README.

Let me know if you need further changes.

m3nu commented 1 year ago

Thanks for the changes. I think this makes it a very nice addition.

m3nu commented 1 year ago

How about splitting borg_packages in 2 parts: (not easy to name those)

I also adjusted the tests to run the role with both options.

m3nu commented 1 year ago

I think this needs EPEL on EL-like distros

  TASK [m3nu.ansible_role_borgbackup : Install borgmatic and borg via distribution package manager] ***
  failed: [centos-7] (item=borgbackup) => {"ansible_loop_var": "item", "changed": false, "item": "borgbackup", "msg": "No package matching 'borgbackup' found available, installed or updated", "rc": 126, "results": ["No package matching 'borgbackup' found available, installed or updated"]}
  failed: [almalinux-9] (item=borgbackup) => {"ansible_loop_var": "item", "changed": false, "failures": ["No package borgbackup available."], "item": "borgbackup", "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}
  failed: [almalinux-8] (item=borgbackup) => {"ansible_loop_var": "item", "changed": false, "failures": ["No package borgbackup available."], "item": "borgbackup", "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}
  failed: [centos-7] (item=borgmatic) => {"ansible_loop_var": "item", "changed": false, "item": "borgmatic", "msg": "No package matching 'borgmatic' found available, installed or updated", "rc": 126, "results": ["No package matching 'borgmatic' found available, installed or updated"]}
  failed: [almalinux-9] (item=borgmatic) => {"ansible_loop_var": "item", "changed": false, "failures": ["No package borgmatic available."], "item": "borgmatic", "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}
  failed: [almalinux-8] (item=borgmatic) => {"ansible_loop_var": "item", "changed": false, "failures": ["No package borgmatic available."], "item": "borgmatic", "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}
m3nu commented 1 year ago

Added a check to make sure EPEL is enabled for EL distros. Will make sure the tests fail with this and then add EPEL to the test setup, so it succeeds.

m3nu commented 1 year ago

Packages on EPEL are pretty broken. No point in testing.

So only thing left is to split borg_packages as mentioned above. Point being that compiler and dev libs don't get installed when a distro package is used.

m3nu commented 1 year ago

Went on to make those changes. borg_packgages is now split in:

And we also have

Also renamed a few things to make it more consistent.

moregeek commented 1 year ago

@m3nu Thanks for finishing this PR.