apt: use deb822_repository only on ansible-core >= 2.15

ansible.builtin.deb822_repository was added in ansible-core 2.15. Hosts
running an older ansible-core cannot use it at all, so gate the choice of
module on the runtime version.

Introduce the shared role apt_repos (tasks_from: add) which takes a
single structured apt_repo dict and:
- uses deb822_repository when ansible_version.full >= 2.15 and removes
  the legacy .list file,
- falls back to apt_repository (still available before its removal in
  2.25) and builds the equivalent 'deb [opts] uri suite components' line
  otherwise.

All six repository definitions now go through the role, keeping the
deb822 and legacy representations in sync from one source of truth. The
backup role's repository task keeps its tags via apply, and its tailscale
install updates the apt cache explicitly since the previously notified
'update apt cache' handler does not exist.
This commit is contained in:
rene committed 2026-10-23 09:13:42 +02:00
1 parent 83e6accdc1
commit 97c64189c5
7 files changed
+159 -104

No files matched your search

+14 -16
View File
@@ -31,23 +31,21 @@
creates: /usr/share/keyrings/mongodb-archive-keyring.gpg
# Hinweis: Der Pfad /usr/share/keyrings/ ist der empfohlene Ort für Schlüssel, die mit 'signed-by' verwendet werden.
- name: Remove legacy MongoDB repository file
ansible.builtin.file:
path: "/etc/apt/sources.list.d/mongodb-org-{{ omada_controller_mongodb_version }}.list"
state: absent
- name: Add MongoDB repository
ansible.builtin.deb822_repository:
name: "mongodb-org-{{ omada_controller_mongodb_version }}"
types: deb
uris: "https://repo.mongodb.org/apt/debian"
suites: "{{ omada_controller_mongodb_repo_release }}/mongodb-org/{{ omada_controller_mongodb_version }}"
components:
- main
architectures:
- amd64
- arm64
signed_by: /usr/share/keyrings/mongodb-archive-keyring.gpg
include_role:
name: apt_repos
tasks_from: add
vars:
apt_repo:
name: "mongodb-org-{{ omada_controller_mongodb_version }}"
uris: "https://repo.mongodb.org/apt/debian"
suites: "{{ omada_controller_mongodb_repo_release }}/mongodb-org/{{ omada_controller_mongodb_version }}"
components:
- main
architectures:
- amd64
- arm64
signed_by: /usr/share/keyrings/mongodb-archive-keyring.gpg
# Der 'signed-by'-Parameter verweist auf den zuvor dearmored Schlüssel.
- name: Install MongoDB server