A role for managing LVM
Special about this role is that the VolumeGroups and Devicepaths are autodiscovered. So you should be fine if you only give the mountpoints and sizes at the host_vars/* files or playbook. Only if you add disks you need to set the VolumeGroup to where the new disks should be addet.
- Installs lvm2 (and cryptsetup if needet)
- Make a partiton on all disks who doesn't already have a partition
- Make a cryptsetup ontop of created partitions
- Adds partitions to VolumeGroup
- Unmounts and Removes unwanted Montpoints and their LogicalVolumes
- Creates/Resizes LogicalVolumes based on Mountpoints given as variables
- Creates/Resizes Filesystems based on Mountpoints given as variables
None
Below are all the variables used by the role, together an explanation, and their defaults.
partitioning: true
cryptdisk: false cryptdisk_pw:
addisk: true
resizelvm: true
#remove_mounts: []
disk_align_offset: "2048s"
fs: ext4
lvm_group: vg01
#lvgrp:
Optional-parameter: vg, fs and opts (for mount) - Only use them if you need and fill them. Dont leave them empty (eg.: "vg: ''")!
#lv_mounts:
#swapsize: '8192m'
Needet so these variables/lists aren't "undefined" and provoke the "undefined error" when they are automagically filled
eg. fill addet_partitions if you are running with "partitioning: false" and have already partitions to add
addet_disks: [] addet_partitions: [] addet_crypted_partitions: []
- hosts: all
become: true
roles:
- ansible-lvm
cryptdisk: true cryptdisk_pw: SecretCryptDiskPassword lv_mounts:
- {mount: '/data', size: '1T'}
- {mount: '/opt', size: '500G', opts: 'defaults,acl,nodev,nosuid'}
- {mount: '/home', size: '100M', opts: 'defaults,acl,nodev,nosuid,noexec', vg: 'vg00', fs: 'xfs'} swapsize: '8192m'
BSD
This role was created in 2016 by Sven Weise