Skip to content

Commit

Permalink
feat: add become statements to avoid relying on ansible.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
ednxzu committed Nov 27, 2023
1 parent 38b9587 commit 66ff9d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tasks/custom_repositories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -20,5 +21,6 @@
owner: root
group: root
loop: "{{ manage_repositories_custom_repo }}"
become: true
notify:
- "debian-based-cache-update"
4 changes: 4 additions & 0 deletions tasks/main_repositories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -24,13 +25,15 @@
group: root
mode: '0644'
when: sources_list_current_content_str == ''
become: true

- name: "Replace content of /etc/apt/sources.list"
ansible.builtin.replace:
path: "{{ manage_repositories_sources_list_location }}"
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:
Expand All @@ -40,5 +43,6 @@
suites: "{{ item.suites | join(' ') }}"
components: "{{ item.components }}"
loop: "{{ manage_repositories_default_repo }}"
become: true
notify:
- "debian-based-cache-update"

0 comments on commit 66ff9d0

Please sign in to comment.