From ad48d2a72a801aaec64133f74c46ab93d501949b Mon Sep 17 00:00:00 2001
From: Alexandre Iooss <erdnaxe@crans.org>
Date: Sat, 8 Jun 2019 09:37:36 +0200
Subject: [PATCH] Configure APT to use adm debian miror

---
 base.yml                                           |  4 ++++
 monitoring.yml                                     |  2 +-
 roles/debian-apt-sources/tasks/main.yml            |  5 +++++
 .../templates/apt/sources.list.j2                  | 14 ++++++++++++++
 4 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 roles/debian-apt-sources/tasks/main.yml
 create mode 100644 roles/debian-apt-sources/templates/apt/sources.list.j2

diff --git a/base.yml b/base.yml
index 2b7a2636..fcaee722 100644
--- a/base.yml
+++ b/base.yml
@@ -1,5 +1,9 @@
 ---
 # Playbook to deploy common Crans configuration and tools
 - hosts: all
+  vars:
+    # Debian mirror on adm
+    debian_mirror: http://mirror.adm.crans.org/debian
   roles:
+    - debian-apt-sources
     - common-tools
diff --git a/monitoring.yml b/monitoring.yml
index 98b372fa..7918cef2 100644
--- a/monitoring.yml
+++ b/monitoring.yml
@@ -12,7 +12,7 @@
       - targets: [pulsar.adm.crans.org]
 
     # Debian non-free mirror
-    debian_mirror: http://ftp.adm.crans.org/debian/
+    debian_mirror: http://mirror.adm.crans.org/debian
   roles:
     - debian-non-free
     - prometheus
diff --git a/roles/debian-apt-sources/tasks/main.yml b/roles/debian-apt-sources/tasks/main.yml
new file mode 100644
index 00000000..24c5fc4e
--- /dev/null
+++ b/roles/debian-apt-sources/tasks/main.yml
@@ -0,0 +1,5 @@
+---
+- name: Configure Debian repositories
+  template:
+    src: apt/sources.list.j2
+    dest: /etc/apt/sources.list
diff --git a/roles/debian-apt-sources/templates/apt/sources.list.j2 b/roles/debian-apt-sources/templates/apt/sources.list.j2
new file mode 100644
index 00000000..ad448e64
--- /dev/null
+++ b/roles/debian-apt-sources/templates/apt/sources.list.j2
@@ -0,0 +1,14 @@
+# {{ ansible_managed }}
+
+# Mises à jour de sécurité
+deb     {{ debian_mirror }}-security {{ ansible_lsb.codename }}/updates main
+deb-src {{ debian_mirror }}-security {{ ansible_lsb.codename }}/updates main
+
+# Dépôt classique
+deb     {{ debian_mirror }} {{ ansible_lsb.codename }} main
+deb-src {{ debian_mirror }} {{ ansible_lsb.codename }} main
+
+# Dépôt pour mises à jour fréquentes (volatile)
+deb     {{ debian_mirror }} {{ ansible_lsb.codename }}-updates main
+deb-src {{ debian_mirror }} {{ ansible_lsb.codename }}-updates main
+
-- 
GitLab