[apt] Configure APT sources

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-04-07 23:53:30 +02:00
parent 564db32244
commit 7388125008
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
7 changed files with 81 additions and 7 deletions

View File

@ -1,5 +1,10 @@
#!/usr/bin/env ansible-playbook
---
- hosts: debian
vars:
apt: "{{ glob_apt | default({}) | combine(service_apt | default({})) | combine(loc_apt | default({})) }}"
roles:
- apt
- hosts: all
roles:

4
group_vars/debian.yml Normal file
View File

@ -0,0 +1,4 @@
---
glob_apt:
mirror: "http://mirror.crans.org/"
extra_repositories: []

8
group_vars/virtu.yml Normal file
View File

@ -0,0 +1,8 @@
---
service_apt:
extra_repositories:
- name: pve-entreprise
repositories:
- url: "{{ glob_apt.mirror }}proxmox/debian/pve"
version: "{{ ansible_distribution_release }}"
tags: "pve-no-subscription"

18
hosts
View File

@ -1,16 +1,20 @@
[server]
templier.adh.crans.org
dt.adh.crans.org
[archlinux:children]
perso
[debian:children]
server
[perso]
ynerant-pc.fil.sand.auro.re
ynerant-thinkpad.wifi.sand.auro.re
localhost
[crans]
odlyd.crans.org
tealc.crans.org
zamok.crans.org
[server]
templier.adh.crans.org
dt.adh.crans.org
[virtu]
dt.adh.crans.org
[all:vars]
# Force remote to use Python 3

27
roles/apt/tasks/main.yml Normal file
View File

@ -0,0 +1,27 @@
---
- name: Add mirror.crans.org in /etc/hosts
lineinfile:
state: present
path: /etc/hosts
regex: "^{{ item }}"
line: "{{ item }} mirror.crans.org charybde.crans.org mirror"
loop:
- "185.230.79.30"
- "2a0c:700:2:0:ea39:35ff:fef0:48c9"
- name: Configure Debian repositories
template:
src: apt/sources.list.j2
dest: /etc/apt/sources.list
owner: root
group: root
mode: 0644
- name: Connfigure 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 }}"

View File

@ -0,0 +1,8 @@
{{ ansible_header | comment }}
{% for repo in item.repositories -%}
deb {{ repo.url }} {{ repo.version }} {{ repo.tags }}
{% if repo.src is defined and repo.src -%}
deb-src {{ repo.url }} {{ repo.version }} {{ repo.tags }}
{% endif -%}
{% endfor -%}

View File

@ -0,0 +1,18 @@
{{ ansible_header | comment }}
{% if ansible_distribution_release != "bullseye" %}
{# Debian security does not exist yet for bullseye #}
# Mises à jour de sécurité
deb {{ apt.mirror }}debian-security {{ ansible_distribution_release }}/updates main contrib non-free
{% endif %}
# Dépôt classique
deb {{ apt.mirror }}debian {{ ansible_distribution_release }} main contrib non-free
# Dépôt pour mises à jour fréquentes (volatile)
deb {{ apt.mirror }}debian {{ ansible_distribution_release }}-updates main contrib non-free
{% if backports | default(false) %}
# Backports
deb {{ apt.mirror }}debian {{ ansible_distribution_release }}-backports main contrib non-free
{% endif %}