From d6cb28b6393b938bf6044d07771a3df1585cc7ea Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:28 -0400 Subject: [PATCH] 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. --- roles/pvc/handlers/main.yml | 10 --------- roles/pvc/tasks/pvc/main.yml | 11 +--------- roles/pvc/templates/pvc/pvc-vacuum.j2 | 31 --------------------------- 3 files changed, 1 insertion(+), 51 deletions(-) delete mode 100755 roles/pvc/templates/pvc/pvc-vacuum.j2 diff --git a/roles/pvc/handlers/main.yml b/roles/pvc/handlers/main.yml index 1c8bfeb..d165e02 100644 --- a/roles/pvc/handlers/main.yml +++ b/roles/pvc/handlers/main.yml @@ -40,13 +40,3 @@ - name: restart ceph-mgr shell: "{% if is_coordinator %}sleep {{ 30 * (hostvars[inventory_hostname].ansible_local.host_id|int - 1) }} && systemctl restart ceph-mgr@{{ this_node }}.service{% endif %}" ignore_errors: true - -- name: restart pvcnoded - shell: "{% if is_coordinator %}sleep {{ 30 * (hostvars[inventory_hostname].ansible_local.host_id|int - 1) }} &&{% endif %} systemctl restart pvcnoded.service" - ignore_errors: true - when: bootstrap is not defined - -- name: restart pvcapid - shell: "{% if is_coordinator %}sleep {{ 30 * (hostvars[inventory_hostname].ansible_local.host_id|int - 1) }} &&{% endif %} systemctl restart pvcapid.service" - ignore_errors: true - when: bootstrap is not defined diff --git a/roles/pvc/tasks/pvc/main.yml b/roles/pvc/tasks/pvc/main.yml index f645fd4..6ebd154 100644 --- a/roles/pvc/tasks/pvc/main.yml +++ b/roles/pvc/tasks/pvc/main.yml @@ -10,13 +10,12 @@ - ethtool - jq state: latest + when: bootstrap is defined and bootstrap - name: install pvc node daemon configuration template: src: pvc/{{ item }}.j2 dest: /etc/pvc/{{ item }} - notify: - - restart pvcnoded with_items: - pvcnoded.yaml @@ -24,8 +23,6 @@ template: src: pvc/{{ item }}.j2 dest: /etc/pvc/{{ item }} - notify: - - restart pvcapid with_items: - pvcapid.yaml @@ -55,12 +52,6 @@ run_once: yes when: bootstrap is defined and bootstrap and is_coordinator -- name: install daily vacuum script - template: - src: pvc/pvc-vacuum.j2 - dest: /etc/cron.daily/pvc-vacuum - mode: 0755 - - meta: flush_handlers - name: ensure services are started and running diff --git a/roles/pvc/templates/pvc/pvc-vacuum.j2 b/roles/pvc/templates/pvc/pvc-vacuum.j2 deleted file mode 100755 index 2b0fd1b..0000000 --- a/roles/pvc/templates/pvc/pvc-vacuum.j2 +++ /dev/null @@ -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