forked from puppetlabs/puppetlabs-lvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
235 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
fixtures: | ||
repositories: | ||
"stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
symlinks: | ||
"lvm": "#{source_dir}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class lvm( | ||
$volume_groups = {}, | ||
) { | ||
validate_hash($volume_groups) | ||
|
||
create_resources('lvm::volume_group', $volume_groups) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
define lvm::logical_volume( | ||
$volume_group, | ||
$size, | ||
$ensure = present, | ||
$options = 'defaults', | ||
$fs_type = 'ext4', | ||
$mountpath = "/${name}", | ||
$mountpath_require = false, | ||
) { | ||
validate_bool($mountpath_require) | ||
|
||
if $mountpath_require { | ||
Mount { | ||
require => File[$mountpath], | ||
} | ||
} | ||
|
||
$mount_ensure = $ensure ? { | ||
'absent' => absent, | ||
default => mounted, | ||
} | ||
|
||
if $ensure == 'present' { | ||
Logical_volume[$name] -> | ||
Filesystem["/dev/${volume_group}/${name}"] -> | ||
Mount[$mountpath] | ||
} else { | ||
Mount[$mountpath] -> | ||
Filesystem["/dev/${volume_group}/${name}"] -> | ||
Logical_volume[$name] | ||
} | ||
|
||
logical_volume { $name: | ||
ensure => $ensure, | ||
volume_group => $volume_group, | ||
size => $size, | ||
} | ||
|
||
filesystem {"/dev/${volume_group}/${name}": | ||
ensure => $ensure, | ||
fs_type => $fs_type, | ||
} | ||
|
||
exec { "ensure mountpoint '${mountpath}' exists": | ||
command => "mkdir -p ${mountpath}", | ||
unless => "test -d ${mountpath}", | ||
} -> | ||
mount {$mountpath: | ||
ensure => $mount_ensure, | ||
device => "/dev/${volume_group}/${name}", | ||
fstype => $fs_type, | ||
options => $options, | ||
pass => 2, | ||
dump => 1, | ||
atboot => true, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
define lvm::volume_group( | ||
$physical_volumes, | ||
$ensure = present, | ||
$logical_volumes = {}, | ||
) { | ||
validate_hash($logical_volumes) | ||
|
||
physical_volume { $physical_volumes: | ||
ensure => $ensure, | ||
} | ||
|
||
volume_group { $name: | ||
ensure => $ensure, | ||
physical_volumes => $physical_volumes, | ||
} | ||
|
||
create_resources( | ||
'lvm::logical_volume', | ||
$logical_volumes, | ||
{ | ||
ensure => $ensure, | ||
volume_group => $name, | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'spec_helper' | ||
|
||
describe 'lvm', :type => :class do | ||
|
||
describe 'with no parameters' do | ||
it { should compile.with_all_deps } | ||
end | ||
|
||
describe 'with volume groups' do | ||
let(:params) do | ||
{ | ||
:volume_groups => { | ||
'myvg' => { | ||
'physical_volumes' => [ '/dev/sda2', '/dev/sda3', ], | ||
'logical_volumes' => { | ||
'opt' => {'size' => '20G'}, | ||
'tmp' => {'size' => '1G' }, | ||
'usr' => {'size' => '3G' }, | ||
'var' => {'size' => '15G'}, | ||
'home' => {'size' => '5G' }, | ||
'backup' => { | ||
'size' => '5G', | ||
'mountpath' => '/var/backups', | ||
'mountpath_require' => true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
end | ||
|
||
it { should contain_physical_volume('/dev/sda2') } | ||
it { should contain_physical_volume('/dev/sda3') } | ||
it { should contain_volume_group('myvg').with({ | ||
:ensure => 'present', | ||
:physical_volumes => [ '/dev/sda2', '/dev/sda3', ] | ||
}) } | ||
|
||
it { should contain_logical_volume('opt').with( { | ||
:volume_group => 'myvg', | ||
:size => '20G' | ||
}) } | ||
it { should contain_filesystem('/dev/myvg/opt') } | ||
it { should contain_mount('/opt') } | ||
|
||
it { should contain_logical_volume('backup').with({ | ||
:volume_group => 'myvg', | ||
:size => '5G' | ||
}) } | ||
it { should contain_filesystem('/dev/myvg/backup') } | ||
it { should contain_mount('/var/backups') } | ||
end | ||
|
||
end |