Bertrand Lanson
880451bcd5
Some checks failed
test / Linting (push) Failing after 29s
test / Molecule tests (default, debian11) (push) Has been skipped
test / Molecule tests (default, debian12) (push) Has been skipped
test / Molecule tests (default, ubuntu2004) (push) Has been skipped
test / Molecule tests (default, ubuntu2204) (push) Has been skipped
test / Molecule tests (with_custom_repo, debian11) (push) Has been skipped
test / Molecule tests (with_custom_repo, debian12) (push) Has been skipped
test / Molecule tests (with_custom_repo, ubuntu2004) (push) Has been skipped
test / Molecule tests (with_custom_repo, ubuntu2204) (push) Has been skipped
45 lines
1.6 KiB
YAML
45 lines
1.6 KiB
YAML
---
|
|
# task/debian file for manage_repositories
|
|
- name: "Emtpy /etc/apt/sources.list"
|
|
block:
|
|
- 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
|
|
|
|
- name: "Convert sources.list current content to string"
|
|
ansible.builtin.set_fact:
|
|
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 }}"
|
|
|
|
- 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 == ''
|
|
|
|
- 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
|
|
|
|
- name: "Configure {{ ansible_distribution|lower }} main repositories into sources.list"
|
|
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 }}"
|
|
notify:
|
|
- "debian-based-cache-update"
|