diff --git a/tasks/main.yml b/tasks/main.yml index bb6b8d7..e22a041 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/tasks/preferences.yml b/tasks/preferences.yml new file mode 100644 index 0000000..613c635 --- /dev/null +++ b/tasks/preferences.yml @@ -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 diff --git a/tasks/repositories.yml b/tasks/repositories.yml index 7710d78..3f002ca 100644 --- a/tasks/repositories.yml +++ b/tasks/repositories.yml @@ -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