Posts

Showing posts from January, 2016

Puppet Vgextend LVM module

I've recently extended our lvm2 Puppet module with the vgextend feature. Below is what I've come up with. There are a Puppet file and a bash script for checking if VG needs to be extended. You have to define VG name and PVs in the node YAML file. vgextend.pp # == Define: lvm2::vgextend # Extend an LVM Volume Group (VG) # # === Parameters # [*name*] #   Volume Group Name # # [*physicalvolumes*] #   Array of physical volumes (PV) to extend the VG define lvm2::vgextend($physicalvolumes) {   validate_array($physicalvolumes)   include '::lvm2'   $pv = join($physicalvolumes,' ')   $onlyif_check = $::lvm2::vg_onlyif_check   $cmd = "${onlyif_check} apply ${name} ${pv}"   $pipe = $::lvm2::dryrun_pipe_command   $command = $::lvm2::dryrun ? {     false   => $cmd,     default => "echo '${cmd}' ${pipe}",   }   exec { "extend_volume_group_${name}" :     command => $command,     path    =>