|
67 | 67 | when:
|
68 | 68 | - "_pve_active_cluster is not defined"
|
69 | 69 | - "inventory_hostname != groups[pve_group][0]"
|
| 70 | + |
| 71 | +- name: Check for PVE cluster HA groups |
| 72 | + proxmox_query: |
| 73 | + query: "/cluster/ha/groups" |
| 74 | + register: _ha_group_list |
| 75 | + when: "inventory_hostname == groups[pve_group][0]" |
| 76 | + |
| 77 | +- name: Create PVE cluster HA groups |
| 78 | + command: >- |
| 79 | + ha-manager groupadd {{ item.name }} |
| 80 | + -comment "{{ item.comment | default('') }}" |
| 81 | + -nodes "{{ item.nodes }}" |
| 82 | + {% if 'nofailback' in item %} |
| 83 | + -nofailback {{ item.nofailback }} |
| 84 | + {% endif %} |
| 85 | + {% if 'restricted' in item %} |
| 86 | + -restricted {{ item.restricted }} |
| 87 | + {% endif %} |
| 88 | + when: |
| 89 | + - "inventory_hostname == groups[pve_group][0]" |
| 90 | + - item.name not in _ha_group_list.response | json_query("[*].group") |
| 91 | + with_items: "{{ pve_cluster_ha_groups }}" |
| 92 | + |
| 93 | +- name: Update PVE cluster HA groups |
| 94 | + command: >- |
| 95 | + ha-manager groupset {{ item.0.name }} -{{ item.1 }} "{{ item.0[item.1] }}" |
| 96 | + when: |
| 97 | + - "inventory_hostname == groups[pve_group][0]" |
| 98 | + - item.0.name in _ha_group_list.response | json_query("[*].group") |
| 99 | + - item.1 in item.0 |
| 100 | + - item.0[item.1] != _ha_group_list.response |
| 101 | + | json_query("[?group=='" + item.0.name + "']." + item.1) | first |
| 102 | + loop: "{{ pve_cluster_ha_groups |
| 103 | + | product(['comment', 'nodes', 'nofailback', 'restricted']) | list }}" |
0 commit comments