diff --git a/defaults/main.yml b/defaults/main.yml index bfb666f..a53b7a2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,6 +19,8 @@ apt_repositories: [] # key_url: https://pkgs.zabbly.com/key.asc # key_path: /etc/apt/keyrings/incus.asc +apt_preferences: [] + apt_remove: [] apt_install: [] diff --git a/tasks/repositories.yml b/tasks/repositories.yml index 8363b63..278ba67 100644 --- a/tasks/repositories.yml +++ b/tasks/repositories.yml @@ -18,23 +18,21 @@ - name: Ajouter le dépôt ansible.builtin.template: src: repository.sources.j2 - dest: /etc/apt/sources.list.d/{{ item.name }}.sources + dest: /etc/apt/sources.list.d/99custom.sources owner: root group: root mode: u=rw,g=r,o=r when: apt_repositories | length > 0 become: true - loop: "{{ apt_repositories }}" - loop_control: - label: "{{ item.name }}" notify: Mettre à jour le cache - name: Ajouter le fichier de priorité ansible.builtin.template: src: preferences.j2 - dest: /etc/apt/preferences.d/40-debian + dest: /etc/apt/preferences.d/99custom owner: root group: root mode: u=rw,g=r,o=r + when: apt_preferences | length > 0 become: true notify: Mettre à jour le cache diff --git a/templates/preferences.j2 b/templates/preferences.j2 index 8f7882a..f233604 100644 --- a/templates/preferences.j2 +++ b/templates/preferences.j2 @@ -1,9 +1,10 @@ # {{ ansible_managed }} -Package: * -Pin: release a=testing -Pin-Priority: -10 +{% for item in apt_preferences %} +Package: {{ item.package }} +Pin: {{ item.pin }} +Pin-Priority: {{ item.priority }} +{% if not loop.last %} -Package: * -Pin: release a=unstable -Pin-Priority: -20 +{% endif %} +{% endfor %} diff --git a/templates/repository.sources.j2 b/templates/repository.sources.j2 index 5c45448..86789ce 100644 --- a/templates/repository.sources.j2 +++ b/templates/repository.sources.j2 @@ -1,7 +1,12 @@ # {{ ansible_managed }} +{% for item in apt_repositories %} Types: deb URIs: {{ item.url }} Suites: {{ item.suites }} Components: {{ item.components }} Signed-By: {{ item.key_path }} +{% if not loop.last %} + +{% endif %} +{% endfor %}