Merge pull request #46 from bodepd/add_loopback_mnt_param
Add loopback mnt param
This commit is contained in:
commit
b63a9dbe07
manifests/storage
spec
defines
fixtures/modules
@ -7,10 +7,10 @@
|
||||
# - formats the file to be an xfs device and mounts it as a loopback device at /srv/node/$name
|
||||
# - sets up each mount point as a swift endpoint
|
||||
define swift::storage::loopback(
|
||||
$base_dir = '/srv/loopback-device',
|
||||
$base_dir = '/srv/loopback-device',
|
||||
$mnt_base_dir = '/srv/node',
|
||||
$byte_size = '1024',
|
||||
$seek = '25000'
|
||||
$byte_size = '1024',
|
||||
$seek = '25000'
|
||||
) {
|
||||
|
||||
if(!defined(File[$base_dir])) {
|
||||
@ -39,6 +39,7 @@ define swift::storage::loopback(
|
||||
mnt_base_dir => $mnt_base_dir,
|
||||
byte_size => $byte_size,
|
||||
subscribe => Exec["create_partition-${name}"],
|
||||
loopback => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,14 @@
|
||||
#
|
||||
define swift::storage::mount(
|
||||
$device,
|
||||
$mnt_base_dir = '/srv/node'
|
||||
$mnt_base_dir = '/srv/node',
|
||||
$loopback = false
|
||||
) {
|
||||
|
||||
if($loopback){
|
||||
$options = 'noatime,nodiratime,nobarrier,logbufs=8,loop'
|
||||
} else {
|
||||
$options = 'noatime,nodiratime,nobarrier,logbufs=8'
|
||||
}
|
||||
# the directory that represents the mount point
|
||||
# needs to exist
|
||||
file { "${mnt_base_dir}/${name}":
|
||||
@ -20,7 +25,7 @@ define swift::storage::mount(
|
||||
ensure => present,
|
||||
device => $device,
|
||||
fstype => 'xfs',
|
||||
options => 'loop,noatime,nodiratime,nobarrier,logbufs=8',
|
||||
options => $options,
|
||||
require => File["${mnt_base_dir}/${name}"]
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,9 @@
|
||||
# It is recommened to use 1024 to ensure that the metadata can fit in a single inode.
|
||||
define swift::storage::xfs(
|
||||
$device,
|
||||
$byte_size = '1024',
|
||||
$mnt_base_dir = '/srv/node'
|
||||
$byte_size = '1024',
|
||||
$mnt_base_dir = '/srv/node',
|
||||
$loopback = false
|
||||
) {
|
||||
|
||||
include swift::xfs
|
||||
@ -29,7 +30,8 @@ define swift::storage::xfs(
|
||||
swift::storage::mount { $name:
|
||||
device => $device,
|
||||
mnt_base_dir => $mnt_base_dir,
|
||||
subscribe => Exec["mkfs-${name}"]
|
||||
subscribe => Exec["mkfs-${name}"],
|
||||
loopback => $loopback,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'swift::storage::loopback' do
|
||||
# TODO add unit tests
|
||||
# this is not the highest priority b/c it is really for testing
|
||||
# TODO add more unit tests
|
||||
|
||||
let :title do
|
||||
'dans_disk'
|
||||
end
|
||||
|
||||
it { should contain_swift__storage__xfs('dans_disk').with(
|
||||
:device => '/srv/loopback-device/dans_disk',
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:byte_size => '1024',
|
||||
:subscribe => 'Exec[create_partition-dans_disk]',
|
||||
:loopback => true
|
||||
) }
|
||||
|
||||
end
|
||||
|
@ -1,4 +1,42 @@
|
||||
require 'spec_helper'
|
||||
describe 'swift::storage::mount' do
|
||||
# TODO add unit tests
|
||||
# not a super high priority b/c this is just for testing
|
||||
|
||||
let :title do
|
||||
'dans_mount_point'
|
||||
end
|
||||
|
||||
describe 'with defaults params' do
|
||||
let :params do
|
||||
{
|
||||
:device => '/dev/sda'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_mount('/srv/node/dans_mount_point').with(
|
||||
:ensure => 'present',
|
||||
:device => '/dev/sda',
|
||||
:fstype => 'xfs',
|
||||
:options => 'noatime,nodiratime,nobarrier,logbufs=8',
|
||||
:require => 'File[/srv/node/dans_mount_point]'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'when mounting a loopback device' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:device => '/dev/sda',
|
||||
:loopback => true
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_mount('/srv/node/dans_mount_point').with(
|
||||
:device => '/dev/sda',
|
||||
:options => 'noatime,nodiratime,nobarrier,logbufs=8,loop'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -11,15 +11,21 @@ describe 'swift::storage::xfs' do
|
||||
|
||||
describe 'when a device is specified' do
|
||||
let :default_params do
|
||||
{:device => 'some_device',
|
||||
{
|
||||
:device => 'some_device',
|
||||
:byte_size => '1024',
|
||||
:mnt_base_dir => '/srv/node'}
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:loopback => false
|
||||
}
|
||||
end
|
||||
|
||||
[{:device => 'some_device'},
|
||||
{:device => 'some_device',
|
||||
:byte_size => 1,
|
||||
:mnt_base_dir => '/mnt/foo'}
|
||||
{
|
||||
:device => 'some_device',
|
||||
:byte_size => 1,
|
||||
:mnt_base_dir => '/mnt/foo',
|
||||
:loopback => true
|
||||
}
|
||||
].each do |param_set|
|
||||
|
||||
describe "#{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||
@ -39,9 +45,10 @@ describe 'swift::storage::xfs' do
|
||||
)}
|
||||
|
||||
it { should contain_swift__storage__mount('foo').with(
|
||||
{:device => param_hash[:device],
|
||||
:device => param_hash[:device],
|
||||
:mnt_base_dir => param_hash[:mnt_base_dir],
|
||||
:subscribe => 'Exec[mkfs-foo]'}
|
||||
:loopback => param_hash[:loopback],
|
||||
:subscribe => 'Exec[mkfs-foo]'
|
||||
)}
|
||||
|
||||
end
|
||||
|
1
spec/fixtures/modules/swift
vendored
1
spec/fixtures/modules/swift
vendored
@ -1 +0,0 @@
|
||||
../../../
|
Loading…
x
Reference in New Issue
Block a user