summaryrefslogtreecommitdiffstats
path: root/roles/pve-storage/tasks/main.yml
blob: 9851858712423244335c04177c336fa49185420a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
- name: "Create LVM volume group for PVE storage"
  become: true
  community.general.lvg:
    vg: "{{ pve_storage_name }}"
    pvs: "{{ pve_storage_device }}"
    state: present
  tags:
    # No block devices available in containers
    - "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 --poolmetadatasize 1G"
    shrink: false
    state: present
  tags:
    # No block devices available in containers
    - "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:
    # pvesm binary not available in containers — requires proxmox-ve package
    - "molecule-notest"