Adding support for ext4 devices

XFS may not be available on all systems
This commit is contained in:
Derek Higgins 2012-08-22 15:57:28 +01:00
parent 682c6931dc
commit 7034190780
5 changed files with 57 additions and 9 deletions

View File

@ -2,6 +2,7 @@ fixtures:
repositories:
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
"concat": "git://github.com/ripienaar/puppet-concat.git"
"create_resources": "git://github.com/puppetlabs/puppetlabs-create_resources.git"
"keystone": "git://github.com/puppetlabs/puppetlabs-keystone.git"
"memcached": "git://github.com/saz/puppet-memcached.git"
"rsync": "git://github.com/puppetlabs/puppetlabs-rsync.git"

36
manifests/storage/ext4.pp Normal file
View File

@ -0,0 +1,36 @@
# follow the instructions for creating a loopback device
# for storage from: http://swift.openstack.org/development_saio.html
#
#
#
# this define needs to be sent a refresh signal to do anything
#
#
# [*title*]
#
# [*byte_size*] Byte size to use for every inode in the created filesystem.
# It is recommened to use 1024 to ensure that the metadata can fit in a single inode.
define swift::storage::ext4(
$device,
$byte_size = '1024',
$mnt_base_dir = '/srv/node',
$loopback = false
) {
# does this have to be refreshonly?
# how can I know if this drive has been formatted?
exec { "mkfs-${name}":
command => "mkfs.ext4 -I ${byte_size} -F ${device}",
path => ['/sbin/'],
refreshonly => true,
}
swift::storage::mount { $name:
device => $device,
mnt_base_dir => $mnt_base_dir,
subscribe => Exec["mkfs-${name}"],
loopback => $loopback,
fstype => 'ext4',
}
}

View File

@ -10,7 +10,8 @@ define swift::storage::loopback(
$base_dir = '/srv/loopback-device',
$mnt_base_dir = '/srv/node',
$byte_size = '1024',
$seek = '25000'
$seek = '25000',
$fstype = 'xfs'
) {
if(!defined(File[$base_dir])) {
@ -34,12 +35,13 @@ define swift::storage::loopback(
require => File[$base_dir],
}
swift::storage::xfs { $name:
$storage_params = {
device => "${base_dir}/${name}",
mnt_base_dir => $mnt_base_dir,
byte_size => $byte_size,
subscribe => Exec["create_partition-${name}"],
loopback => true,
}
$device_config_hash = {"$name" => $storage_params,}
create_resources("swift::storage::$fstype", $device_config_hash)
}

View File

@ -6,13 +6,22 @@
define swift::storage::mount(
$device,
$mnt_base_dir = '/srv/node',
$loopback = false
$loopback = false,
$fstype = 'xfs'
) {
if($loopback){
$options = 'noatime,nodiratime,nobarrier,logbufs=8,loop'
$options = 'noatime,nodiratime,nobarrier,loop'
} else {
$options = 'noatime,nodiratime,nobarrier,logbufs=8'
$options = 'noatime,nodiratime,nobarrier'
}
if($fstype == 'xfs'){
$fsoptions = 'logbufs=8'
} else {
$fsoptions = 'user_xattr'
}
# the directory that represents the mount point
# needs to exist
file { "${mnt_base_dir}/${name}":
@ -24,8 +33,8 @@ define swift::storage::mount(
mount { "${mnt_base_dir}/${name}":
ensure => present,
device => $device,
fstype => 'xfs',
options => $options,
fstype => $fstype,
options => "$options,$fsoptions",
require => File["${mnt_base_dir}/${name}"]
}

View File

@ -34,7 +34,7 @@ describe 'swift::storage::mount' do
it { should contain_mount('/srv/node/dans_mount_point').with(
:device => '/dev/sda',
:options => 'noatime,nodiratime,nobarrier,logbufs=8,loop'
:options => 'noatime,nodiratime,nobarrier,loop,logbufs=8'
)}
end