Compare commits

..

No commits in common. "5be3f98f4436fefcf0cf2d98cd94886556e38e5a" and "a2c295d57eddfd643a4b99c451cc7c1beecf1863" have entirely different histories.

7 changed files with 59 additions and 117 deletions

View File

@ -5,15 +5,5 @@ 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

View File

@ -1,7 +0,0 @@
---
# handlers file for apt
- name: Mettre à jour le cache
ansible.builtin.apt:
update_cache: true
become: true

View File

@ -1,22 +0,0 @@
---
# 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

View File

@ -1,37 +0,0 @@
---
# 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

View File

@ -1,18 +1,65 @@
--- ---
# tasks file for apt # tasks file for apt
- name: Importer les tâches de configuration - name: Déployer la configuration du gestionnaire
ansible.builtin.import_tasks: ansible.builtin.template:
file: configuration.yml 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
- name: Importer les tâches d'ajout de dépôts tiers - name: Déployer la configuration des sources
ansible.builtin.import_tasks: ansible.builtin.template:
file: repositories.yml src: "{{ apt_distribution_name }}-{{ apt_distribution_release }}.list.j2"
when: apt_repositories | length > 0 dest: /etc/apt/sources.list
owner: root
group: root
mode: u=rw,g=r,o=r
become: true
- name: Exécuter les handlers - name: Mettre à jour le cache
meta: flush_handlers ansible.builtin.apt:
name: sudo
become: true
- name: Importer les tâches de gestion de paquets - name: Installer sudo
ansible.builtin.import_tasks: ansible.builtin.apt:
file: gestion.yml name: sudo
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

View File

@ -1,26 +0,0 @@
---
# 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 }}"
loop_control:
label: "{{ item.name }}"
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 }}"
loop_control:
label: "{{ item.name }}"
notify: Mettre à jour le cache

View File

@ -1,3 +0,0 @@
# {{ ansible_managed }}
deb [signed-by=/etc/apt/keyrings/{{ item.name }}.asc] {{ item.url }} {{ item.distribution_release }} {{ item.distribution_section }}