From b26e8e7267455d72dbfbb7b1f5456f89bdf4ccaa Mon Sep 17 00:00:00 2001 From: lae Date: Fri, 15 Mar 2024 23:11:34 +0900 Subject: [PATCH] Use `_init_node` instead of `groups[pve_group][0]` for all configuration tasks --- tasks/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 356aff48..4fd7d18b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -208,7 +208,7 @@ 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: @@ -216,7 +216,7 @@ 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: @@ -224,7 +224,7 @@ 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: @@ -239,7 +239,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: @@ -249,7 +249,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: @@ -287,7 +287,7 @@ 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 @@ -295,7 +295,7 @@ 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 @@ -304,7 +304,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" @@ -319,7 +319,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