fix: proxmox_upgrade preflight delegate_to and run_once
This commit is contained in:
@@ -2,14 +2,15 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
# proxmox_upgrade — preflight.yml
|
# proxmox_upgrade — preflight.yml
|
||||||
# Check cluster health before starting any upgrade work
|
# Check cluster health before starting any upgrade work
|
||||||
# Runs delegate_to: first node in upgrade_order
|
# All tasks delegate_to: localhost — uses API only
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
- name: Preflight | Check all cluster nodes are online
|
- name: Preflight | Check quorum via pvecm
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
pvecm status 2>/dev/null | grep -E "^Nodes|Quorate"
|
pvecm status 2>/dev/null | grep -i "quorate" | grep -i "yes"
|
||||||
register: pvecm_status
|
register: quorum_check
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
failed_when: quorum_check.rc != 0
|
||||||
|
|
||||||
- name: Preflight | Get cluster node status via API
|
- name: Preflight | Get cluster node status via API
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
validate_certs: false
|
validate_certs: false
|
||||||
register: cluster_nodes
|
register: cluster_nodes
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Preflight | Check all nodes are online
|
- name: Preflight | Check all nodes are online
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
@@ -29,24 +31,17 @@
|
|||||||
loop: "{{ cluster_nodes.json.data }}"
|
loop: "{{ cluster_nodes.json.data }}"
|
||||||
when: item.status != 'online'
|
when: item.status != 'online'
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
run_once: true
|
||||||
- name: Preflight | Check quorum via pvecm
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
pvecm status 2>/dev/null | grep -i "quorate" | grep -i "yes"
|
|
||||||
register: quorum_check
|
|
||||||
changed_when: false
|
|
||||||
failed_when: quorum_check.rc != 0
|
|
||||||
|
|
||||||
- name: Preflight | Check CEPH health
|
- name: Preflight | Check CEPH health
|
||||||
when: ceph_enabled | bool
|
when: ceph_enabled | bool
|
||||||
block:
|
block:
|
||||||
- name: Preflight | Get CEPH health status
|
- name: Preflight | Get CEPH health status
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: ceph health 2>/dev/null
|
||||||
ceph health 2>/dev/null
|
|
||||||
register: ceph_health
|
register: ceph_health
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Preflight | Abort if CEPH is not healthy
|
- name: Preflight | Abort if CEPH is in error state
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: >
|
msg: >
|
||||||
CEPH health check FAILED — status: {{ ceph_health.stdout }}.
|
CEPH health check FAILED — status: {{ ceph_health.stdout }}.
|
||||||
@@ -60,5 +55,7 @@
|
|||||||
|
|
||||||
- name: Preflight | Cluster health check passed
|
- name: Preflight | Cluster health check passed
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Cluster health check passed — all nodes online, quorum OK{{ ', CEPH checked' if ceph_enabled else '' }}"
|
msg: "Cluster health check passed — all {{ cluster_nodes.json.data | length }} nodes online, quorum OK{{ ', CEPH checked' if ceph_enabled else '' }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user