Compare commits
10 Commits
5be3f98f44
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c0f2b31437 | |||
| e4fccbface | |||
| fbb43e8c7c | |||
| 3ffb13ba5b | |||
| 5b871f1c48 | |||
| a8178194c3 | |||
| 028beb4ea0 | |||
| c825925d7c | |||
| 7b5b672e41 | |||
| 255128789b |
@@ -2,16 +2,22 @@
|
|||||||
# defaults file for apt
|
# defaults file for apt
|
||||||
|
|
||||||
apt_distribution_name: debian
|
apt_distribution_name: debian
|
||||||
apt_distribution_release: bullseye
|
apt_distribution_release: bookworm
|
||||||
apt_distribution_sections: main
|
apt_distribution_sections: main
|
||||||
|
|
||||||
apt_repositories: []
|
apt_repositories: []
|
||||||
# Exemple:
|
# Exemple:
|
||||||
# - name: incus
|
# - url: http://deb.debian.org/debian
|
||||||
# key: https://pkgs.zabbly.com/key.asc
|
# suites: sid
|
||||||
# url: https://pkgs.zabbly.com/incus/stable
|
# components: main
|
||||||
# distribution_release: bookworm
|
# key_path: /usr/share/keyrings/debian-archive-keyring.gpg
|
||||||
# distribution_section: main
|
# - url: https://pkgs.zabbly.com/incus/stable
|
||||||
|
# suites: bookworm
|
||||||
|
# components: main
|
||||||
|
# key_url: https://pkgs.zabbly.com/key.asc
|
||||||
|
# key_path: /etc/apt/keyrings/incus.asc
|
||||||
|
|
||||||
|
apt_preferences: []
|
||||||
|
|
||||||
apt_remove: []
|
apt_remove: []
|
||||||
apt_install: []
|
apt_install: []
|
||||||
|
|||||||
@@ -11,10 +11,23 @@
|
|||||||
become: true
|
become: true
|
||||||
notify: Mettre à jour le cache
|
notify: Mettre à jour le cache
|
||||||
|
|
||||||
|
- name: Nettoyer le fichier de base
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/apt/sources.list
|
||||||
|
state: absent
|
||||||
|
become: true
|
||||||
|
notify: Mettre à jour le cache
|
||||||
|
|
||||||
|
- name: Supprimer le mirroirs
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/apt/mirrors
|
||||||
|
state: absent
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Déployer la configuration des sources
|
- name: Déployer la configuration des sources
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "{{ apt_distribution_name }}-{{ apt_distribution_release }}.list.j2"
|
src: debian.sources.list.j2
|
||||||
dest: /etc/apt/sources.list
|
dest: /etc/apt/sources.list.d/debian.sources
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
- name: Importer les tâches d'ajout de dépôts tiers
|
- name: Importer les tâches d'ajout de dépôts tiers
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: repositories.yml
|
file: repositories.yml
|
||||||
when: apt_repositories | length > 0
|
|
||||||
|
- name: Importer les tâches d'ajout des préférences
|
||||||
|
ansible.builtin.import_tasks:
|
||||||
|
file: preferences.yml
|
||||||
|
when: apt_preferences | length > 0
|
||||||
|
|
||||||
- name: Exécuter les handlers
|
- name: Exécuter les handlers
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|||||||
24
tasks/preferences.yml
Normal file
24
tasks/preferences.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
# tasks file for apt
|
||||||
|
|
||||||
|
- name: Construire la liste des règles
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
nftables_rules: "{{ nftables_rules + specific }}"
|
||||||
|
when: specific | length > 0
|
||||||
|
loop: "{{ lookup('ansible.builtin.varnames', '^nftables_rules_.+', wantlist=True) }}"
|
||||||
|
vars:
|
||||||
|
specific: "{{ lookup('ansible.builtin.vars', item, default='') }}"
|
||||||
|
|
||||||
|
- name: Ajouter le fichier de priorité
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: preferences.j2
|
||||||
|
dest: /etc/apt/preferences.d/{{ item.name }}
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
when: apt_preferences | length > 0
|
||||||
|
loop: "{{ apt_preferences }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
become: true
|
||||||
|
notify: Mettre à jour le cache
|
||||||
@@ -1,11 +1,20 @@
|
|||||||
---
|
---
|
||||||
# tasks file for apt
|
# tasks file for apt
|
||||||
|
|
||||||
|
- name: Construire la liste des dépôts
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
apt_repositories: "{{ apt_repositories + specific }}"
|
||||||
|
when: specific | length > 0
|
||||||
|
loop: "{{ lookup('ansible.builtin.varnames', '^apt_repositories_.+', wantlist=True) }}"
|
||||||
|
vars:
|
||||||
|
specific: "{{ lookup('ansible.builtin.vars', item, default='') }}"
|
||||||
|
|
||||||
- name: Télécharger la clef du dépôt
|
- name: Télécharger la clef du dépôt
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: "{{ item.key }}"
|
url: "{{ item.key_url }}"
|
||||||
dest: "/etc/apt/keyrings/{{ item.name }}.asc"
|
dest: "{{ item.key_path }}"
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
|
when: item.get('key_url', '') | length > 0
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ apt_repositories }}"
|
loop: "{{ apt_repositories }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
@@ -14,8 +23,8 @@
|
|||||||
|
|
||||||
- name: Ajouter le dépôt
|
- name: Ajouter le dépôt
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: repository.list.j2
|
src: repository.sources.j2
|
||||||
dest: /etc/apt/sources.list.d/{{ item.name }}.list
|
dest: /etc/apt/sources.list.d/{{ item.name }}.sources
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
debian-stable.list.j2
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
debian-stable.list.j2
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
deb http://deb.debian.org/debian {{ apt_distribution_release }} {{ apt_distribution_sections }}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
deb http://deb.debian.org/debian {{ apt_distribution_release }} {{ apt_distribution_sections }}
|
|
||||||
deb http://security.debian.org/debian-security {{ apt_distribution_release }}-security {{ apt_distribution_sections }}
|
|
||||||
deb http://deb.debian.org/debian {{ apt_distribution_release }}-updates {{ apt_distribution_sections }}
|
|
||||||
deb https://deb.debian.org/debian/ {{ apt_distribution_release }}-backports {{ apt_distribution_sections }}
|
|
||||||
21
templates/debian.sources.list.j2
Normal file
21
templates/debian.sources.list.j2
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% if apt_distribution_release == "sid" %}
|
||||||
|
Types: deb
|
||||||
|
URIs: https://deb.debian.org/debian
|
||||||
|
Suites: {{ apt_distribution_release }}
|
||||||
|
Components: {{ apt_distribution_sections }}
|
||||||
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
||||||
|
{% else %}
|
||||||
|
Types: deb
|
||||||
|
URIs: https://deb.debian.org/debian
|
||||||
|
Suites: {{ apt_distribution_release }} {{ apt_distribution_release }}-updates {{ apt_distribution_release }}-backports
|
||||||
|
Components: {{ apt_distribution_sections }}
|
||||||
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
||||||
|
|
||||||
|
Types: deb
|
||||||
|
URIs: http://security.debian.org/debian-security
|
||||||
|
Suites: {{ apt_distribution_release }}-security
|
||||||
|
Components: {{ apt_distribution_sections }}
|
||||||
|
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
||||||
|
{% endif %}
|
||||||
10
templates/preferences.j2
Normal file
10
templates/preferences.j2
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% for item in apt_preferences %}
|
||||||
|
Package: {{ item.package }}
|
||||||
|
Pin: {{ item.pin }}
|
||||||
|
Pin-Priority: {{ item.priority }}
|
||||||
|
{% if not loop.last %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
deb [signed-by=/etc/apt/keyrings/{{ item.name }}.asc] {{ item.url }} {{ item.distribution_release }} {{ item.distribution_section }}
|
|
||||||
12
templates/repository.sources.j2
Normal file
12
templates/repository.sources.j2
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% for item in apt_repositories %}
|
||||||
|
Types: deb
|
||||||
|
URIs: {{ item.url }}
|
||||||
|
Suites: {{ item.suites }}
|
||||||
|
Components: {{ item.components }}
|
||||||
|
Signed-By: {{ item.key_path }}
|
||||||
|
{% if not loop.last %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
Reference in New Issue
Block a user