--- # Set the cluster into maintenance mode - hosts: all remote_user: deploy become: yes become_user: root gather_facts: yes tasks: - name: set PVC maintenance mode command: pvc cluster maintenance on run_once: yes ignore_errors: yes # 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 - hosts: all remote_user: deploy become: yes become_user: root gather_facts: yes serial: 1 tasks: - name: install latest PVC packages apt: update_cache: yes autoremove: yes autoclean: yes package: - gunicorn - python3-gunicorn - python3-setuptools - pvc-client-cli - pvc-daemon-common - pvc-daemon-api - pvc-daemon-node - pvc-daemon-health - pvc-daemon-worker state: latest dpkg_options: "force-all" register: packages - name: clean apt archives file: dest: /var/cache/apt/archives state: absent - name: clean pycaches command: 'find /usr/share/pvc -name "__pycache__" -exec rm -r {} \;' ignore_errors: true - name: restart daemons cleanly block: - name: secondary node command: 'pvc node secondary --wait {{ ansible_hostname }}' ignore_errors: true - name: wait 15 seconds for system to stabilize pause: seconds: 15 become: no connection: local - name: restart PVC node daemons service: name: "{{ item }}" state: restarted enabled: yes with_items: - pvcnoded - pvcworkerd - pvchealthd - name: wait 15 seconds for system to stabilize pause: seconds: 15 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 - pvcworkerd.service - name: reset any systemd failures command: systemctl reset-failed when: packages.changed - name: wait 15 seconds for system to stabilize pause: seconds: 15 become: no connection: local # Set the cluster out of maintenance mode - hosts: all remote_user: deploy become: yes become_user: root gather_facts: yes tasks: - name: restart PVC supplemental node daemons for schema updates service: name: "{{ item }}" state: restarted with_items: - pvcworkerd - pvchealthd - name: become primary on first node command: pvc node primary --wait run_once: yes - name: apply database migrations on first node (safe upgrades prevented this in dpkg) command: /usr/share/pvc/pvc-api-db-upgrade run_once: yes - name: restart API daemon to apply database migrations service: name: "{{ item }}" state: restarted with_items: - pvcapid run_once: yes - name: wait 15 seconds for system to stabilize pause: seconds: 15 become: no connection: local - name: unset PVC maintenance mode on first node command: pvc cluster maintenance off run_once: yes # 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 when: pvc_config_check.stat.exists and pvc_version_check.rc == 0