Skip to content

Commit

Permalink
Merge pull request #219 from btravouillon/fix/update_ha_groups
Browse files Browse the repository at this point in the history
Fix host used to configure HA groups
  • Loading branch information
lae authored Mar 15, 2024
2 parents 341a098 + b26e8e7 commit 33685a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,23 @@
state: "{{ item.state | default('present') }}"
comment: "{{ item.comment | default(omit) }}"
with_items: "{{ pve_pools }}"
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"

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

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

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

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

- name: Create ZFS Pools
zfs:
Expand Down Expand Up @@ -301,15 +301,15 @@
thinpool: "{{ item.thinpool | default(omit) }}"
sparse: "{{ item.sparse | default(omit) }}"
with_items: "{{ pve_storages }}"
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == groups[pve_group][0])"
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
tags: storage

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

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

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

- import_tasks: ssl_config.yml
Expand Down
6 changes: 3 additions & 3 deletions tasks/pve_cluster_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
proxmox_query:
query: "/cluster/ha/groups"
register: _ha_group_list
when: "inventory_hostname == groups[pve_group][0]"
when: "inventory_hostname == _init_node"

- name: Create PVE cluster HA groups
command: >-
Expand All @@ -94,15 +94,15 @@
-restricted {{ item.restricted }}
{% endif %}
when:
- "inventory_hostname == groups[pve_group][0]"
- "inventory_hostname == _init_node"
- item.name not in _ha_group_list.response | json_query("[*].group")
with_items: "{{ pve_cluster_ha_groups }}"

- name: Update PVE cluster HA groups
command: >-
ha-manager groupset {{ item.0.name }} -{{ item.1 }} "{{ item.0[item.1] }}"
when:
- "inventory_hostname == groups[pve_group][0]"
- "inventory_hostname == _init_node"
- item.0.name in _ha_group_list.response | json_query("[*].group")
- item.1 in item.0
- item.0[item.1] != _ha_group_list.response
Expand Down

0 comments on commit 33685a8

Please sign in to comment.