From 5bf423027ede7fdae52d5853133dfb314501704c Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 30 Mar 2020 20:17:27 +0200 Subject: [PATCH] ftpsync role --- base.yml | 2 +- roles/ftpsync/tasks/main.yml | 28 +++++++++++++++ roles/ftpsync/templates/ftpsync-cron.j2 | 4 +++ roles/ftpsync/templates/ftpsync.conf.j2 | 48 +++++++++++++++++++++++++ services_web.yml | 42 ++++++++++++++++++++++ 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 roles/ftpsync/tasks/main.yml create mode 100644 roles/ftpsync/templates/ftpsync-cron.j2 create mode 100644 roles/ftpsync/templates/ftpsync.conf.j2 diff --git a/base.yml b/base.yml index 5341f438..d2007046 100644 --- a/base.yml +++ b/base.yml @@ -78,7 +78,7 @@ roles: - ansible -# Tools for memebers +# Tools for members - hosts: zamok.adm.crans.org roles: - zamok-tools diff --git a/roles/ftpsync/tasks/main.yml b/roles/ftpsync/tasks/main.yml new file mode 100644 index 00000000..e5b45d77 --- /dev/null +++ b/roles/ftpsync/tasks/main.yml @@ -0,0 +1,28 @@ +--- +# For installation instruction, see /usr/share/doc/ftpsync/README.md.gz +# Not everything is up to date in this README, be careful! +- name: Install ftpsync + apt: + update_cache: true + name: ftpsync + register: apt_result + retries: 3 + until: apt_result is succeeded + +# cron run as mirror user +- name: Add the mirror user + user: + name: mirror + home: /var/mirror # unused, should be something empty + shell: /bin/false + +- name: Copy ftpsync configurations + template: + src: ftpsync.conf.j2 + dest: "/etc/ftpsync/ftpsync-{{ item.name }}.conf" + loop: "{{ ftpsync }}" + +- name: Configure ftpsync cron + template: + src: ftpsync-cron.j2 + dest: /etc/cron.d/ftpsync diff --git a/roles/ftpsync/templates/ftpsync-cron.j2 b/roles/ftpsync/templates/ftpsync-cron.j2 new file mode 100644 index 00000000..81f1a9aa --- /dev/null +++ b/roles/ftpsync/templates/ftpsync-cron.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} +{% for i in ftpsync %} +{{ i.cron_time }} * * * mirror ftpsync sync:archive:{{ i.name }} +{% endfor %} diff --git a/roles/ftpsync/templates/ftpsync.conf.j2 b/roles/ftpsync/templates/ftpsync.conf.j2 new file mode 100644 index 00000000..42dd0ed5 --- /dev/null +++ b/roles/ftpsync/templates/ftpsync.conf.j2 @@ -0,0 +1,48 @@ +# {{ ansible_managed }} + +# MIRRORNAME=`hostname -f` +TO="{{ item.dest }}" +MAILTO="root" +# HUB=false + +######################################################################## +## Connection options +######################################################################## + +RSYNC_HOST="{{ item.rsync_host }}" +RSYNC_PATH="{{ item.rsync_path }}" +# RSYNC_USER= +# RSYNC_PASSWORD= + +######################################################################## +## Mirror information options +######################################################################## + +# INFO_MAINTAINER="Admins , Person " +# INFO_SPONSOR="Example " +# INFO_COUNTRY=DE +# INFO_LOCATION="Example" +# INFO_THROUGHPUT=10Gb + +######################################################################## +## Include and exclude options +######################################################################## + +# ARCH_INCLUDE= +# ARCH_EXCLUDE= + +######################################################################## +## Log option +######################################################################## + +LOGDIR="/var/log/mirror" + +## If you do want a mail about every single sync, set this to false +## Everything else will only send mails if a mirror sync fails +ERRORSONLY="true" + +## If you want the logs to also include output of rsync, set this to true. +## Careful, the logs can get pretty big, especially if it is the first mirror +## run +FULLLOGS="false" + diff --git a/services_web.yml b/services_web.yml index 3ab74b8f..c86c121d 100644 --- a/services_web.yml +++ b/services_web.yml @@ -31,3 +31,45 @@ - hosts: cochon.adm.crans.org roles: - mumudvb + +# Mirrors +- hosts: charybde.adm.crans.org + vars: + ftpsync: + - name: main + dest: /pubftp/pub/debian/ + cron_time: "25 1,13" + rsync_host: ftp.fr.debian.org + rsync_path: debian + + - name: security + dest: /pubftp/pub/debian-security/ + cron_time: "40 *" + rsync_host: ftp.fr.debian.org + rsync_path: debian-security + + - name: backports + dest: /pubftp/pub/debian-backports/ + cron_time: " 7 3,15" + rsync_host: ftp.fr.debian.org + rsync_path: debian-backports + + - name: ports + dest: /pubftp/pub/debian-ports/ + cron_time: " 7 3,15" + rsync_host: deb.debian.org + rsync_path: debian-ports + + - name: multimedia + dest: /pubftp/pub/debian-multimedia/ + cron_time: "49 4,16" + rsync_host: www.deb-multimedia.org + rsync_path: deb + + - name: ubuntu + dest: /pubftp/pub/ubuntu/ + cron_time: "55 5,17" + rsync_host: ftp.lip6.fr + rsync_path: Ubuntu/archive/ + roles: + - ftpsync