From 9a77705f28a049d41afd9c3fc8fe31a3a8206e5a Mon Sep 17 00:00:00 2001 From: Dirk Sarpe Date: Fri, 26 May 2023 11:50:50 +0200 Subject: [PATCH] use backports on debian 11 for package install --- defaults/main.yml | 1 + tasks/noauto_install_package.yml | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 02e0a65..77f71c7 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -23,6 +23,7 @@ borgmatic_timer_hour: "{{ range(0, 5) | random(seed=inventory_hostname) }}" borgmatic_timer_minute: "{{ range(0, 59) | random(seed=inventory_hostname) }}" borg_install_method: "pip" borg_require_epel: "{{ ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' }}" +borg_require_backports: "{{ ansible_distribution == 'Debian' and ansible_distribution_major_version == '11' }}" borgmatic_config_name: config.yaml borgmatic_hooks: diff --git a/tasks/noauto_install_package.yml b/tasks/noauto_install_package.yml index 5f28a58..21b1eb6 100644 --- a/tasks/noauto_install_package.yml +++ b/tasks/noauto_install_package.yml @@ -13,9 +13,17 @@ - "'epel-release' in ansible_facts.packages" fail_msg: Need EPEL repo to install via distro package. + - name: Check if backports repo is enabled, if installation from distro is requested + when: borg_require_backports + ansible.builtin.apt_repository: + repo: "deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports main" + state: present + register: __borg_require_backports + - name: Install borgmatic and borg via distribution package manager ansible.builtin.package: name: "{{ item }}" - state: present + state: "{{ __borg_require_backports.changed | ternary('latest', 'present') }}" + default_release: "{{ borg_require_backports | ternary(ansible_distribution_release + '-backports', omit) }}" loop: "{{ borg_distro_packages }}" ...