Add Ansible storage role for NVMe setup and Longhorn dual-disk config

Automates LV expansion, NVMe mount, and Longhorn node disk tagging
(hdd/nvme) via Ansible instead of Kustomize-managed manifests.
This commit is contained in:
Julia McGhee
2026-03-21 13:19:04 +00:00
parent 3b8fd4afd2
commit c6ce40a557
5 changed files with 99 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
---
node_labels:
- topology.kubernetes.io/zone=rack1
- node.kubernetes.io/instance-type=nuc
# NVMe partition UUID (Samsung 980 Pro 1TB, partition 3)
nvme_partition_uuid: "65246002-2f17-4f55-add4-a6441d484ecc"

View File

@@ -0,0 +1,6 @@
---
- name: Configure storage (expand LV + mount NVMe)
hosts: k3s_cluster
become: true
roles:
- storage

View File

@@ -0,0 +1,60 @@
---
- name: Extend root LV to use all free VG space
community.general.lvol:
vg: ubuntu-vg
lv: ubuntu-lv
size: +100%FREE
resizefs: true
register: lv_extend
failed_when:
- lv_extend.failed
- "'matches existing size' not in (lv_extend.msg | default(''))"
- name: Create NVMe storage mount point
ansible.builtin.file:
path: /mnt/nvme-storage
state: directory
owner: root
group: root
mode: "0755"
- name: Mount NVMe partition
ansible.posix.mount:
path: /mnt/nvme-storage
src: UUID={{ nvme_partition_uuid }}
fstype: ext4
opts: defaults,noatime
state: mounted
- name: Create Longhorn data directory on NVMe
ansible.builtin.file:
path: /mnt/nvme-storage/longhorn
state: directory
owner: root
group: root
mode: "0755"
- name: Configure Longhorn node disks (HDD + NVMe with tags)
kubernetes.core.k8s:
state: patched
api_version: longhorn.io/v1beta2
kind: Node
name: "{{ inventory_hostname }}"
namespace: longhorn-system
definition:
spec:
disks:
default-disk-d4d0a27486e915cd:
allowScheduling: true
path: /var/lib/longhorn/
storageReserved: 32212254720
tags:
- hdd
nvme:
allowScheduling: true
path: /mnt/nvme-storage/longhorn/
storageReserved: 10737418240
tags:
- nvme
delegate_to: localhost
become: false