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:
		| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
		Reference in New Issue
	
	Block a user