mirror of
https://github.com/valitydev/salt-common.git
synced 2024-11-06 10:25:23 +00:00
Rename gentoo-mirrors to gentoo-mirror, add logrotate config
This commit is contained in:
parent
7b5d6d9b1a
commit
fef87e7679
6
sls/gentoo-mirror/files/gentoo-mirror.logrotate
Normal file
6
sls/gentoo-mirror/files/gentoo-mirror.logrotate
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Managed by Salt
|
||||||
|
|
||||||
|
/var/log/rsync-gentoo-.log {
|
||||||
|
missingok
|
||||||
|
delaycompress
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
RSYNC="/usr/bin/rsync"
|
RSYNC="/usr/bin/rsync"
|
||||||
LOGDIR="/var/log"
|
LOGDIR="/var/log/gentoo-mirror"
|
||||||
bname="$(basename ${0})"
|
bname="$(basename ${0})"
|
||||||
base="${bname%.*}"
|
base="${bname%.*}"
|
||||||
LOGFILE="${LOGDIR}/${base}.log"
|
LOGFILE="${LOGDIR}/${base}.log"
|
||||||
if [ "${base}" == "rsync-base" ]; then
|
if [ "${base}" == "rsync-base" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
source "/etc/rsync/${base}.conf"
|
source "/etc/gentoo-mirror/${base}.conf"
|
||||||
|
|
||||||
if flock -xn "${DST}" sleep 1; then
|
if flock -xn "${DST}" sleep 1; then
|
||||||
echo "${base} is not locked" >> "${LOGFILE}" 2>&1
|
echo "${base} is not locked" >> "${LOGFILE}" 2>&1
|
@ -3,6 +3,7 @@ include:
|
|||||||
- nginx.tls.gentoo-mirror
|
- nginx.tls.gentoo-mirror
|
||||||
- rsyncd
|
- rsyncd
|
||||||
- cron
|
- cron
|
||||||
|
- logrotate
|
||||||
|
|
||||||
{% set mirror_host = salt['pillar.get']('gentoo-mirror:mirror-host', 'gentoo.bakka.su') %}
|
{% set mirror_host = salt['pillar.get']('gentoo-mirror:mirror-host', 'gentoo.bakka.su') %}
|
||||||
{% set dst_host = salt['pillar.get']('gentoo-mirror:dst-host',
|
{% set dst_host = salt['pillar.get']('gentoo-mirror:dst-host',
|
||||||
@ -14,7 +15,7 @@ include:
|
|||||||
|
|
||||||
/etc/nginx/vhosts.d/gentoo-mirror.conf:
|
/etc/nginx/vhosts.d/gentoo-mirror.conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://gentoo-mirrors/files/gentoo_mirror.nginx.conf.tpl
|
- source: salt://{{ slspath }}/files/gentoo_mirror.nginx.conf.tpl
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
ssl: True
|
ssl: True
|
||||||
@ -31,60 +32,76 @@ include:
|
|||||||
- watch_in:
|
- watch_in:
|
||||||
- service: nginx-reload
|
- service: nginx-reload
|
||||||
|
|
||||||
/opt/gentoo-rsync/:
|
/opt/gentoo-mirror/:
|
||||||
file.directory:
|
file.directory:
|
||||||
- create: True
|
- create: True
|
||||||
- mode: 755
|
- mode: 755
|
||||||
- user: root
|
- user: root
|
||||||
- group: root
|
- group: root
|
||||||
|
|
||||||
/opt/gentoo-rsync/rsync-base.sh:
|
/opt/gentoo-mirror/rsync-base.sh:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://gentoo-mirrors/files/rsync-base.sh
|
- source: salt://{{ slspath }}/files/rsync-base.sh
|
||||||
- mode: 755
|
- mode: 755
|
||||||
- user: root
|
- user: root
|
||||||
- group: root
|
- group: root
|
||||||
- require:
|
- require:
|
||||||
- file: /opt/gentoo-rsync/
|
- file: /opt/gentoo-mirror/
|
||||||
|
|
||||||
/etc/rsync/:
|
/etc/gentoo-mirror/:
|
||||||
file.directory:
|
file.directory:
|
||||||
- create: True
|
- create: True
|
||||||
- mode: 755
|
- mode: 755
|
||||||
- user: root
|
- user: root
|
||||||
- group: root
|
- group: root
|
||||||
|
|
||||||
|
/var/log/gentoo-mirror/:
|
||||||
|
file.directory:
|
||||||
|
- create: True
|
||||||
|
- mode: 755
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
|
||||||
|
/etc/logrotate.d/gentoo-mirror:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://{{ slspath }}/files/gentoo-mirror.logrotate
|
||||||
|
- mode: 644
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- require:
|
||||||
|
- file: /etc/logrotate.d/
|
||||||
|
|
||||||
{% if 'gentoo-distfiles' in mirror_types %}
|
{% if 'gentoo-distfiles' in mirror_types %}
|
||||||
"{{ default_root }}/gentoo-distfiles":
|
"{{ default_root }}/gentoo-distfiles":
|
||||||
file.directory:
|
file.directory:
|
||||||
- create: True
|
- create: True
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
/etc/rsync/rsync-gentoo-distfiles.conf:
|
/etc/gentoo-mirror/rsync-gentoo-distfiles.conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://gentoo-mirrors/files/rsync-conf.tpl
|
- source: salt://{{ slspath }}/files/rsync-conf.tpl
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
rsync_src: "rsync://{{ mirror_host }}/gentoo-distfiles"
|
rsync_src: "rsync://{{ mirror_host }}/gentoo-distfiles"
|
||||||
rsync_dst: "{{ default_root }}/gentoo-distfiles"
|
rsync_dst: "{{ default_root }}/gentoo-distfiles"
|
||||||
# - context:
|
# - context:
|
||||||
|
|
||||||
/opt/gentoo-rsync/rsync-gentoo-distfiles.sh:
|
/opt/gentoo-mirror/rsync-gentoo-distfiles.sh:
|
||||||
file.symlink:
|
file.symlink:
|
||||||
- target: /opt/gentoo-rsync/rsync-base.sh
|
- target: /opt/gentoo-mirror/rsync-base.sh
|
||||||
- require:
|
- require:
|
||||||
- file: /opt/gentoo-rsync/rsync-base.sh
|
- file: /opt/gentoo-mirror/rsync-base.sh
|
||||||
|
|
||||||
rsync-gentoo-distfiles:
|
rsync-gentoo-distfiles:
|
||||||
cron.present:
|
cron.present:
|
||||||
- identifier: rsync-gentoo-distfiles
|
- identifier: rsync-gentoo-distfiles
|
||||||
- name: /opt/gentoo-rsync/rsync-gentoo-distfiles.sh
|
- name: /opt/gentoo-mirror/rsync-gentoo-distfiles.sh
|
||||||
- user: root
|
- user: root
|
||||||
- minute: 0
|
- minute: 0
|
||||||
- hour: '*/4'
|
- hour: '*/4'
|
||||||
- require:
|
- require:
|
||||||
- file: /etc/rsync/rsync-gentoo-distfiles.conf
|
- file: /etc/gentoo-mirror/rsync-gentoo-distfiles.conf
|
||||||
- file: /opt/gentoo-rsync/rsync-gentoo-distfiles.sh
|
- file: /opt/gentoo-mirror/rsync-gentoo-distfiles.sh
|
||||||
|
|
||||||
/etc/rsyncd.d/gentoo-distfiles.conf:
|
/etc/rsyncd.d/gentoo-distfiles.conf:
|
||||||
ini.options_present:
|
ini.options_present:
|
||||||
@ -102,9 +119,9 @@ rsync-gentoo-distfiles:
|
|||||||
- create: True
|
- create: True
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
/etc/rsync/rsync-gentoo-portage.conf:
|
/etc/gentoo-mirror/rsync-gentoo-portage.conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://gentoo-mirrors/files/rsync-conf.tpl
|
- source: salt://{{ slspath }}/files/rsync-conf.tpl
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
rsync_src: "rsync://{{ mirror_host }}/gentoo-portage"
|
rsync_src: "rsync://{{ mirror_host }}/gentoo-portage"
|
||||||
@ -112,22 +129,22 @@ rsync-gentoo-distfiles:
|
|||||||
rsync_opts: "+ --checksums"
|
rsync_opts: "+ --checksums"
|
||||||
# - context:
|
# - context:
|
||||||
|
|
||||||
/opt/gentoo-rsync/rsync-gentoo-portage.sh:
|
/opt/gentoo-mirror/rsync-gentoo-portage.sh:
|
||||||
file.symlink:
|
file.symlink:
|
||||||
- target: /opt/gentoo-rsync/rsync-base.sh
|
- target: /opt/gentoo-mirror/rsync-base.sh
|
||||||
- require:
|
- require:
|
||||||
- file: /opt/gentoo-rsync/rsync-base.sh
|
- file: /opt/gentoo-mirror/rsync-base.sh
|
||||||
|
|
||||||
rsync-gentoo-portage:
|
rsync-gentoo-portage:
|
||||||
cron.present:
|
cron.present:
|
||||||
- identifier: rsync-gentoo-portage
|
- identifier: rsync-gentoo-portage
|
||||||
- name: /opt/gentoo-rsync/rsync-gentoo-portage.sh
|
- name: /opt/gentoo-mirror/rsync-gentoo-portage.sh
|
||||||
- user: root
|
- user: root
|
||||||
- minute: 0
|
- minute: 0
|
||||||
- hour: '*/4'
|
- hour: '*/4'
|
||||||
- require:
|
- require:
|
||||||
- file: /etc/rsync/rsync-gentoo-portage.conf
|
- file: /etc/gentoo-mirror/rsync-gentoo-portage.conf
|
||||||
- file: /opt/gentoo-rsync/rsync-gentoo-portage.sh
|
- file: /opt/gentoo-mirror/rsync-gentoo-portage.sh
|
||||||
|
|
||||||
/etc/rsyncd.d/gentoo-portage.conf:
|
/etc/rsyncd.d/gentoo-portage.conf:
|
||||||
ini.options_present:
|
ini.options_present:
|
||||||
@ -147,20 +164,20 @@ rsync-gentoo-portage:
|
|||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
{% for inst in salt['pillar.get']('gentoo-mirror:gentoo-package-repos', []) %}
|
{% for inst in salt['pillar.get']('gentoo-mirror:gentoo-package-repos', []) %}
|
||||||
/opt/gentoo-rsync/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.sh:
|
/opt/gentoo-mirror/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.sh:
|
||||||
file.symlink:
|
file.symlink:
|
||||||
- target: /opt/gentoo-rsync/rsync-base.sh
|
- target: /opt/gentoo-mirror/rsync-base.sh
|
||||||
- require:
|
- require:
|
||||||
- file: /opt/gentoo-rsync/rsync-base.sh
|
- file: /opt/gentoo-mirror/rsync-base.sh
|
||||||
|
|
||||||
"{{ default_root }}/{{ inst.get('rsync_dst', 'gentoo-packages/'+inst['arch']+'/'+inst['cpu_arch']) }}":
|
"{{ default_root }}/{{ inst.get('rsync_dst', 'gentoo-packages/'+inst['arch']+'/'+inst['cpu_arch']) }}":
|
||||||
file.directory:
|
file.directory:
|
||||||
- create: True
|
- create: True
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
/etc/rsync/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.conf:
|
/etc/gentoo-mirror/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://gentoo-mirrors/files/rsync-conf.tpl
|
- source: salt://{{ slspath }}/files/rsync-conf.tpl
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
rsync_src: "{{ inst.get('rsync_src', 'rsync://'+mirror_host+'/gentoo-packages/'+inst['arch']+'/'+inst['cpu_arch']) }}"
|
rsync_src: "{{ inst.get('rsync_src', 'rsync://'+mirror_host+'/gentoo-packages/'+inst['arch']+'/'+inst['cpu_arch']) }}"
|
||||||
@ -169,14 +186,14 @@ rsync-gentoo-portage:
|
|||||||
rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages:
|
rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages:
|
||||||
cron.present:
|
cron.present:
|
||||||
- identifier: rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages
|
- identifier: rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages
|
||||||
- name: /opt/gentoo-rsync/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.sh
|
- name: /opt/gentoo-mirror/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.sh
|
||||||
- user: root
|
- user: root
|
||||||
- dayweek: "{{ inst.get('day','*') }}"
|
- dayweek: "{{ inst.get('day','*') }}"
|
||||||
- hour: "{{ inst.get('hour','*/4') }}"
|
- hour: "{{ inst.get('hour','*/4') }}"
|
||||||
- minute: "{{ inst.get('minute','0') }}"
|
- minute: "{{ inst.get('minute','0') }}"
|
||||||
- require:
|
- require:
|
||||||
- file: /etc/rsync/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.conf
|
- file: /etc/gentoo-mirror/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.conf
|
||||||
- file: /opt/gentoo-rsync/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.sh
|
- file: /opt/gentoo-mirror/rsync-gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.sh
|
||||||
|
|
||||||
/etc/rsyncd.d/gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.conf:
|
/etc/rsyncd.d/gentoo-{{ inst['arch'] }}-{{ inst['cpu_arch'] }}-packages.conf:
|
||||||
ini.options_present:
|
ini.options_present:
|
35
sls/nginx/tls/gentoo-mirror.sls
Normal file
35
sls/nginx/tls/gentoo-mirror.sls
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{%- set cert_chain_key = salt.pillar.get('gentoo-mirror:cert-chain-key', 'gentoo-mirror') %}
|
||||||
|
{%- set privkey_key = salt.pillar.get('gentoo-mirror:privkey-key', cert_chain_key) %}
|
||||||
|
include:
|
||||||
|
- nginx
|
||||||
|
|
||||||
|
/etc/ssl/nginx/gentoo-mirror/:
|
||||||
|
file.directory:
|
||||||
|
- create: True
|
||||||
|
- mode: 750
|
||||||
|
- user: root
|
||||||
|
- group: nginx
|
||||||
|
|
||||||
|
/etc/ssl/nginx/gentoo-mirror/certificate.pem:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://ssl/certificate-chain.tpl
|
||||||
|
- template: jinja
|
||||||
|
- defaults:
|
||||||
|
cert_chain_key: "{{ cert_chain_key }}"
|
||||||
|
- mode: 644
|
||||||
|
- user: root
|
||||||
|
- group: nginx
|
||||||
|
- watch_in:
|
||||||
|
- service: nginx-reload
|
||||||
|
|
||||||
|
/etc/ssl/nginx/gentoo-mirror/privkey.pem:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://ssl/privkey.tpl
|
||||||
|
- template: jinja
|
||||||
|
- defaults:
|
||||||
|
privkey_key: "{{ privkey_key }}"
|
||||||
|
- mode: 600
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- watch_in:
|
||||||
|
- service: nginx-reload
|
Loading…
Reference in New Issue
Block a user