Files
puppet-swift/manifests/storage/loopback.pp
Mathieu Gagné 178f4b18dc Various Puppet lint fixes
* Fix following warnings:
    * double quoted string containing no variables
    * indentation of => is not properly aligned
    * mode should be represented as a 4 digit octal value or symbolic mode
    * string containing only a variable
    * top-scope variable being used without an explicit namespace
    * unquoted file mode
    * variable not enclosed in {}
* Fix following errors:
    * trailing whitespace found
    * two-space soft tabs not used
* Remove quotes around class in include/require statements

Change-Id: Ia920d848e1955612a6486ec8731309e6d3a70f63
2013-08-02 11:51:57 -04:00

50 lines
1.5 KiB
Puppet

# follow the instructions for creating a loopback device
# for storage from: http://swift.openstack.org/development_saio.html
#
#
# creates a managed loopback interface
# - creates a file
# - 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',
$mnt_base_dir = '/srv/node',
$byte_size = '1024',
$seek = '25000',
$fstype = 'xfs'
) {
if(!defined(File[$base_dir])) {
file { $base_dir:
ensure => directory,
}
}
if(!defined(File[$mnt_base_dir])) {
file { $mnt_base_dir:
owner => 'swift',
group => 'swift',
ensure => directory,
}
}
exec { "create_partition-${name}":
command => "dd if=/dev/zero of=${base_dir}/${name} bs=${byte_size} count=0 seek=${seek}",
path => ['/usr/bin/', '/bin'],
unless => "test -f ${base_dir}/${name}",
require => File[$base_dir],
}
$storage_params = {
device => "${base_dir}/${name}",
mnt_base_dir => $mnt_base_dir,
byte_size => $byte_size,
subscribe => Exec["create_partition-${name}"],
loopback => true,
}
# NOTE(mgagne) Puppet does not allow hash keys to be bare variables.
# Keep double-quotes to avoid parse errors.
$device_config_hash = { "${name}" => $storage_params }
create_resources("swift::storage::${fstype}", $device_config_hash)
}