role_apt/tasks/repositories.yml

36 lines
1005 B
YAML

---
# 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
loop: "{{ apt_repositories }}"
loop_control:
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/{{ item.name }}.sources
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