2023-09-01 15:42:25 -04:00
|
|
|
---
|
2023-12-01 01:37:39 -05:00
|
|
|
# Set the cluster into maintenance mode
|
2023-09-01 15:42:25 -04:00
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
tasks:
|
2023-09-01 15:42:29 -04:00
|
|
|
- name: set PVC maintenance mode (legacy)
|
2023-09-01 15:42:25 -04:00
|
|
|
command: pvc maintenance on
|
2023-09-01 15:42:28 -04:00
|
|
|
run_once: yes
|
2023-09-01 15:42:29 -04:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: set PVC maintenance mode
|
|
|
|
command: pvc cluster maintenance on
|
|
|
|
run_once: yes
|
|
|
|
ignore_errors: yes
|
2023-09-01 15:42:25 -04:00
|
|
|
|
2023-12-01 01:37:39 -05:00
|
|
|
# Run the PVC daemon role against the system (update pvc.conf)
|
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
tasks:
|
|
|
|
- set_fact:
|
|
|
|
this_node: "{{ inventory_hostname.split('.')[0] }}"
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
is_coordinator: "{% for node in pvc_nodes if node.hostname == this_node %}{{ node.is_coordinator }}{% endfor %}"
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
new_host: no
|
|
|
|
|
|
|
|
- name: import PVC daemon role
|
|
|
|
include_role:
|
|
|
|
name: pvc
|
|
|
|
tasks_from: pvc/main.yml
|
|
|
|
|
|
|
|
# Install the latest PVC packages & restart daemons to apply
|
2023-09-01 15:42:28 -04:00
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
serial: 1
|
|
|
|
tasks:
|
2023-09-01 15:42:25 -04:00
|
|
|
- name: install latest PVC packages
|
|
|
|
apt:
|
|
|
|
update_cache: yes
|
|
|
|
autoremove: yes
|
|
|
|
autoclean: yes
|
|
|
|
package:
|
|
|
|
- pvc-client-cli
|
|
|
|
- pvc-daemon-common
|
|
|
|
- pvc-daemon-api
|
|
|
|
- pvc-daemon-node
|
2023-12-09 23:59:42 -05:00
|
|
|
- pvc-daemon-health
|
|
|
|
- pvc-daemon-worker
|
2023-09-01 15:42:25 -04:00
|
|
|
state: latest
|
2023-12-10 00:04:02 -05:00
|
|
|
dpkg_options: "force-all"
|
2023-09-01 15:42:25 -04:00
|
|
|
register: packages
|
|
|
|
|
|
|
|
- name: clean apt archives
|
|
|
|
file:
|
|
|
|
dest: /var/cache/apt/archives
|
|
|
|
state: absent
|
2023-11-25 00:51:13 -05:00
|
|
|
|
|
|
|
- name: clean pycaches
|
|
|
|
command: 'find /usr/share/pvc -name "__pycache__" -exec rm -r {} \;'
|
|
|
|
ignore_errors: true
|
|
|
|
|
2023-09-01 15:42:26 -04:00
|
|
|
- name: restart daemons cleanly
|
2023-09-01 15:42:25 -04:00
|
|
|
block:
|
|
|
|
- name: secondary node
|
2023-09-01 15:42:30 -04:00
|
|
|
command: 'pvc node secondary --wait {{ ansible_hostname }}'
|
2023-09-01 15:42:25 -04:00
|
|
|
ignore_errors: true
|
|
|
|
|
2023-09-01 15:42:26 -04:00
|
|
|
- name: wait 15 seconds for system to stabilize
|
2023-09-01 15:42:25 -04:00
|
|
|
pause:
|
2023-09-01 15:42:26 -04:00
|
|
|
seconds: 15
|
2023-09-01 15:42:25 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
2023-12-10 00:13:42 -05:00
|
|
|
- name: restart PVC node daemons
|
2023-09-01 15:42:25 -04:00
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|
|
|
|
with_items:
|
|
|
|
- pvcnoded
|
2023-12-10 00:13:42 -05:00
|
|
|
- pvcworkerd
|
|
|
|
- pvchealthd
|
2023-09-01 15:42:25 -04:00
|
|
|
|
2023-09-01 15:42:26 -04:00
|
|
|
- name: wait 15 seconds for system to stabilize
|
2023-09-01 15:42:25 -04:00
|
|
|
pause:
|
2023-09-01 15:42:26 -04:00
|
|
|
seconds: 15
|
2023-09-01 15:42:25 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- name: get service facts
|
|
|
|
service_facts:
|
|
|
|
|
|
|
|
- name: fail if PVC daemons are not running
|
|
|
|
fail:
|
|
|
|
msg: "PVC daemons are not running"
|
|
|
|
when: ansible_facts.services[item] is not defined or ansible_facts.services[item]["state"] != "running"
|
|
|
|
with_items:
|
|
|
|
- pvcnoded.service
|
2023-11-15 20:32:23 -05:00
|
|
|
- pvcworkerd.service
|
2023-09-01 15:42:25 -04:00
|
|
|
|
|
|
|
- name: reset any systemd failures
|
|
|
|
command: systemctl reset-failed
|
|
|
|
when: packages.changed
|
|
|
|
|
2023-09-01 15:42:26 -04:00
|
|
|
- name: wait 15 seconds for system to stabilize
|
2023-09-01 15:42:25 -04:00
|
|
|
pause:
|
2023-09-01 15:42:26 -04:00
|
|
|
seconds: 15
|
2023-09-01 15:42:25 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
2023-09-01 15:42:28 -04:00
|
|
|
|
2023-12-01 01:37:39 -05:00
|
|
|
# Set the cluster out of maintenance mode
|
2023-09-01 15:42:28 -04:00
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
tasks:
|
|
|
|
- name: unset PVC maintenance mode
|
2023-09-01 15:42:29 -04:00
|
|
|
command: pvc cluster maintenance off
|
2023-09-01 15:42:28 -04:00
|
|
|
run_once: yes
|
2023-12-01 02:14:07 -05:00
|
|
|
|
|
|
|
# Clean up legacy configs if safe to do so
|
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
tasks:
|
|
|
|
- name: check if new configuration exists
|
|
|
|
stat:
|
|
|
|
path: /etc/pvc/pvc.conf
|
|
|
|
register: pvc_config_check
|
|
|
|
|
|
|
|
- name: check if installed PVC version is above 0.9.82
|
|
|
|
shell: "dpkg --compare-versions $(dpkg-query --showformat='${Version}' --show pvc-daemon-node) gt 0.9.82"
|
|
|
|
register: pvc_version_check
|
|
|
|
|
|
|
|
- name: remove obsolete PVC daemon configurations
|
|
|
|
file:
|
|
|
|
dest: "/etc/pvc/{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- pvcnoded.yaml
|
|
|
|
- pvcapid.yaml
|
|
|
|
- autobackup.yaml
|
2023-12-10 00:07:08 -05:00
|
|
|
when: pvc_config_check.stat.exists and pvc_version_check.rc == 0
|