diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-07-03 23:43:17 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-07-03 23:44:47 +0200 |
| commit | 97c97e7b9880a90b2e54dd2b5f02aaf65824fb1f (patch) | |
| tree | d0f0086ead57a6e798aac3038298cc557c30c6cd /roles/pve-storage | |
| parent | 005c49353a6a71954e6a975a43989ded1786022a (diff) | |
Refactor pve roles to create storage separately
Diffstat (limited to 'roles/pve-storage')
| -rw-r--r-- | roles/pve-storage/defaults/main.yml | 4 | ||||
| -rw-r--r-- | roles/pve-storage/meta/argument_specs.yml | 16 | ||||
| -rw-r--r-- | roles/pve-storage/meta/main.yml | 12 | ||||
| -rw-r--r-- | roles/pve-storage/tasks/main.yml | 31 |
4 files changed, 63 insertions, 0 deletions
diff --git a/roles/pve-storage/defaults/main.yml b/roles/pve-storage/defaults/main.yml new file mode 100644 index 00000000..77499ce0 --- /dev/null +++ b/roles/pve-storage/defaults/main.yml @@ -0,0 +1,4 @@ +--- +pve_storage_device: "/dev/sda4" +pve_storage_name: "pve" +pve_storage_pool: "data" diff --git a/roles/pve-storage/meta/argument_specs.yml b/roles/pve-storage/meta/argument_specs.yml new file mode 100644 index 00000000..7f502ef7 --- /dev/null +++ b/roles/pve-storage/meta/argument_specs.yml @@ -0,0 +1,16 @@ +--- +argument_specs: + main: + options: + pve_storage_device: + type: "str" + description: "Block device for LVM physical volume (e.g. /dev/sda4)" + default: "/dev/sda4" + pve_storage_name: + type: "str" + description: "LVM volume group name" + default: "pve" + pve_storage_pool: + type: "str" + description: "LVM thin pool name within the volume group" + default: "data" diff --git a/roles/pve-storage/meta/main.yml b/roles/pve-storage/meta/main.yml new file mode 100644 index 00000000..f3ba634b --- /dev/null +++ b/roles/pve-storage/meta/main.yml @@ -0,0 +1,12 @@ +--- +dependencies: + - role: "pve" +galaxy_info: + author: "a14m" + description: "Configure LVM thin pool and register local-lvm storage in Proxmox VE" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "Debian" + versions: + - "bookworm" diff --git a/roles/pve-storage/tasks/main.yml b/roles/pve-storage/tasks/main.yml new file mode 100644 index 00000000..7fb66b87 --- /dev/null +++ b/roles/pve-storage/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: "Create LVM volume group for PVE storage" + become: true + community.general.lvg: + vg: "{{ pve_storage_name }}" + pvs: "{{ pve_storage_device }}" + state: present + tags: + - "molecule-notest" + +- name: "Create LVM thin pool for PVE storage" + become: true + community.general.lvol: + vg: "{{ pve_storage_name }}" + lv: "{{ pve_storage_pool }}" + size: "100%FREE" + opts: "--type thin-pool" + shrink: false + state: present + tags: + - "molecule-notest" + +- name: "Register local-lvm storage in PVE" + become: true + ansible.builtin.command: + cmd: "pvesm add lvmthin local-lvm --vgname {{ pve_storage_name }} --thinpool {{ pve_storage_pool }}" + register: pve_pvesm_add + changed_when: pve_pvesm_add.rc == 0 + failed_when: pve_pvesm_add.rc != 0 and 'already defined' not in pve_pvesm_add.stderr + tags: + - "molecule-notest" |
