From 66ff9d0c207329b3bea372c9dc12d54f8bcdda5c Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Mon, 27 Nov 2023 20:59:30 +0100 Subject: [PATCH] feat: add become statements to avoid relying on ansible.cfg --- tasks/custom_repositories.yml | 2 ++ tasks/main_repositories.yml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/tasks/custom_repositories.yml b/tasks/custom_repositories.yml index 2d4995a..95a149e 100644 --- a/tasks/custom_repositories.yml +++ b/tasks/custom_repositories.yml @@ -9,6 +9,7 @@ when: item.options is defined and item.options['Signed-By'] is defined and item.options['Signed-By'] not in [None, ''] + become: true - name: "Configure custom repositories" vars: @@ -20,5 +21,6 @@ owner: root group: root loop: "{{ manage_repositories_custom_repo }}" + become: true notify: - "debian-based-cache-update" diff --git a/tasks/main_repositories.yml b/tasks/main_repositories.yml index af3e60c..2c800d3 100644 --- a/tasks/main_repositories.yml +++ b/tasks/main_repositories.yml @@ -7,6 +7,7 @@ src: "{{ manage_repositories_sources_list_location }}" register: sources_list_current_content ignore_errors: true + become: true - name: "Convert sources.list current content to string" ansible.builtin.set_fact: @@ -24,6 +25,7 @@ group: root mode: '0644' when: sources_list_current_content_str == '' + become: true - name: "Replace content of /etc/apt/sources.list" ansible.builtin.replace: @@ -31,6 +33,7 @@ regexp: "{{ sources_list_current_content_str | regex_escape }}" replace: "{{ sources_list_new_content }}" when: sources_list_current_content_str != sources_list_new_content + become: true - name: "Configure main repositories into sources.list.d for {{ ansible_distribution|lower }} " ansible.builtin.deb822_repository: @@ -40,5 +43,6 @@ suites: "{{ item.suites | join(' ') }}" components: "{{ item.components }}" loop: "{{ manage_repositories_default_repo }}" + become: true notify: - "debian-based-cache-update"