From b31aa53c810e0355ac044687b1e1b3ebe4f9c6da Mon Sep 17 00:00:00 2001 From: David Prevot Date: Thu, 25 Jan 2024 13:59:36 +0100 Subject: [PATCH] apt: Improve check mode --- apt/tasks/migrate-to-deb822.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apt/tasks/migrate-to-deb822.yml b/apt/tasks/migrate-to-deb822.yml index e7339e8b..e79ddf82 100644 --- a/apt/tasks/migrate-to-deb822.yml +++ b/apt/tasks/migrate-to-deb822.yml @@ -31,6 +31,11 @@ tags: - apt +- name: Is system.sources present? + ansible.builtin.stat: + path: /etc/apt/sources.list.d/system.sources + register: _system_sources + - name: Add signed-by when relevant for bookworm ansible.builtin.lineinfile: dest: /etc/apt/sources.list.d/system.sources @@ -39,6 +44,12 @@ state: present tags: - apt + when: _system_sources.stat.exists or not ansible_check_mode + +- name: Is security.sources present? + ansible.builtin.stat: + path: /etc/apt/sources.list.d/security.sources + register: _security_sources - name: Add signed-by when relevant for bookworm-security ansible.builtin.lineinfile: @@ -48,3 +59,4 @@ state: present tags: - apt + when: _security_sources.stat.exists or not ansible_check_mode