|
152 | 152 |
|
153 | 153 | - name: Check if rootlv exists |
154 | 154 | stat: |
155 | | - path: /dev/mapper/{{ hpc_rootvg_name }}-{{ hpc_rootlv_name }} |
| 155 | + path: /dev/{{ hpc_rootvg_name }}/{{ hpc_rootlv_name }} |
156 | 156 | register: __hpc_rootlv_stat |
157 | 157 |
|
158 | 158 | - name: Check if usrlv exists |
159 | 159 | stat: |
160 | | - path: /dev/mapper/{{ hpc_rootvg_name }}-{{ hpc_usrlv_name }} |
| 160 | + path: /dev/{{ hpc_rootvg_name }}/{{ hpc_usrlv_name }} |
161 | 161 | register: __hpc_usrlv_stat |
162 | 162 |
|
163 | 163 | - name: Check if varlv exists |
164 | 164 | stat: |
165 | | - path: /dev/mapper/{{ hpc_rootvg_name }}-{{ hpc_varlv_name }} |
| 165 | + path: /dev/{{ hpc_rootvg_name }}/{{ hpc_varlv_name }} |
166 | 166 | register: __hpc_varlv_stat |
167 | 167 |
|
168 | 168 | - name: Get current LV size of rootlv |
169 | | - command: lvs --noheadings --units g --nosuffix -o lv_size /dev/mapper/{{ hpc_rootvg_name }}-{{ hpc_rootlv_name }} |
| 169 | + command: lvs --noheadings --units g --nosuffix -o lv_size /dev/{{ hpc_rootvg_name }}/{{ hpc_rootlv_name }} |
170 | 170 | register: __hpc_rootlv_size_cmd |
171 | 171 | changed_when: false |
172 | 172 | when: __hpc_rootlv_stat.stat.exists |
173 | 173 |
|
174 | 174 | - name: Get current LV size of usrlv |
175 | | - command: lvs --noheadings --units g --nosuffix -o lv_size /dev/mapper/{{ hpc_rootvg_name }}-{{ hpc_usrlv_name }} |
| 175 | + command: lvs --noheadings --units g --nosuffix -o lv_size /dev/{{ hpc_rootvg_name }}/{{ hpc_usrlv_name }} |
176 | 176 | register: __hpc_usrlv_size_cmd |
177 | 177 | changed_when: false |
178 | 178 | when: __hpc_usrlv_stat.stat.exists |
179 | 179 |
|
180 | 180 | - name: Get current LV size of varlv |
181 | | - command: lvs --noheadings --units g --nosuffix -o lv_size /dev/mapper/{{ hpc_rootvg_name }}-{{ hpc_varlv_name }} |
| 181 | + command: lvs --noheadings --units g --nosuffix -o lv_size /dev/{{ hpc_rootvg_name }}/{{ hpc_varlv_name }} |
182 | 182 | register: __hpc_varlv_size_cmd |
183 | 183 | changed_when: false |
184 | 184 | when: __hpc_varlv_stat.stat.exists |
185 | 185 |
|
| 186 | + - name: Check if volume group exists |
| 187 | + command: vgs --noheadings -o vg_name {{ hpc_rootvg_name }} |
| 188 | + register: __hpc_vg_check |
| 189 | + changed_when: false |
| 190 | + failed_when: false |
| 191 | + |
| 192 | + - name: Get PV devices for volume group |
| 193 | + command: pvs --noheadings -o pv_name -S vg_name={{ hpc_rootvg_name }} |
| 194 | + register: __hpc_pv_devices |
| 195 | + changed_when: false |
| 196 | + when: __hpc_vg_check.rc == 0 |
| 197 | + |
| 198 | + - name: Set PV device list for storage role |
| 199 | + set_fact: |
| 200 | + __hpc_rootvg_disks: "{{ __hpc_pv_devices.stdout_lines | map('trim') | list }}" |
| 201 | + when: |
| 202 | + - __hpc_vg_check.rc == 0 |
| 203 | + - __hpc_pv_devices.stdout_lines | length > 0 |
| 204 | + |
| 205 | + - name: Expand partitions if underlying disks have been expanded |
| 206 | + when: |
| 207 | + - __hpc_vg_check.rc == 0 |
| 208 | + - __hpc_rootvg_disks is defined |
| 209 | + - __hpc_rootvg_disks | length > 0 |
| 210 | + block: |
| 211 | + - name: Install cloud-utils-growpart for partition expansion |
| 212 | + package: |
| 213 | + name: cloud-utils-growpart |
| 214 | + state: present |
| 215 | + use: "{{ (__hpc_server_is_ostree | d(false)) | |
| 216 | + ternary('ansible.posix.rhel_rpm_ostree', omit) }}" |
| 217 | + |
| 218 | + - name: Expand partitions via growpart |
| 219 | + vars: |
| 220 | + # From pv_device to extract parent_device and partition_number example |
| 221 | + # SCSI: /dev/sda4 -> /dev/sda and 4 |
| 222 | + # NVMe: /dev/nvme0n1p4 -> /dev/nvme0n1 and 4 |
| 223 | + pv_device: "{{ item }}" |
| 224 | + parent_device: "{{ pv_device | regex_replace('p?([0-9]+)$', '') }}" |
| 225 | + partition_number: "{{ pv_device | regex_search('([0-9]+)$') }}" |
| 226 | + command: growpart {{ parent_device }} {{ partition_number }} |
| 227 | + register: __hpc_growpart_result |
| 228 | + changed_when: |
| 229 | + - __hpc_growpart_result.rc == 0 |
| 230 | + - "'NOCHANGE' not in __hpc_growpart_result.stdout" |
| 231 | + failed_when: |
| 232 | + - __hpc_growpart_result.rc != 0 |
| 233 | + - "'NOCHANGE' not in __hpc_growpart_result.stdout" |
| 234 | + loop: "{{ __hpc_rootvg_disks }}" |
| 235 | + when: |
| 236 | + - partition_number | length > 0 |
| 237 | + - parent_device != pv_device |
| 238 | + |
| 239 | + # - name: Resize PVs to use expanded partition space |
| 240 | + # command: pvresize {{ item }} |
| 241 | + # changed_when: false |
| 242 | + # loop: "{{ __hpc_rootvg_disks }}" |
| 243 | + |
186 | 244 | - name: Initialize volumes list |
187 | 245 | set_fact: |
188 | 246 | __hpc_volumes: [] |
|
229 | 287 | - __hpc_varlv_stat.stat.exists |
230 | 288 | - (size_expected | int) > (size_current | int) |
231 | 289 |
|
232 | | - - name: Configure storage |
| 290 | + - name: Configure storage via storage role |
233 | 291 | include_role: |
234 | 292 | name: fedora.linux_system_roles.storage |
235 | 293 | vars: |
236 | 294 | storage_pools: |
237 | 295 | - name: "{{ hpc_rootvg_name }}" |
| 296 | + disks: "{{ __hpc_rootvg_disks | default(omit) }}" |
238 | 297 | grow_to_fill: true |
239 | 298 | volumes: "{{ __hpc_volumes }}" |
240 | 299 | when: __hpc_volumes | length > 0 |
|
1261 | 1320 | Skipping azurehpc-health-checks installation because aznhc-nv Docker image cannot be pulled. |
1262 | 1321 | To install health checks, increase /var space by: |
1263 | 1322 | (1) Expanding the root disk in Azure portal, |
1264 | | - (2) Adding the new space as a PV to the volume group (e.g., pvresize /dev/sda2), |
| 1323 | + (2) Adding the new space as a PV to the volume group (e.g., pvresize /dev/sda4), |
1265 | 1324 | (3) Expanding the /var logical volume (e.g., lvextend -L +20G /dev/rootvg/varlv && xfs_growfs /var). |
1266 | 1325 | See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/expand-disks?tabs=rhellvm for details. |
1267 | 1326 | Alternatively, configure hpc_varlv_size before running this role. |
|
0 commit comments