manage_repositories/tasks/main_repositories.yml

49 lines
1.7 KiB
YAML
Raw Normal View History

2023-03-09 08:29:28 +00:00
---
2023-11-02 22:17:11 +00:00
# task/main_repositories file for manage_repositories
- name: "Emtpy /etc/apt/sources.list"
block:
2023-09-13 19:54:24 +00:00
- name: "Read the current content of source.list"
ansible.builtin.slurp:
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:
2023-09-13 19:54:24 +00:00
sources_list_current_content_str: "{{ (sources_list_current_content.content | default('')) | b64decode }}"
- name: "Define sources.list new content"
ansible.builtin.set_fact:
sources_list_new_content: "{{ manage_repositories_sources_list_message }}"
2023-09-13 19:54:24 +00:00
- name: "Create file /etc/apt/sources.list"
ansible.builtin.file:
path: "{{ manage_repositories_sources_list_location }}"
state: touch
owner: root
group: root
mode: '0644'
when: sources_list_current_content_str == ''
become: true
2023-09-13 19:54:24 +00:00
- 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
2023-09-13 19:57:41 +00:00
- name: "Configure main repositories into sources.list.d for {{ ansible_distribution|lower }} "
2023-09-13 19:54:24 +00:00
ansible.builtin.deb822_repository:
name: "{{ item.name }}"
types: "{{item.types}}"
uris: "{{ item.uri }}"
suites: "{{ item.suites | join(' ') }}"
components: "{{ item.components }}"
loop: "{{ manage_repositories_default_repo }}"
become: true
2023-03-09 08:29:28 +00:00
notify:
- "debian-based-cache-update"