From 8c12e02c53d23ef61ed4c63154b4e7d533fa4a92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de>
Date: Mon, 13 Jan 2025 16:46:57 +0100
Subject: [PATCH] fix: use correct release codename for Ubuntu targets when
 adding repositories

---
 tasks/configure_package_repositories.yml | 42 +++++++++++++++---------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/tasks/configure_package_repositories.yml b/tasks/configure_package_repositories.yml
index 5f2b0b4..b35dc16 100644
--- a/tasks/configure_package_repositories.yml
+++ b/tasks/configure_package_repositories.yml
@@ -23,21 +23,33 @@
         - "/etc/apt/keyrings/slub-sdvdebianrepo-key.asc"
         - "/etc/apt/sources.list.d/slub.list"
 
-    - name: add custom repo for SLUB's custom Debian repo
-      ansible.builtin.deb822_repository:
-        architectures: "amd64"
-        components: "main"
-        enabled: true
-        name: "slub"
-        pdiffs: true
-        signed_by: "{{ vault_debrepo_url }}deb-repository/pub.gpg.key"
-        suites: "{{ ansible_lsb.codename }}"
-        uris: "{{ vault_debrepo_url }}deb-repository"
-      notify: update package cache
-    - name: >
-        Flush handlers (we can't wait for the handler to fire if we want to
-        install packages from the newly configured repo)
-      ansible.builtin.meta: flush_handlers
+    - name: Configure additional repos for Debian-based repos.
+      when: ansible_os_family == "Debian"
+      block:
+        - name: >
+            Set Mapping for Debian- and Ubuntu-Releasenames. This is necessary,
+            because SLUB's Debian repo server doesn't support Ubuntu releases
+            (yet?). Whenever this restriction is removed, then we can remove
+            the mapping as well.
+          ansible.builtin.set_fact:
+            releasenames:
+              jammy: "bookworm"
+              # noble: "?????????"
+        - name: add custom repo for SLUB's custom Debian repo
+          ansible.builtin.deb822_repository:
+            architectures: "amd64"
+            components: "main"
+            enabled: true
+            name: "slub"
+            pdiffs: true
+            signed_by: "{{ vault_debrepo_url }}deb-repository/pub.gpg.key"
+            suites: "{{ ( ansible_distribution == 'Ubuntu' ) | ternary( releasenames[ansible_lsb.codename], ansible_lsb.codename ) }}"
+            uris: "{{ vault_debrepo_url }}deb-repository"
+          notify: update package cache
+        - name: >
+            Flush handlers (we can't wait for the handler to fire if we want to
+            install packages from the newly configured repo)
+          ansible.builtin.meta: flush_handlers
 
 - name: configure RHEL repositories
   when:
-- 
GitLab