Skip to content

Commit 33685a8

Browse files
authored
Merge pull request #219 from btravouillon/fix/update_ha_groups
Fix host used to configure HA groups
2 parents 341a098 + b26e8e7 commit 33685a8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

tasks/main.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,23 @@
216216
state: "{{ item.state | default('present') }}"
217217
comment: "{{ item.comment | default(omit) }}"
218218
with_items: "{{ pve_pools }}"
219-
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
219+
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
220220

221221
- name: Configure Proxmox roles
222222
proxmox_role:
223223
name: "{{ item.name }}"
224224
privileges: "{{ item.privileges }}"
225225
state: "{{ item.state | default('present') }}"
226226
with_items: "{{ pve_roles }}"
227-
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
227+
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
228228

229229
- name: Configure Proxmox groups
230230
proxmox_group:
231231
name: "{{ item.name }}"
232232
state: "{{ item.state | default('present') }}"
233233
comment: "{{ item.comment | default(omit) }}"
234234
with_items: "{{ pve_groups }}"
235-
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
235+
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
236236

237237
- name: Configure Proxmox user accounts
238238
proxmox_user:
@@ -247,7 +247,7 @@
247247
password: "{{ item.password | default(omit) }}"
248248
expire: "{{ item.expire | default(omit) }}"
249249
with_items: "{{ pve_users }}"
250-
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
250+
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
251251

252252
- name: Configure Proxmox ACLs
253253
proxmox_acl:
@@ -257,7 +257,7 @@
257257
groups: "{{ item.groups | default([]) }}"
258258
users: "{{ item.users | default([]) }}"
259259
with_items: "{{ pve_acls }}"
260-
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
260+
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
261261

262262
- name: Create ZFS Pools
263263
zfs:
@@ -301,15 +301,15 @@
301301
thinpool: "{{ item.thinpool | default(omit) }}"
302302
sparse: "{{ item.sparse | default(omit) }}"
303303
with_items: "{{ pve_storages }}"
304-
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
304+
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
305305
tags: storage
306306

307307
- name: Check datacenter.cfg exists
308308
stat:
309309
path: "/etc/pve/datacenter.cfg"
310310
register: _datacenter_cfg
311311
when:
312-
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
312+
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
313313
- "pve_datacenter_cfg | length > 0"
314314

315315
- name: Create datacenter.cfg if it does not exist
@@ -318,7 +318,7 @@
318318
state: "touch"
319319
mode: 0640
320320
when:
321-
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
321+
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
322322
- "pve_datacenter_cfg | length > 0"
323323
- "not _datacenter_cfg.stat.exists"
324324

@@ -333,7 +333,7 @@
333333
{{ k }}: {{ v }}
334334
{% endfor %}
335335
when:
336-
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
336+
- "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
337337
- "pve_datacenter_cfg | length > 0"
338338

339339
- import_tasks: ssl_config.yml

tasks/pve_cluster_config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
proxmox_query:
8181
query: "/cluster/ha/groups"
8282
register: _ha_group_list
83-
when: "inventory_hostname == groups[pve_group][0]"
83+
when: "inventory_hostname == _init_node"
8484

8585
- name: Create PVE cluster HA groups
8686
command: >-
@@ -94,15 +94,15 @@
9494
-restricted {{ item.restricted }}
9595
{% endif %}
9696
when:
97-
- "inventory_hostname == groups[pve_group][0]"
97+
- "inventory_hostname == _init_node"
9898
- item.name not in _ha_group_list.response | json_query("[*].group")
9999
with_items: "{{ pve_cluster_ha_groups }}"
100100

101101
- name: Update PVE cluster HA groups
102102
command: >-
103103
ha-manager groupset {{ item.0.name }} -{{ item.1 }} "{{ item.0[item.1] }}"
104104
when:
105-
- "inventory_hostname == groups[pve_group][0]"
105+
- "inventory_hostname == _init_node"
106106
- item.0.name in _ha_group_list.response | json_query("[*].group")
107107
- item.1 in item.0
108108
- item.0[item.1] != _ha_group_list.response

0 commit comments

Comments
 (0)