From 93553c7630db1716cccfe10b2b90b736af308309 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 27 Jul 2025 12:31:45 -0500 Subject: [PATCH] datavol: Add support for LVM The `datavol.yml` playbook can now create LVM volume groups and logical volumes. This will be useful for physical hosts with static storage. LVM LVs and VGs are defined using the `logical_volumes` Ansible variable, which contains a mapping of VG names to their properties. Each VG must have two properties: `pvs`, which is a list of LVM physical volumes to add to the VG, and `lvs`, a list of LVs and their properties, including `name` and `size. For example: ```yaml logical_volumes: kubernetes: pvs: - /dev/nvme0n1 lvs: - name: containers size: 64G - name: kubelet size: 32G ``` --- datavol.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/datavol.yml b/datavol.yml index 7867e18..afb2d67 100644 --- a/datavol.yml +++ b/datavol.yml @@ -21,6 +21,28 @@ tags: - install + - name: ensure lvm volume groups exist + lvg: + vg: '{{ item.key }}' + pvs: '{{ item.value.pvs }}' + loop: '{{ logical_volumes | d({}) | dict2items }}' + loop_control: + label: '{{ item.key }}' + tags: + - lvm + - lvm-vg + - name: ensure lvm logical volumes exist + lvol: + lv: '{{ item.1.name }}' + vg: '{{ item.0.key }}' + size: '{{ item.1.size }}' + loop: '{{ logical_volumes | dict2items | subelements("value.lvs") }}' + loop_control: + label: '{{ item.0.key }}/{{ item.1.name }}' + tags: + - lvm + - lvm-lv + - name: ensure data volume filesystem exists filesystem: dev: '{{ item.dev }}'