fix: Deploy repositories

This commit is contained in:
pulsar89.5 2025-01-02 13:18:09 +01:00
parent e4fccbface
commit c0f2b31437
3 changed files with 43 additions and 17 deletions

View File

@ -9,6 +9,11 @@
ansible.builtin.import_tasks:
file: repositories.yml
- 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
meta: flush_handlers

24
tasks/preferences.yml Normal file
View 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

View File

@ -1,38 +1,35 @@
---
# 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
ansible.builtin.get_url:
url: "{{ item.key_url }}"
dest: "{{ item.key_path }}"
mode: u=rw,g=r,o=r
when: item.get('key_url', '') | length > 0
become: true
when:
- apt_repositories | length > 0
- item.get('key_url', '') | length > 0
loop: "{{ apt_repositories }}"
loop_control:
label: "{{ item.url }}"
label: "{{ item.name }}"
notify: Mettre à jour le cache
- name: Ajouter le dépôt
ansible.builtin.template:
src: repository.sources.j2
dest: /etc/apt/sources.list.d/99custom.sources
dest: /etc/apt/sources.list.d/{{ item.name }}.sources
owner: root
group: root
mode: u=rw,g=r,o=r
when: apt_repositories | length > 0
become: true
notify: Mettre à jour le cache
- name: Ajouter le fichier de priorité
ansible.builtin.template:
src: preferences.j2
dest: /etc/apt/preferences.d/99custom
owner: root
group: root
mode: u=rw,g=r,o=r
when: apt_preferences | length > 0
become: true
loop: "{{ apt_repositories }}"
loop_control:
label: "{{ item.name }}"
notify: Mettre à jour le cache