diff --git a/Puppetfile b/Puppetfile index e4f3c7d..1e7b959 100644 --- a/Puppetfile +++ b/Puppetfile @@ -8,6 +8,7 @@ mod 'puppetlabs-concat', '9.0.0' mod 'puppetlabs-vcsrepo', '6.1.0' mod 'puppetlabs-yumrepo_core', '2.0.0' mod 'puppetlabs-apt', '9.1.0' +mod 'puppetlabs-lvm', '2.0.3' mod 'puppetlabs-puppetdb', '7.13.0' mod 'puppetlabs-postgresql', '9.1.0' mod 'puppetlabs-firewall', '6.0.0' diff --git a/site/profiles/manifests/base/datavol.pp b/site/profiles/manifests/base/datavol.pp new file mode 100644 index 0000000..2d3fb37 --- /dev/null +++ b/site/profiles/manifests/base/datavol.pp @@ -0,0 +1,62 @@ +# profiles::base::datavol +# +# This class manages the creation of a logical volume using the `lvm::volume` definition. +# +# Parameters: +# $ensure - Ensure whether the logical volume is present or not. Defaults to 'present'. +# $vg - Volume group name. No default. +# $pv - Physical volume, typically the disk or partition device path. No default. +# $fstype - Filesystem type for the logical volume. Defaults to 'ext3'. +# $size - Size of the logical volume. No default. +# +class profiles::base::datavol ( + Enum['present', 'absent'] $ensure = 'present', + Enum['ext2', 'ext3', 'ext4', 'xfs', 'btrfs'] $fstype = 'xfs', + String $vg = 'datavg', + String $pv = '/dev/vdb', + String $lv = 'data', + Stdlib::Absolutepath $mount = '/data', + Variant[Pattern[/^[\d+GTP%FREE]$/], Integer] $size = '100%FREE', + Array $mount_options = ['noatime', 'nodiratime'], +) { + + # Ensure the physical volume exists + physical_volume { $pv: + ensure => $ensure, + before => Volume_group[$vg], + } + + # Ensure the volume group exists + volume_group { $vg: + ensure => $ensure, + physical_volumes => [$pv], + before => Logical_volume[$lv], + } + + # Ensure the logical volume exists + logical_volume { $lv: + ensure => $ensure, + volume_group => $vg, + size => $size, + before => Filesystem["/dev/${vg}/${lv}"], + } + + # Ensure the filesystem is created on the logical volume + filesystem { "/dev/${vg}/${lv}": + ensure => $ensure, + fs_type => $fstype, + require => Logical_volume[$lv], + before => Mount[$mount], + } + + # Ensure the logical volume is mounted at the desired location + mount { $mount: + ensure => $ensure, + device => "/dev/${vg}/${lv}", + fstype => $fstype, + options => 'defaults', + dump => 0, + pass => 2, + require => Filesystem["/dev/${vg}/${lv}"], + } +}