feat: Add extra respositories
This commit is contained in:
parent
a2c295d57e
commit
1e090e385a
@ -5,5 +5,15 @@ apt_distribution_name: debian
|
|||||||
apt_distribution_release: bullseye
|
apt_distribution_release: bullseye
|
||||||
apt_distribution_sections: main
|
apt_distribution_sections: main
|
||||||
|
|
||||||
|
apt_repositories: []
|
||||||
|
# Exemple:
|
||||||
|
# - name: incus
|
||||||
|
# key: https://pkgs.zabbly.com/key.asc
|
||||||
|
# url: https://pkgs.zabbly.com/incus/stable
|
||||||
|
# distribution_release: bookworm
|
||||||
|
# distribution_section: main
|
||||||
|
|
||||||
apt_remove: []
|
apt_remove: []
|
||||||
apt_install: []
|
apt_install: []
|
||||||
|
|
||||||
|
apt_full_upgrade: false
|
||||||
|
7
handlers/main.yml
Normal file
7
handlers/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
# handlers file for apt
|
||||||
|
|
||||||
|
- name: Mettre à jour le cache
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
become: true
|
22
tasks/configuration.yml
Normal file
22
tasks/configuration.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
# tasks file for apt
|
||||||
|
|
||||||
|
- name: Déployer la configuration du gestionnaire
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: apt.conf.j2
|
||||||
|
dest: /etc/apt/apt.conf.d/99-custom
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
become: true
|
||||||
|
notify: Mettre à jour le cache
|
||||||
|
|
||||||
|
- name: Déployer la configuration des sources
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "{{ apt_distribution_name }}-{{ apt_distribution_release }}.list.j2"
|
||||||
|
dest: /etc/apt/sources.list
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
become: true
|
||||||
|
notify: Mettre à jour le cache
|
37
tasks/gestion.yml
Normal file
37
tasks/gestion.yml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
# tasks file for apt
|
||||||
|
|
||||||
|
- name: Construire la liste des paquets à désinstaller
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
apt_remove: "{{ apt_remove + specific }}"
|
||||||
|
when: specific | length > 0
|
||||||
|
loop: "{{ lookup('ansible.builtin.varnames', '^apt_remove_.+', wantlist=True) }}"
|
||||||
|
vars:
|
||||||
|
specific: "{{ lookup('ansible.builtin.vars', item, default='') }}"
|
||||||
|
|
||||||
|
- name: Désinstaller des paquets
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: absent
|
||||||
|
purge: true
|
||||||
|
autoremove: true
|
||||||
|
name: "{{ apt_remove }}"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Mettre à jour la distribution
|
||||||
|
become: true
|
||||||
|
ansible.builtin.apt:
|
||||||
|
upgrade: dist
|
||||||
|
when: apt_full_upgrade
|
||||||
|
|
||||||
|
- name: Construire la liste des paquets à installer
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
apt_install: "{{ apt_install + specific }}"
|
||||||
|
when: specific | length > 0
|
||||||
|
loop: "{{ lookup('ansible.builtin.varnames', '^apt_install_.+', wantlist=True) }}"
|
||||||
|
vars:
|
||||||
|
specific: "{{ lookup('ansible.builtin.vars', item, default='') }}"
|
||||||
|
|
||||||
|
- name: Installer des paquets
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ apt_install }}"
|
||||||
|
become: true
|
@ -1,65 +1,18 @@
|
|||||||
---
|
---
|
||||||
# tasks file for apt
|
# tasks file for apt
|
||||||
|
|
||||||
- name: Déployer la configuration du gestionnaire
|
- name: Importer les tâches de configuration
|
||||||
ansible.builtin.template:
|
ansible.builtin.import_tasks:
|
||||||
src: apt.conf.j2
|
file: configuration.yml
|
||||||
dest: /etc/apt/apt.conf.d/99-custom
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Déployer la configuration des sources
|
- name: Importer les tâches d'ajout de dépôts tiers
|
||||||
ansible.builtin.template:
|
ansible.builtin.import_tasks:
|
||||||
src: "{{ apt_distribution_name }}-{{ apt_distribution_release }}.list.j2"
|
file: repositories.yml
|
||||||
dest: /etc/apt/sources.list
|
when: apt_repositories | length > 0
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Mettre à jour le cache
|
- name: Exécuter les handlers
|
||||||
ansible.builtin.apt:
|
meta: flush_handlers
|
||||||
name: sudo
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Installer sudo
|
- name: Importer les tâches de gestion de paquets
|
||||||
ansible.builtin.apt:
|
ansible.builtin.import_tasks:
|
||||||
name: sudo
|
file: gestion.yml
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Construire la liste des paquets à désinstaller
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
apt_remove: "{{ apt_remove + specific }}"
|
|
||||||
when: specific | length > 0
|
|
||||||
loop: "{{ lookup('ansible.builtin.varnames', '^apt_remove_.+', wantlist=True) }}"
|
|
||||||
vars:
|
|
||||||
specific: "{{ lookup('ansible.builtin.vars', item, default='') }}"
|
|
||||||
|
|
||||||
- name: Désinstaller des paquets
|
|
||||||
ansible.builtin.apt:
|
|
||||||
state: absent
|
|
||||||
purge: true
|
|
||||||
autoremove: true
|
|
||||||
name: "{{ apt_remove }}"
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Mettre à jour la distribution
|
|
||||||
become: true
|
|
||||||
ansible.builtin.apt:
|
|
||||||
update_cache: true
|
|
||||||
upgrade: dist
|
|
||||||
|
|
||||||
- name: Construire la liste des paquets à installer
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
apt_install: "{{ apt_install + specific }}"
|
|
||||||
when: specific | length > 0
|
|
||||||
loop: "{{ lookup('ansible.builtin.varnames', '^apt_install_.+', wantlist=True) }}"
|
|
||||||
vars:
|
|
||||||
specific: "{{ lookup('ansible.builtin.vars', item, default='') }}"
|
|
||||||
|
|
||||||
- name: Installer des paquets
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name: "{{ apt_install }}"
|
|
||||||
become: true
|
|
||||||
|
22
tasks/repositories.yml
Normal file
22
tasks/repositories.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
# tasks file for apt
|
||||||
|
|
||||||
|
- name: Télécharger la clef du dépôt
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ item.key }}"
|
||||||
|
dest: "/etc/apt/keyrings/{{ item.name }}.asc"
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
become: true
|
||||||
|
loop: "{{ apt_repositories }}"
|
||||||
|
notify: Mettre à jour le cache
|
||||||
|
|
||||||
|
- name: Ajouter le dépôt
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: repository.list.j2
|
||||||
|
dest: /etc/apt/sources.list.d/{{ item.name }}.list
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
become: true
|
||||||
|
loop: "{{ apt_repositories }}"
|
||||||
|
notify: Mettre à jour le cache
|
3
templates/repository.list.j2
Normal file
3
templates/repository.list.j2
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
deb [signed-by=/etc/apt/keyrings/{{ item.name }}.asc] {{ item.url }} {{ item.distribution_release }} {{ item.distribution_section }}
|
Loading…
Reference in New Issue
Block a user