testing new proxmox logic
This commit is contained in:
50
playbooks/proxmox_ha.yml
Normal file
50
playbooks/proxmox_ha.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
# =============================================================================
|
||||
# proxmox_ha.yml
|
||||
# HA group membership and maintenance mode management.
|
||||
#
|
||||
# Actions:
|
||||
# status — show current HA status for all nodes and services
|
||||
# disable — put a node into HA maintenance mode (VMs migrate away)
|
||||
# enable — take a node out of HA maintenance mode (resume normal HA)
|
||||
#
|
||||
# Usage:
|
||||
# # Check HA status
|
||||
# ansible-playbook proxmox_ha.yml -e "ha_action=status"
|
||||
#
|
||||
# # Put node into maintenance before work
|
||||
# ansible-playbook proxmox_ha.yml -e "ha_action=disable ha_target_node=pm-node-01"
|
||||
#
|
||||
# # Resume HA after work is complete
|
||||
# ansible-playbook proxmox_ha.yml -e "ha_action=enable ha_target_node=pm-node-01"
|
||||
# =============================================================================
|
||||
|
||||
- name: "Proxmox | HA Management"
|
||||
hosts: proxmox_cluster
|
||||
gather_facts: false
|
||||
|
||||
vars:
|
||||
ha_action: status
|
||||
ha_target_node: "{{ inventory_hostname }}"
|
||||
|
||||
pre_tasks:
|
||||
- name: "HA | Validate action"
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Invalid ha_action '{{ ha_action }}'.
|
||||
Must be one of: status, disable, enable.
|
||||
when: ha_action not in ['status', 'disable', 'enable']
|
||||
run_once: true
|
||||
|
||||
- name: "HA | Log action"
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
HA {{ ha_action }} —
|
||||
client={{ client_name | default('Unknown') }}
|
||||
{% if ha_action in ['disable', 'enable'] %}node={{ ha_target_node }}{% endif %}
|
||||
run_once: true
|
||||
|
||||
roles:
|
||||
- role: proxmox_ha
|
||||
vars:
|
||||
current_node: "{{ ha_target_node }}"
|
||||
Reference in New Issue
Block a user