Last active
October 20, 2025 01:07
-
-
Save Thalagyrt/bd553cc1e2cc4af265e5b3effa4530a2 to your computer and use it in GitHub Desktop.
Ansible playbook to roll a Proxmox+Ceph cluster one by one, waiting for health and migrations before proceeding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2025 James Riley | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| # | |
| # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| --- | |
| - hosts: servers | |
| serial: 1 | |
| tasks: | |
| - name: Enter maintenance mode | |
| command: ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }} | |
| - name: Wait for evacuation | |
| command: pgrep -f qemu | |
| register: qemu_process_check | |
| until: qemu_process_check.rc != 0 | |
| retries: 30 | |
| delay: 30 | |
| changed_when: false | |
| failed_when: qemu_process_check.rc == 0 and qemu_process_check.stderr != "" | |
| - name: Update apt repo and cache | |
| apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 | |
| - name: Upgrade all packages | |
| apt: upgrade=dist force_apt_get=yes | |
| - name: Reboot host | |
| reboot: | |
| reboot_timeout: 600 | |
| - name: Wait for Ceph cluster to be healthy | |
| ansible.builtin.shell: ceph health | |
| register: ceph_health_status | |
| until: "'HEALTH_OK' in ceph_health_status.stdout" | |
| retries: 30 | |
| delay: 10 | |
| failed_when: "'HEALTH_WARN' in ceph_health_status.stdout or 'HEALTH_ERR' in ceph_health_status.stdout" | |
| - name: Autoremove old packages | |
| apt: autoremove=yes | |
| - name: Exit maintenance mode | |
| command: ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }} | |
| - name: Wait for at least one running guest | |
| command: pgrep -f qemu | |
| register: qemu_process_check | |
| until: qemu_process_check.rc == 0 | |
| retries: 30 | |
| delay: 30 | |
| changed_when: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment