From 4f7da3ae5d51f3e04ca41f464987efd4ebcca7f5 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 17 Jul 2026 18:24:14 +0200 Subject: [PATCH] Add check for legacy /etc/apt/sources.list existence before backup in apt.yml --- roles/common/tasks/apt.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/roles/common/tasks/apt.yml b/roles/common/tasks/apt.yml index 01c7b31..529e155 100644 --- a/roles/common/tasks/apt.yml +++ b/roles/common/tasks/apt.yml @@ -36,6 +36,17 @@ tags: - apt-configuration +- name: (apt.yml) check if legacy /etc/apt/sources.list exists (Debian >= 13) + stat: + path: /etc/apt/sources.list + register: apt_sources_list_stat + when: + - apt_manage_sources_list|bool + - ansible_facts['distribution'] == 'Debian' + - (ansible_facts['distribution_major_version'] | int) >= 13 + tags: + - apt-configuration + - name: (apt.yml) backup legacy /etc/apt/sources.list before deb822 migration (Debian >= 13) copy: src: /etc/apt/sources.list @@ -49,9 +60,7 @@ - apt_manage_sources_list|bool - ansible_facts['distribution'] == 'Debian' - (ansible_facts['distribution_major_version'] | int) >= 13 - failed_when: - - apt_sources_list_backup.failed - - "'No such file or directory' not in (apt_sources_list_backup.msg | default(''))" + - apt_sources_list_stat.stat.exists | default(false) register: apt_sources_list_backup tags: - apt-configuration