Add immutability to PVC subrole

1. Remove the obsolete pvc-vacuum script install.

2. Remove notifies when modifying configs; we do not want to restart the
daemons uncontrolled.

3. Add bootstrap check to package installs so they only happen on
bootstrap.

This ensures this part of the role, on re-runs, will *only* update
configs and not actually touch the running daemon. This makes it safe to
run before a oneshot/update-pvc-daemons.yml playbook run.
This commit is contained in:
Joshua Boniface
2021-11-15 10:49:03 -05:00
parent bb3b7e3922
commit bea79b5102
3 changed files with 1 additions and 51 deletions

View File

@ -1,31 +0,0 @@
#!/bin/bash
# Daily vaccuum script for PVC daemons
# {{ ansible_managed }}
# This script cleans up the PostgreSQL databases as well as the Zookeeper
# database. This prevents filesystem growth balooning after loong running
# periods.
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
echo -e "$( date )" &>>/var/log/pvc/vacuum.log
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
#
# PostgreSQL
#
# Don't run if we aren't the Patroni primary
HOSTNAME="$( hostname -s )"
PRIMARY="$( patronictl -c /etc/patroni/config.yml -d zookeeper://localhost:2181 list --format json \
| jq -r '.[] | select(.Role == "Leader") | .Member' )"
if [[ $HOSTNAME == $PRIMARY ]]; then
# Analyze the database
su postgres -c 'vacuumdb --verbose --analyze --all' &>>/var/log/pvc/vacuum.log
fi
#
# Zookeeper
#
export ZOOCFG=/etc/zookeeper/conf/zoo.cfg
/usr/share/zookeeper/bin/zkCleanup.sh -n 7 &>>/var/log/pvc/vacuum.log