Files
ansible-pull/roles/apt_repos/defaults/main.yml
T
rene 97c64189c5 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.
2026-10-23 09:13:42 +02:00

25 lines
1.5 KiB
YAML
Executable File

---
# Standardwerte für roles/apt_repos/tasks/add.yml
#
# Erwartete Variable: apt_repo (dict)
# name (Pflicht) Repo-Name (deb822: X-Repolib-Name und Dateiname)
# uris (Pflicht) Basis-URL des Repositories
# suites (Pflicht) Suite/Codename oder Pfad (Pfad muss auf "/" enden)
# components (optional) Liste der Komponenten (bei Pfad-Suite weglassen)
# types (optional) [deb] (Default) oder [deb, deb-src]
# signed_by (optional) Pfad zum Keyring
# architectures (optional) Liste der Architekturen
# mode (optional) Dateimodus, Default "0644"
# legacy_file (optional) Dateiname der alten .list, Default: name
# notify (optional) Handler, Default: apt_update
apt_repo_types: "{{ apt_repo.types | default(['deb']) }}"
apt_repo_legacy_file: "{{ apt_repo.legacy_file | default(apt_repo.name) }}"
apt_repo_notify: "{{ apt_repo.notify | default('apt_update') }}"
apt_repo_arch_option: "{{ ('arch=' ~ (apt_repo.architectures | join(','))) if apt_repo.architectures is defined else '' }}"
apt_repo_signed_option: "{{ ('signed-by=' ~ apt_repo.signed_by) if apt_repo.signed_by is defined else '' }}"
apt_repo_legacy_options: "{{ (apt_repo_arch_option ~ ' ' ~ apt_repo_signed_option) | trim }}"
apt_repo_legacy_suffix: >-
{{ (' [' ~ apt_repo_legacy_options ~ ']') if apt_repo_legacy_options else '' }}
{{ apt_repo.uris }} {{ apt_repo.suites }}{{ (' ' ~ (apt_repo.components | join(' '))) if apt_repo.components is defined else '' }}