Skip to content

Commit ad1cd07

Browse files
committed
Allow for lvs to be created on specific pv
1 parent 0be5cfc commit ad1cd07

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

REFERENCE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ The following parameters are available in the `logical_volume` type.
799799
* [`name`](#-logical_volume--name)
800800
* [`no_sync`](#-logical_volume--no_sync)
801801
* [`persistent`](#-logical_volume--persistent)
802+
* [`physical_volume`](#-logical_volume--physical_volume)
802803
* [`poolmetadatasize`](#-logical_volume--poolmetadatasize)
803804
* [`provider`](#-logical_volume--provider)
804805
* [`range`](#-logical_volume--range)
@@ -844,6 +845,10 @@ An optimization in lvcreate, at least on Linux.
844845

845846
Set to true to make the block device persistent
846847

848+
##### <a name="-logical_volume--physical_volume"></a>`physical_volume`
849+
850+
Create this logical volume on the specified physical volume
851+
847852
##### <a name="-logical_volume--poolmetadatasize"></a>`poolmetadatasize`
848853

849854
Change the size of logical volume pool metadata

lib/puppet/provider/logical_volume/lvm.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def create
120120
end
121121

122122
args.push('--yes') if @resource[:yes_flag]
123+
args.push(@resource[:physical_volume]) if @resource[:physical_volume]
123124
lvcreate(*args)
124125
end
125126

lib/puppet/type/logical_volume.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ def insync?(is)
119119
end
120120
end
121121

122+
newparam(:physical_volume) do
123+
desc "The name of the physical volume on which this logical volume will be created"
124+
validate do |val|
125+
unless val.is_a?(::String) || val.is_a?(::Array)
126+
raise ArgumentError, "physical_volume should be String or Array: #{val}"
127+
end
128+
end
129+
130+
munge do |val|
131+
case val
132+
when ::String
133+
[val]
134+
else
135+
val
136+
end
137+
end
138+
end
139+
122140
newproperty(:stripes) do
123141
desc 'The number of stripes to allocate for the new logical volume.'
124142
validate do |value|

manifests/logical_volume.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
Optional[Variant[String[1], Integer]] $region_size = undef,
9292
Optional[Enum['anywhere', 'contiguous', 'cling', 'inherit', 'normal']] $alloc = undef,
9393
Boolean $yes_flag = false,
94+
Optional[Variant[Array[String],String]] $physical_volume = undef,
9495
) {
9596
$lvm_device_path = "/dev/${volume_group}/${name}"
9697

@@ -153,6 +154,7 @@
153154
region_size => $region_size,
154155
alloc => $alloc,
155156
yes_flag => $yes_flag,
157+
physical_volume => $physical_volume,
156158
}
157159

158160
if $createfs {

0 commit comments

Comments
 (0)