Skip to content

Commit 9e7f9f8

Browse files
lukebigumTim Hughes
authored andcommitted
(MODULES-3991) new parameter to tell volume_group Type to resolve PV symlinks to real devices, and override insync? method to do this
1 parent 3f1395c commit 9e7f9f8

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

lib/puppet/type/volume_group.rb

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,46 @@
1212
using the physical_volume resource type."
1313

1414
def insync?(is)
15-
should.sort == is.sort
15+
if @resource.parameter(:followsymlinks).value == :true then
16+
real_should = []
17+
real_is = []
18+
should.each do |s|
19+
if File.symlink?(s)
20+
device = File.expand_path(File.readlink(s), File.dirname(s))
21+
debug("resolved symlink '"+s+"' to device '"+ device+"'")
22+
real_should.push device
23+
else
24+
real_should.push s
25+
end
26+
end
27+
is.each do |s|
28+
if File.symlink?(s)
29+
device = File.expand_path(File.readlink(s), File.dirname(s))
30+
debug("resolved symlink '"+s+"' to device '"+ device+"'")
31+
real_is.push device
32+
else
33+
real_is.push s
34+
end
35+
end
36+
37+
real_should.sort == real_is.sort
38+
else
39+
should.sort == is.sort
40+
end
1641
end
1742
end
1843

44+
newparam(:followsymlinks, :boolean => true) do
45+
desc "If set to true all current and wanted values of the physical_volumes property
46+
will be followed to their real files on disk if they are in fact symlinks. This is
47+
useful to have Puppet determine what the actual PV device is if the property value
48+
is a symlink, like '/dev/disk/by-path/xxxx -> ../../sda'. Defaults to `False`."
49+
newvalues(:true, :false)
50+
aliasvalue(:yes, :true)
51+
aliasvalue(:no, :false)
52+
defaultto :false
53+
end
54+
1955
newparam(:createonly, :boolean => true) do
2056
desc "If set to true the volume group will be created if it does not exist. If the
2157
volume group does exist no action will be taken. Defaults to `false`."

0 commit comments

Comments
 (0)