-
Notifications
You must be signed in to change notification settings - Fork 271
/
lvm.rb
55 lines (43 loc) · 1.21 KB
/
lvm.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Puppet::Type.type(:filesystem).provide :lvm do
desc "Manages filesystem of a logical volume"
commands :blkid => 'blkid'
def create
mkfs(@resource[:fs_type], @resource[:name])
end
def exists?
fstype == @resource[:fs_type]
end
def destroy
# no-op
end
def fstype
/\bTYPE=\"(\S+)\"/.match(blkid(@resource[:name]))[1]
rescue Puppet::ExecutionFailure
nil
end
def mkfs(fs_type, name)
mkfs_params = { "reiserfs" => "-q" }
mkfs_cmd = @resource[:mkfs_cmd] != nil ?
[@resource[:mkfs_cmd]] :
case fs_type
when 'swap'
["mkswap"]
else
["mkfs.#{fs_type}"]
end
mkfs_cmd << name
if mkfs_params[fs_type]
mkfs_cmd << mkfs_params[fs_type]
end
if resource[:options]
mkfs_options = Array.new(resource[:options].split)
mkfs_cmd << mkfs_options
end
execute mkfs_cmd
if fs_type == 'swap'
swap_cmd = ["swapon"]
swap_cmd << name
execute swap_cmd
end
end
end