Merge "disk: Expose more options"
This commit is contained in:
commit
4105195a3b
@ -39,13 +39,26 @@
|
||||
# server is fully setup or if the partition was created outside of puppet.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*filesystem_type*]
|
||||
# (optional) The filesystem deployed on the device. Currently only ext4 and
|
||||
# xfs are supported.
|
||||
# Defaults to 'xfs'.
|
||||
#
|
||||
# [*mount_type*]
|
||||
# (optional) Define if the device is mounted by the device partition path,
|
||||
# UUID, or filesystem label.
|
||||
# Defaults to 'path'.
|
||||
#
|
||||
# [*manage_filesystem*]
|
||||
# (optional) If set to false, skip calling xfs_admin -l to check if a
|
||||
# partition needs to be formatted with mkfs.xfs, which can, in some cases,
|
||||
# increase the load on the server. This is to set to false only after the
|
||||
# server is fully setup, or if the filesystem was created outside of puppet.
|
||||
# (optional) If set to false, skip creating filesystem. This is to set to
|
||||
# false only after the server is fully setup, or if the filesystem was
|
||||
# created outside of puppet.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*label*]
|
||||
# (optional) Filesystem label.
|
||||
# Defaults to $name.
|
||||
#
|
||||
# =Example=
|
||||
#
|
||||
# Simply add one disk sdb:
|
||||
@ -61,12 +74,15 @@
|
||||
# TODO(yuxcer): maybe we can remove param $base_dir
|
||||
#
|
||||
define swift::storage::disk(
|
||||
Stdlib::Absolutepath $base_dir = '/dev',
|
||||
Stdlib::Absolutepath $mnt_base_dir = '/srv/node',
|
||||
$byte_size = '1024',
|
||||
$ext_args = '',
|
||||
Boolean $manage_partition = true,
|
||||
Boolean $manage_filesystem = true,
|
||||
Stdlib::Absolutepath $base_dir = '/dev',
|
||||
Stdlib::Absolutepath $mnt_base_dir = '/srv/node',
|
||||
$byte_size = '1024',
|
||||
$ext_args = '',
|
||||
Boolean $manage_partition = true,
|
||||
Enum['ext4', 'xfs'] $filesystem_type = 'xfs',
|
||||
Enum['path', 'uuid', 'label'] $mount_type = 'path',
|
||||
Boolean $manage_filesystem = true,
|
||||
String[1] $label = $name,
|
||||
) {
|
||||
|
||||
include swift::deps
|
||||
@ -89,15 +105,22 @@ define swift::storage::disk(
|
||||
onlyif => ["test -b ${base_dir}/${name}","parted ${base_dir}/${name} print|tail -1|grep 'Error'"],
|
||||
before => Anchor['swift::config::end'],
|
||||
}
|
||||
Exec["create_partition_label-${name}"] ~> Swift::Storage::Xfs<| title == $name |>
|
||||
|
||||
if $filesystem_type == 'xfs' {
|
||||
Exec["create_partition_label-${name}"] ~> Swift::Storage::Xfs[$name]
|
||||
} else {
|
||||
Exec["create_partition_label-${name}"] ~> Swift::Storage::Ext4[$name]
|
||||
}
|
||||
}
|
||||
|
||||
swift::storage::xfs { $name:
|
||||
device => "${base_dir}/${name}",
|
||||
mnt_base_dir => $mnt_base_dir,
|
||||
byte_size => $byte_size,
|
||||
loopback => false,
|
||||
manage_filesystem => $manage_filesystem,
|
||||
}
|
||||
create_resources("swift::storage::${filesystem_type}", { $name => {
|
||||
'device' => "${base_dir}/${name}",
|
||||
'mnt_base_dir' => $mnt_base_dir,
|
||||
'byte_size' => $byte_size,
|
||||
'loopback' => false,
|
||||
'mount_type' => $mount_type,
|
||||
'manage_filesystem' => $manage_filesystem,
|
||||
'label' => $label,
|
||||
}})
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The ``swift::storage::disk`` defined resource type now supports
|
||||
the following parameters.
|
||||
|
||||
- ``filesystem_type``
|
||||
- ``mount_type``
|
||||
- ``label``
|
@ -24,7 +24,9 @@ describe 'swift::storage::disk' do
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:byte_size => '1024',
|
||||
:loopback => false,
|
||||
:mount_type => 'path',
|
||||
:manage_filesystem => true,
|
||||
:label => 'sdb',
|
||||
) }
|
||||
end
|
||||
|
||||
@ -34,6 +36,7 @@ describe 'swift::storage::disk' do
|
||||
:mnt_base_dir => '/srv/data',
|
||||
:byte_size => '2048',
|
||||
:ext_args => 'mkpart primary 0% 100%',
|
||||
:mount_type => 'label',
|
||||
:manage_filesystem => false,
|
||||
}
|
||||
end
|
||||
@ -50,7 +53,34 @@ describe 'swift::storage::disk' do
|
||||
:mnt_base_dir => '/srv/data',
|
||||
:byte_size => '2048',
|
||||
:loopback => false,
|
||||
:mount_type => 'label',
|
||||
:manage_filesystem => false,
|
||||
:label => 'sdb',
|
||||
) }
|
||||
end
|
||||
|
||||
context 'with ext4 filesystem type' do
|
||||
let :params do
|
||||
{
|
||||
:filesystem_type => 'ext4'
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec('create_partition_label-sdb').with(
|
||||
:command => 'parted -s /dev/sdb mklabel gpt ',
|
||||
:path => ['/usr/bin/', '/sbin', '/bin'],
|
||||
:onlyif => ['test -b /dev/sdb', 'parted /dev/sdb print|tail -1|grep \'Error\''],
|
||||
:before => 'Anchor[swift::config::end]'
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_swift__storage__ext4('sdb').with(
|
||||
:device => '/dev/sdb',
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:byte_size => '1024',
|
||||
:loopback => false,
|
||||
:mount_type => 'path',
|
||||
:manage_filesystem => true,
|
||||
:label => 'sdb',
|
||||
) }
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user