fix: os disk management

This commit is contained in:
root 2025-07-01 17:29:30 +00:00
parent ebdedd67b9
commit 4af2c65d8f
3 changed files with 27 additions and 3 deletions

20
roles/os_disks/README.md Normal file
View File

@ -0,0 +1,20 @@
# OS Disk
Prepare LVM disks. Configuration example:
```
disks_vg:
- vg: data
state: present
devices_dev:
- /dev/vda
disks_lv:
- lv: var_lib_docker
vg: data
size: 20G
state: # present (mounted), absent (destroyed)
fstype: ext4
```
Note:
- Provides a VM disk detection helper

View File

@ -1,4 +1,8 @@
---
disks_vg: []
disks_lv: []
disks_vg__default: []
disks_lv__default: []
disks_vg: "{{ vars | dict2items | selectattr('key', 'match', '^disks_vg__.*') | map(attribute='value') | list | flatten | unique }}"
disks_lv: "{{ vars | dict2items | selectattr('key', 'match', '^disks_lv__.*') | map(attribute='value') | list | flatten | unique }}"

View File

@ -67,7 +67,7 @@
state: "{{ state }}"
loop: "{{ disks_lv }}"
vars:
state: "{{ item.state | default('mounted') }}"
state: "{{ ( item.state == 'present' ) | ternary( 'mounted', item.state | default('mounted')) }}"
fstype: "{{ item.fstype | default('ext4') }}"
src: "/dev/{{ item.vg }}/{{ item.lv }}"
path: "/{{ item.lv | replace('_', '/') }}"