From 2612bfe33288883386ff27df4133e912c5bbb17b Mon Sep 17 00:00:00 2001
From: Maxime Bombar <bombar@crans.org>
Date: Sun, 2 Aug 2020 00:32:30 +0200
Subject: [PATCH] [rsyncd] Do not hardcode anything in rsyncd.conf

---
 roles/rsync-client/templates/rsyncd.conf.j2 | 60 +++++++--------------
 1 file changed, 18 insertions(+), 42 deletions(-)

diff --git a/roles/rsync-client/templates/rsyncd.conf.j2 b/roles/rsync-client/templates/rsyncd.conf.j2
index 780ab375..89c873a7 100644
--- a/roles/rsync-client/templates/rsyncd.conf.j2
+++ b/roles/rsync-client/templates/rsyncd.conf.j2
@@ -30,48 +30,24 @@ address = {{ hostvars[inventory_hostname]['ansible_' + adm_iface.stdout].ipv4.ad
 # MODULE OPTIONS
 
 {# Liste des dossiers a sauvegarder par serveur, en plus de la racine. #}
-[var]
-path = /var
-auth users = backupcrans
-secrets file = /etc/rsyncd.secrets
-hosts allow = zephir.adm.crans.org 10.231.136.6 {% if ansible_hostname == "sputnik" %}172.31.0.1{% endif %}
+{% for partition in to_backup %}
 
-
-[slash]
-path = /
-auth users = backupcrans
-secrets file = /etc/rsyncd.secrets
-hosts allow = zephir.adm.crans.org 10.231.136.6 {% if ansible_hostname == "sputnik" %}172.31.0.1{% endif %}
-
-{# rsync readonly pour le miroir #}
-{% if ansible_hostname == "charybde" %}
-[ftp]
-path = /pubftp
-comment = CRANS FTP
-uid = nobody
-gid = nogroup
-hosts allow = *
-read only = yes
-
-[videolan]
-path = /pubftp/videolan
-comment = VideoLAN repository
-uid = nobody
-gid = nogroup
-hosts allow = *
-read only = yes
+[{{ partition.name }}]
+path = {{ partition.path }}
+{% if partition.comment is defined %}
+comment = {{ partition.comment }}
+{% endif %}
+{% if partition.uid is defined %}
+uid = {{ partition.uid }}
+gid = {{ partition.gid }}
+{% endif %}
+{% if partition.auth_users is defined %}
+auth users = {{ partition.auth_users }}
+secrets file = {{ partition.secrets_file }}
+{% endif %}
+hosts allow = {{ partition.hosts_allow | join(" ") }}
+{% if partition.read_only is defined %}
+read only = {{ partition.read_only }}
 {% endif %}
 
-{# on veut backuper /var/lib/mailman sur redisdead #}
-{% if ansible_hostname == "redisdead" %}
-[mailman]
-path = /var/lib/mailman
-auth users = backupcrans
-secrets file = /etc/rsyncd.secrets
-hosts allow = zephir.adm.crans.org 10.231.136.6
-{% endif %} 
-
-
-{# TODO: implémenter le vrai système comme dans BCFG2 #}
-{# TODO: implémenter le cas particulier cpasswords-main et wiki #}
-
+{% endfor %}
-- 
GitLab