Compare commits

..

5 Commits

5 changed files with 49 additions and 8 deletions

View File

@ -20,3 +20,8 @@ minecraft_var_path: /var/opt/minecraft
minecraft_syslog_facility: local5 minecraft_syslog_facility: local5
minecraft_notifier_state: present minecraft_notifier_state: present
minecraft_config:
white-list: true
enforce-whitelist: true
server-port: 25565

View File

@ -1,3 +1,5 @@
white-list: {{ (minecraft_config.whitelist | default(true)) | ternary('true', 'false') }} # {{ ansible_managed }}
enforce-whitelist: {{ (minecaft_config.enfoce_whitelist | default(true)) | ternary('true', 'false') }}
server-port: {{ item.port | default(25565) }} {% for k, v in minecraft_config.items() | default({}) %}
{{ k }}: {{ v }}
{% endfor %}

View File

@ -65,6 +65,8 @@ if [ -z "${PATHS+x}" ]; then
error_exit "\$PATHS is not set" error_exit "\$PATHS is not set"
fi fi
START="$(date +%s)"
if [ -f "$LOCK" ]; then if [ -f "$LOCK" ]; then
pid=$(cat "$LOCK") pid=$(cat "$LOCK")
if ! kill -0 "$pid" 2> /dev/null; then if ! kill -0 "$pid" 2> /dev/null; then
@ -86,6 +88,8 @@ fi
echo $$ > "$LOCK" echo $$ > "$LOCK"
LOCKED=$(($(date +%s) - START))
printf "job '%s' started\n" "$JOB" printf "job '%s' started\n" "$JOB"
if [ -d "${HOOKS_PATH}" ]; then if [ -d "${HOOKS_PATH}" ]; then
@ -111,7 +115,9 @@ until [ $counter -eq "$MAX_ATTEMPTS" ] || [ $rc -eq 0 ]; do
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -eq 0 ]; then
break
else
sleep=$((counter * 5)) sleep=$((counter * 5))
printf "sleeping for %d seconds (%d)\n" $sleep $counter printf "sleeping for %d seconds (%d)\n" $sleep $counter
sleep $sleep sleep $sleep
@ -131,3 +137,25 @@ if [ -d "${HOOKS_PATH}" ]; then
printf "running '%s' job post-hooks\n" "$JOB" printf "running '%s' job post-hooks\n" "$JOB"
run-parts --exit-on-error -v -a post "${HOOKS_PATH}" run-parts --exit-on-error -v -a post "${HOOKS_PATH}"
fi fi
END=$(date +%s)
if [ -d /var/spool/node_exporter/textfile_collector ]; then
cat << EOF > "/var/spool/node_exporter/textfile_collector/restic.prom.$$"
node_restic_duration_seconds{restic_job="${JOB}"} $((END - START))
node_restic_lock_duration_seconds{restic_job="${JOB}"} $LOCKED
node_restic_last_run_time{restic_job="${JOB}"} $END
node_restic_retries{restic_job="${JOB}"} $counter
EOF
if [ -f /var/spool/node_exporter/textfile_collector/restic.prom ]; then
cat /var/spool/node_exporter/textfile_collector/restic.prom "/var/spool/node_exporter/textfile_collector/restic.prom.$$" |
tac |
awk '!seen[$1]++' |
tac |
sponge "/var/spool/node_exporter/textfile_collector/restic.prom.$$"
fi
mv "/var/spool/node_exporter/textfile_collector/restic.prom.$$" \
/var/spool/node_exporter/textfile_collector/restic.prom
fi

View File

@ -77,5 +77,7 @@
minute: "0" minute: "0"
hour: "2" hour: "2"
user: root user: root
job: find /var/log/syslog/ -mindepth 4 -type f -name "*.log" -mtime +90 -delete job: >
find /var/log/syslog/ -mindepth 4 -type f -name "*.log.xz" -mtime +90 -delete &&
find /var/log/syslog/ -mindepth 3 -type d -empty -delete
state: "{{ rsyslog_archival_format_enabled | ternary('present', 'absent') }}" state: "{{ rsyslog_archival_format_enabled | ternary('present', 'absent') }}"

View File

@ -28,6 +28,7 @@ util_packages:
- traceroute - traceroute
- iperf - iperf
- iperf3 - iperf3
- smem
math: math:
- bc - bc
misc: misc:
@ -45,6 +46,8 @@ util_packages:
- htop - htop
- iotop - iotop
- iftop - iftop
- atop
- glances
- lsof - lsof
- sysdig - sysdig
- dstat - dstat
@ -52,6 +55,7 @@ util_packages:
- gnupg - gnupg
- pass - pass
- pwgen - pwgen
- apache2-utils
text: text:
- jq - jq
- crudini - crudini