role(apt_sources): add role to modify default apt repo list
This commit is contained in:
8
roles/apt_sources/defaults/main.yml
Normal file
8
roles/apt_sources/defaults/main.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
apt_sources_debian_repos_list: |
|
||||||
|
deb https://ftp-stud.hs-esslingen.de/debian/ bookworm main non-free-firmware
|
||||||
|
deb-src https://ftp-stud.hs-esslingen.de/debian/ bookworm main non-free-firmware
|
||||||
|
deb https://ftp-stud.hs-esslingen.de/debian-security/ bookworm-security main non-free-firmware
|
||||||
|
deb-src https://ftp-stud.hs-esslingen.de/debian-security/ bookworm-security main non-free-firmware
|
||||||
|
deb https://ftp-stud.hs-esslingen.de/debian/ bookworm-updates main non-free-firmware
|
||||||
|
deb-src https://ftp-stud.hs-esslingen.de/debian/ bookworm-updates main non-free-firmware
|
||||||
6
roles/apt_sources/handlers/main.yml
Normal file
6
roles/apt_sources/handlers/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: update apt sources
|
||||||
|
listen: apt_sources_update
|
||||||
|
become: true
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
35
roles/apt_sources/tasks/main.yml
Normal file
35
roles/apt_sources/tasks/main.yml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
- name: ensure custom repositories in apt sources
|
||||||
|
become: true
|
||||||
|
notify: apt_sources_update
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/apt/sources.list.d/debian.list
|
||||||
|
mode: '0644'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
backup: true
|
||||||
|
content: |
|
||||||
|
#
|
||||||
|
# this file was modified by ansible on {{ ansible_date_time.iso8601 }}
|
||||||
|
#
|
||||||
|
{{ apt_sources_debian_repos_list }}
|
||||||
|
|
||||||
|
- name: disable default apt repos
|
||||||
|
become: true
|
||||||
|
notify: apt_sources_update
|
||||||
|
register: apt_sources_disable
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: /etc/apt/sources.list
|
||||||
|
backup: true
|
||||||
|
regexp: '^(deb(?:\-src)?.*)$'
|
||||||
|
replace: '#\1'
|
||||||
|
|
||||||
|
- name: ensure info comment in default sources file
|
||||||
|
become: true
|
||||||
|
when: apt_sources_disable is changed
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
state: present
|
||||||
|
path: /etc/apt/sources.list
|
||||||
|
insertbefore: BOF
|
||||||
|
search_string: '# this file was modified by ansible on '
|
||||||
|
line: '# this file was modified by ansible on {{ ansible_date_time.iso8601 }}'
|
||||||
Reference in New Issue
Block a user