role_apt/tasks/gestion.yml

38 lines
1.0 KiB
YAML

---
# 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