From b6ff97dc05cdd1c622a14047c07be9e87b9c3cab Mon Sep 17 00:00:00 2001 From: Sven Lange Date: Mon, 16 Jul 2018 14:56:10 +0200 Subject: [PATCH 1/2] Allow for lvs to be created on specific pv This change allows the use of physical_volume as argument to logical_volume so that the new lv will be created on a specific physical volume even if the volume group consists of several physical volumes. Signed-off-by: Sven Lange --- lib/puppet/provider/logical_volume/lvm.rb | 4 ++++ lib/puppet/type/logical_volume.rb | 4 ++++ manifests/logical_volume.pp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/lib/puppet/provider/logical_volume/lvm.rb b/lib/puppet/provider/logical_volume/lvm.rb index 4af6a2c8..84e7dc86 100644 --- a/lib/puppet/provider/logical_volume/lvm.rb +++ b/lib/puppet/provider/logical_volume/lvm.rb @@ -133,6 +133,10 @@ def create else args << @resource[:volume_group] end + + if @resource[:physical_volume] + args << @resource[:physical_volume] + end lvcreate(*args) end diff --git a/lib/puppet/type/logical_volume.rb b/lib/puppet/type/logical_volume.rb index 35479adc..d046b0bf 100644 --- a/lib/puppet/type/logical_volume.rb +++ b/lib/puppet/type/logical_volume.rb @@ -21,6 +21,10 @@ volume_group resource type." end + newparam(:physical_volume) do + desc "The physical volume name this logical volume will be created on." + end + newparam(:initial_size) do desc "The initial size of the logical volume. This will only apply to newly-created volumes" validate do |value| diff --git a/manifests/logical_volume.pp b/manifests/logical_volume.pp index bd50a3f8..cade5f9e 100644 --- a/manifests/logical_volume.pp +++ b/manifests/logical_volume.pp @@ -28,6 +28,7 @@ $no_sync = undef, $region_size = undef, $alloc = undef, + $physical_volume = undef, ) { $lvm_device_path = "/dev/${volume_group}/${name}" @@ -90,6 +91,7 @@ no_sync => $no_sync, region_size => $region_size, alloc => $alloc, + physical_volume => $physical_volume, } if $createfs { From 5d7b2058e4f555c0a351990255c5a8595c45d8ff Mon Sep 17 00:00:00 2001 From: Sven Lange Date: Mon, 16 Jul 2018 14:57:48 +0200 Subject: [PATCH 2/2] Update README for physical_volume flag --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cfb8dea2..703738dc 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,7 @@ resources out yourself. * mounted - If puppet should mount the volume. This only affects what puppet will do, and not what will be mounted at boot-time. * no_sync (Parameter) - An optimization in lvcreate, at least on Linux. * persistent (Parameter) - Set to true to make the block device persistent +* physical_volume (Parameter) - Create this logical volume on the specified physical volume * poolmetadatasize (Parameter) - Set the initial size of the logical volume pool metadata on creation * readahead (Parameter) - The readahead count to use for the new logical volume. * region_size (Parameter) - A mirror is divided into regions of this size (in MB), the mirror log uses this granularity to track which regions are in sync. CAN NOT BE CHANGED on already mirrored volume. Take your mirror size in terabytes and round up that number to the next power of 2, using that number as the -R argument.