templier-ansible/roles/apt/tasks/main.yml

62 lines
1.5 KiB
YAML

---
- name: Clear charybde configuration
lineinfile:
state: absent
path: /etc/hosts
regex: "^{{ item }}"
loop:
- "185.230.79.30"
- "2a0c:700:2:0:ea39:35ff:fef0:48c9"
- name: Add mirror.adm.ynerant.fr in /etc/hosts
lineinfile:
state: present
path: /etc/hosts
regex: "^{{ item }}"
line: "{{ item }} mirror.adm.ynerant.fr"
loop:
- "172.16.42.102"
- "fd00::42:4000:ff:fe01:242"
- name: Configure Debian repositories
template:
src: apt/sources.list.j2
dest: /etc/apt/sources.list
owner: root
group: root
mode: 0644
- name: Configure extra repositories
template:
src: apt/sources.list.d/sources.list.j2
dest: "/etc/apt/sources.list.d/{{ item.name }}.list"
owner: root
group: root
mode: 0644
loop: "{{ apt.extra_repositories }}"
- name: Configure pin from future distributions
when: item[2].key != ansible_distribution_release
template:
src: "apt/{{ item[0] }}.d/pin{{ item[1] }}.j2"
dest: "/etc/apt/{{ item[0] }}.d/{{ item[2].key }}{{ item[1] }}"
owner: root
group: root
mode: 0644
with_nested:
- [["sources.list", ".list"], ["preferences", ""]]
- "{{ apt.pin|dict2items }}"
- name: Clear useless pinned configuration
when: item[2].key == ansible_distribution_release
file:
path: "/etc/apt/{{ item[0] }}.d/{{ item[2].key }}{{ item[1] }}"
state: absent
with_nested:
- [["sources.list", ".list"], ["preferences", ""]]
- "{{ apt.pin|dict2items }}"
- name: Update APT cache
apt:
update_cache: true