Add check for legacy /etc/apt/sources.list existence before backup in apt.yml

This commit is contained in:
2026-07-17 18:24:14 +02:00
parent d68e39127a
commit 4f7da3ae5d
+12 -3
View File
@@ -36,6 +36,17 @@
tags: tags:
- apt-configuration - 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) - name: (apt.yml) backup legacy /etc/apt/sources.list before deb822 migration (Debian >= 13)
copy: copy:
src: /etc/apt/sources.list src: /etc/apt/sources.list
@@ -49,9 +60,7 @@
- apt_manage_sources_list|bool - apt_manage_sources_list|bool
- ansible_facts['distribution'] == 'Debian' - ansible_facts['distribution'] == 'Debian'
- (ansible_facts['distribution_major_version'] | int) >= 13 - (ansible_facts['distribution_major_version'] | int) >= 13
failed_when: - apt_sources_list_stat.stat.exists | default(false)
- apt_sources_list_backup.failed
- "'No such file or directory' not in (apt_sources_list_backup.msg | default(''))"
register: apt_sources_list_backup register: apt_sources_list_backup
tags: tags:
- apt-configuration - apt-configuration