mirror of
https://gitlab.archlinux.org/archlinux/infrastructure.git
synced 2024-05-08 15:36:05 +02:00
syncrepo: let mirrorsync perform the repo syncing
This role will still handle setting up nginx and rsyncd, due to specific configuration requirements these services have. We're also effectively relieving build.archlinux.org of rsyncd duties as it is not something it should be doing anyway.
This commit is contained in:
parent
ef1f5c81b6
commit
a782c6953f
|
@ -17,6 +17,17 @@ mirrorsync_mirrors:
|
|||
- --include="pool/"
|
||||
- --include="pool/*-debug/***"
|
||||
- --exclude="*"
|
||||
repo:
|
||||
hosts: "{{ groups['mirrors'] + ['build.archlinux.org'] }}"
|
||||
source: rsync://rsync.archlinux.org/ftp_tier1
|
||||
target: /srv/ftp
|
||||
last_update_url: https://rsync.archlinux.org/lastupdate
|
||||
last_update_dst: lastupdate
|
||||
save_lastsync: true
|
||||
rsync_options:
|
||||
- --exclude="/other"
|
||||
- --exclude="/sources"
|
||||
- --exclude="*-debug/"
|
||||
riscv:
|
||||
hosts: "{{ groups['geo_mirrors'] }}"
|
||||
mirror_domain: riscv.mirror.pkgbuild.com
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../../group_vars/mirrors/mirrorsync.yml
|
|
@ -8,7 +8,7 @@
|
|||
- { role: root_ssh }
|
||||
- { role: archusers }
|
||||
- { role: sudo, tags: ['archusers'] }
|
||||
- { role: syncrepo }
|
||||
- { role: mirrorsync }
|
||||
- { role: archbuild }
|
||||
- { role: fail2ban }
|
||||
- { role: prometheus_exporters }
|
||||
|
|
|
@ -26,6 +26,10 @@ rsync_cmd() {
|
|||
|
||||
# if we are called without a tty (cronjob) only run when there are changes
|
||||
if ! tty -s && [[ -f "$target/{{ item.value.last_update_dst }}" ]] && diff -b <(curl -Ls "$lastupdate_url") "$target/{{ item.value.last_update_dst }}" >/dev/null; then
|
||||
{% if item.value.save_lastsync | default(false) %}
|
||||
# keep lastsync file in sync for statistics generated by the Arch Linux website
|
||||
rsync_cmd "$source_url/lastsync" "$target/lastsync"
|
||||
{% endif %}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
########
|
||||
#
|
||||
# Copyright © 2014-2019 Florian Pritz <bluewind@xinu.at>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
########
|
||||
#
|
||||
|
||||
# NOTE: This script is a copy of the syncrepo-template.sh script in the same
|
||||
# directory. It is a copy instead of being a template because the template is
|
||||
# linked in the wiki. People that follow the link and want to use the script
|
||||
# should populate the variables themselves and not be influenced by the values we
|
||||
# are using.
|
||||
|
||||
# NOTE: If you perform changes to this script, also consider changing the template!
|
||||
|
||||
# This is a simple mirroring script. To save bandwidth it first checks a
|
||||
# timestamp via HTTP and only runs rsync when the timestamp differs from the
|
||||
# local copy. As of 2016, a single rsync run without changes transfers roughly
|
||||
# 6MiB of data which adds up to roughly 250GiB of traffic per month when rsync
|
||||
# is run every minute. Performing a simple check via HTTP first can thus save a
|
||||
# lot of traffic.
|
||||
|
||||
# Directory where the repo is stored locally. Example: /srv/repo
|
||||
target="/srv/ftp"
|
||||
|
||||
# Lockfile path
|
||||
lock="/var/lock/syncrepo.lck"
|
||||
|
||||
# If you want to limit the bandwidth used by rsync set this.
|
||||
# Use 0 to disable the limit.
|
||||
# The default unit is KiB (see man rsync /--bwlimit for more)
|
||||
bwlimit=0
|
||||
|
||||
# The source URL of the mirror you want to sync from.
|
||||
# If you are a tier 1 mirror use rsync.archlinux.org, for example like this:
|
||||
# rsync://rsync.archlinux.org/ftp_tier1
|
||||
# Otherwise chose a tier 1 mirror from this list and use its rsync URL:
|
||||
# https://www.archlinux.org/mirrors/
|
||||
source_url='rsync://rsync.archlinux.org/ftp_tier1'
|
||||
|
||||
# An HTTP(S) URL pointing to the 'lastupdate' file on your chosen mirror.
|
||||
# If you are a tier 1 mirror use: https://rsync.archlinux.org/lastupdate
|
||||
# Otherwise use the HTTP(S) URL from your chosen mirror.
|
||||
lastupdate_url='https://rsync.archlinux.org/lastupdate'
|
||||
|
||||
#### END CONFIG
|
||||
|
||||
[ ! -d "${target}" ] && mkdir -p "${target}"
|
||||
|
||||
exec 9>"${lock}"
|
||||
flock -n 9 || exit
|
||||
|
||||
rsync_cmd() {
|
||||
local -a cmd=(rsync -rlptH --safe-links --delete-delay --delay-updates
|
||||
"--timeout=600" "--contimeout=60" --no-motd)
|
||||
|
||||
if stty &>/dev/null; then
|
||||
cmd+=(-h -v --progress)
|
||||
else
|
||||
cmd+=("--info=name1")
|
||||
fi
|
||||
|
||||
if ((bwlimit>0)); then
|
||||
cmd+=("--bwlimit=$bwlimit")
|
||||
fi
|
||||
|
||||
"${cmd[@]}" "$@"
|
||||
}
|
||||
|
||||
|
||||
# if we are called without a tty (cronjob) only run when there are changes
|
||||
if ! tty -s && [[ -f "$target/lastupdate" ]] && diff -b <(curl -Ls "$lastupdate_url") "$target/lastupdate" >/dev/null; then
|
||||
# keep lastsync file in sync for statistics generated by the Arch Linux website
|
||||
rsync_cmd "$source_url/lastsync" "$target/lastsync"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rsync_cmd \
|
||||
--exclude='/other' \
|
||||
--exclude='/sources' \
|
||||
--exclude='*-debug/' \
|
||||
"${source_url}" \
|
||||
"${target}"
|
||||
|
||||
#echo "Last sync was $(date -d @$(cat ${target}/lastsync))"
|
|
@ -1,12 +0,0 @@
|
|||
[Unit]
|
||||
Description=Synchronize package repository mirror
|
||||
RequiresMountsFor=/srv/ftp
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/syncrepo
|
||||
Nice=19
|
||||
IOSchedulingClass=best-effort
|
||||
IOSchedulingPriority=7
|
|
@ -1,10 +0,0 @@
|
|||
[Unit]
|
||||
Description=Minutely repository sync
|
||||
|
||||
[Timer]
|
||||
OnCalendar=minutely
|
||||
AccuracySec=1m
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -16,27 +16,11 @@
|
|||
- name: Install rsync
|
||||
pacman: name=rsync state=present
|
||||
|
||||
- name: Install syncrepo script
|
||||
copy: src=syncrepo dest=/usr/local/bin/syncrepo owner=root group=root mode=0755
|
||||
|
||||
- name: Install syncrepo units
|
||||
copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
|
||||
with_items:
|
||||
- syncrepo.timer
|
||||
- syncrepo.service
|
||||
|
||||
- name: Install rsyncd config
|
||||
copy: src=rsyncd.conf dest=/etc/rsyncd.conf owner=root group=root mode=0644
|
||||
|
||||
- name: Start and enable syncrepo units
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
with_items:
|
||||
- syncrepo.timer
|
||||
- rsyncd.socket
|
||||
- name: Start and enable rsyncd.socket
|
||||
service: name=rsyncd.socket enabled=yes state=started
|
||||
|
||||
- name: Make nginx log dirs
|
||||
file: path=/var/log/nginx/{{ item }} state=directory owner=root group=root mode=0755
|
||||
|
|
Loading…
Reference in New Issue