From 6f61a0744c82e587248cb4d391217f2b98660906 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 18 Mar 2023 15:38:05 +0100 Subject: [PATCH] apt: with Debian, 12 backports are installed but disabled by default --- CHANGELOG.md | 2 ++ apt/defaults/main.yml | 2 ++ apt/files/bookworm_backports_preferences | 3 +++ apt/tasks/backports.deb822.yml | 9 +-------- apt/tasks/main.yml | 4 ++-- apt/templates/bookworm_backports.sources.j2 | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 apt/files/bookworm_backports_preferences diff --git a/CHANGELOG.md b/CHANGELOG.md index edb6c431..fafbe518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ The **patch** part changes is incremented if multiple releases happen the same m ### Changed +* apt: with Debian 12, backports are installed but disabled by default + ### Fixed ### Removed diff --git a/apt/defaults/main.yml b/apt/defaults/main.yml index 681f1d14..3720d893 100644 --- a/apt/defaults/main.yml +++ b/apt/defaults/main.yml @@ -8,6 +8,8 @@ apt_upgrade: False apt_install_basics: True apt_basics_components: "main" +# With Debian 12+ and the deb822 format of source files +# backports are always installed but enabled according to `apt_install_backports` apt_install_backports: False apt_backports_components: "main" diff --git a/apt/files/bookworm_backports_preferences b/apt/files/bookworm_backports_preferences new file mode 100644 index 00000000..eaf76d52 --- /dev/null +++ b/apt/files/bookworm_backports_preferences @@ -0,0 +1,3 @@ +Package: * +Pin: release a=bookworm-backports +Pin-Priority: 50 diff --git a/apt/tasks/backports.deb822.yml b/apt/tasks/backports.deb822.yml index 8e196cc0..633b9266 100644 --- a/apt/tasks/backports.deb822.yml +++ b/apt/tasks/backports.deb822.yml @@ -1,13 +1,6 @@ --- -- name: No backports config in default sources.list - lineinfile: - dest: /etc/apt/sources.list.d/ - regexp: "backports" - state: absent - tags: - - apt -- name: Backports sources list is installed +- name: Backports deb822 sources list is installed template: src: '{{ ansible_distribution_release }}_backports.sources.j2' dest: /etc/apt/sources.list.d/backports.sources diff --git a/apt/tasks/main.yml b/apt/tasks/main.yml index b72acb63..104756d2 100644 --- a/apt/tasks/main.yml +++ b/apt/tasks/main.yml @@ -46,7 +46,6 @@ - apt_install_basics | bool - ansible_distribution_major_version is version('12', '>=') - - name: Install backports repositories (Debian <12) import_tasks: backports.oneline.yml tags: @@ -55,12 +54,13 @@ - apt_install_backports | bool - ansible_distribution_major_version is version('12', '<') +# With Debian 12+ and the deb822 format of source files +# backports are always installed but enabled according to `apt_install_backports` - name: Install backports repositories (Debian >=12) import_tasks: backports.deb822.yml tags: - apt when: - - apt_install_backports | bool - ansible_distribution_major_version is version('12', '>=') diff --git a/apt/templates/bookworm_backports.sources.j2 b/apt/templates/bookworm_backports.sources.j2 index 5b1b99d1..31ac2f3b 100644 --- a/apt/templates/bookworm_backports.sources.j2 +++ b/apt/templates/bookworm_backports.sources.j2 @@ -4,4 +4,4 @@ Types: deb URIs: http://mirror.evolix.org/debian Suites: bullseye-backports Components: {{ apt_backports_components | mandatory }} -Enabled: yes +Enabled: {{ apt_install_backports | bool | ternary('yes', 'no') }}