xoxys.lvm/tasks/main.yml
Robert Kaussow 04c8df9f32
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci: migrate to woodpecker
2024-02-18 13:16:42 +01:00

47 lines
1.5 KiB
YAML

---
- name: Install requirements
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ lvm_packages }}"
- name: Create volume group
community.general.lvg:
vg: "{{ item.group }}"
pvs: "{{ item.disks | join(',') }}"
pesize: "4"
pvresize: yes
loop: "{{ lvm_volumes }}"
loop_control:
label: "name: {{ item.group }}, disks: {{ item.disks | join(',') }}"
- name: Create logical volume
community.general.lvol:
vg: "{{ item.group }}"
lv: "{{ item.name }}"
size: "{{ item.size }}"
resizefs: "{{ item.resizefs | default(True) }}"
state: present
loop: "{{ lvm_volumes }}"
loop_control:
label: "name: {{ item.group }}, size: {{ item.size }}"
- name: Create filesystem
community.general.filesystem:
fstype: "{{ item.fstype | default('ext4') }}"
dev: "/dev/mapper/{{ item.group }}-{{ item.name }}"
loop: "{{ lvm_volumes }}"
loop_control:
label: "device: /dev/mapper/{{ item.group }}-{{ item.name }}, fstype: {{ item.fstype | default('ext4') }}"
- name: Mount volume
ansible.posix.mount:
path: "{{ item.mountpoint }}"
src: "/dev/mapper/{{ item.group }}-{{ item.name }}"
fstype: "{{ item.fstype | default('ext4') }}"
opts: "{{ item.mountopts | default([]) | join(',') or omit }}"
state: "{{ item.state | default('mounted') }}"
loop: "{{ lvm_volumes }}"
loop_control:
label: "mount: /dev/mapper/{{ item.group }}-{{ item.name }} {{ item.mountpoint }} {{ item.fstype | default('ext4') }}{% if item.mountopts is defined %} {{ item.mountopts | join(',') }}{% endif %}"