Merge "xfs: Support mount by label"
This commit is contained in:
commit
dd5ebbb3f3
|
@ -34,7 +34,7 @@ define swift::storage::ext4(
|
||||||
# does this have to be refreshonly?
|
# does this have to be refreshonly?
|
||||||
# how can I know if this drive has been formatted?
|
# how can I know if this drive has been formatted?
|
||||||
exec { "mkfs-${name}":
|
exec { "mkfs-${name}":
|
||||||
command => "mkfs.ext4 -I ${byte_size} -F ${device}",
|
command => ['mkfs.ext4', '-I', $byte_size, '-F', $device],
|
||||||
path => ['/sbin/'],
|
path => ['/sbin/'],
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
before => Anchor['swift::config::end'],
|
before => Anchor['swift::config::end'],
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
# Defaults to 'xfs'.
|
# Defaults to 'xfs'.
|
||||||
#
|
#
|
||||||
define swift::storage::mount(
|
define swift::storage::mount(
|
||||||
Stdlib::Absolutepath $device = "/dev/${name}",
|
Swift::MountDevice $device = "/dev/${name}",
|
||||||
Stdlib::Absolutepath $mnt_base_dir = '/srv/node',
|
Stdlib::Absolutepath $mnt_base_dir = '/srv/node',
|
||||||
Boolean $loopback = false,
|
Boolean $loopback = false,
|
||||||
String[1] $fstype = 'xfs'
|
String[1] $fstype = 'xfs'
|
||||||
|
@ -50,7 +50,7 @@ define swift::storage::mount(
|
||||||
# Make root own the mount point to prevent swift processes from writing files
|
# Make root own the mount point to prevent swift processes from writing files
|
||||||
# when the disk device is not mounted
|
# when the disk device is not mounted
|
||||||
exec { "fix_mountpoint_permissions_${name}":
|
exec { "fix_mountpoint_permissions_${name}":
|
||||||
command => "chown -R root:root ${mnt_base_dir}/${name}",
|
command => ['chown', '-R', 'root:root', "${mnt_base_dir}/${name}"],
|
||||||
path => ['/usr/bin', '/bin'],
|
path => ['/usr/bin', '/bin'],
|
||||||
before => Anchor['swift::config::end'],
|
before => Anchor['swift::config::end'],
|
||||||
unless => "grep ${mnt_base_dir}/${name} /etc/mtab",
|
unless => "grep ${mnt_base_dir}/${name} /etc/mtab",
|
||||||
|
@ -75,7 +75,7 @@ define swift::storage::mount(
|
||||||
$group = $::swift::params::group
|
$group = $::swift::params::group
|
||||||
|
|
||||||
exec { "fix_mount_permissions_${name}":
|
exec { "fix_mount_permissions_${name}":
|
||||||
command => "chown -R ${user}:${group} ${mnt_base_dir}/${name}",
|
command => ['chown', '-R', "${user}:${group}", "${mnt_base_dir}/${name}"],
|
||||||
path => ['/usr/bin', '/bin'],
|
path => ['/usr/bin', '/bin'],
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
before => Anchor['swift::config::end'],
|
before => Anchor['swift::config::end'],
|
||||||
|
@ -98,7 +98,7 @@ define swift::storage::mount(
|
||||||
# systems :(
|
# systems :(
|
||||||
if (str2bool($facts['os']['selinux']['enabled']) == true) {
|
if (str2bool($facts['os']['selinux']['enabled']) == true) {
|
||||||
exec { "restorecon_mount_${name}":
|
exec { "restorecon_mount_${name}":
|
||||||
command => "restorecon ${mnt_base_dir}/${name}",
|
command => ['restorecon', "${mnt_base_dir}/${name}"],
|
||||||
path => ['/usr/sbin', '/sbin'],
|
path => ['/usr/sbin', '/sbin'],
|
||||||
before => Anchor['swift::config::end'],
|
before => Anchor['swift::config::end'],
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
|
|
|
@ -12,15 +12,16 @@
|
||||||
#
|
#
|
||||||
# [*byte_size*]
|
# [*byte_size*]
|
||||||
# (optional) Byte size to use for every inode in the created filesystem.
|
# (optional) Byte size to use for every inode in the created filesystem.
|
||||||
# Defaults to '1024'. It is recommended to use 1024 to ensure that the metadata can fit
|
# Defaults to '1024'. It is recommended to use 1024 to ensure that
|
||||||
# in a single inode.
|
# the metadata can fit in a single inode.
|
||||||
#
|
#
|
||||||
# [*loopback*]
|
# [*loopback*]
|
||||||
# (optional) Define if the device must be mounted as a loopback or not
|
# (optional) Define if the device must be mounted as a loopback or not
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
# [*mount_type*]
|
# [*mount_type*]
|
||||||
# (optional) Define if the device is mounted by the device partition path or UUID.
|
# (optional) Define if the device is mounted by the device partition path,
|
||||||
|
# UUID, or filesystem label.
|
||||||
# Defaults to 'path'.
|
# Defaults to 'path'.
|
||||||
#
|
#
|
||||||
# [*manage_filesystem*]
|
# [*manage_filesystem*]
|
||||||
|
@ -30,6 +31,10 @@
|
||||||
# server is fully setup, or if the filesystem was created outside of puppet.
|
# server is fully setup, or if the filesystem was created outside of puppet.
|
||||||
# Defaults to true.
|
# Defaults to true.
|
||||||
#
|
#
|
||||||
|
# [*label*]
|
||||||
|
# (optional) Filesystem label.
|
||||||
|
# Defaults to $name.
|
||||||
|
#
|
||||||
# Sample usage:
|
# Sample usage:
|
||||||
#
|
#
|
||||||
# swift::storage::xfs {
|
# swift::storage::xfs {
|
||||||
|
@ -43,12 +48,13 @@
|
||||||
# it already has an XFS FS, and mounts de FS in /srv/node/sdX
|
# it already has an XFS FS, and mounts de FS in /srv/node/sdX
|
||||||
#
|
#
|
||||||
define swift::storage::xfs(
|
define swift::storage::xfs(
|
||||||
Stdlib::Absolutepath $device = "/dev/${name}",
|
Stdlib::Absolutepath $device = "/dev/${name}",
|
||||||
$byte_size = '1024',
|
$byte_size = '1024',
|
||||||
Stdlib::Absolutepath $mnt_base_dir = '/srv/node',
|
Stdlib::Absolutepath $mnt_base_dir = '/srv/node',
|
||||||
Boolean $loopback = false,
|
Boolean $loopback = false,
|
||||||
Enum['path', 'uuid'] $mount_type = 'path',
|
Enum['path', 'uuid', 'label'] $mount_type = 'path',
|
||||||
Boolean $manage_filesystem = true,
|
Boolean $manage_filesystem = true,
|
||||||
|
String[1] $label = $name,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include swift::deps
|
include swift::deps
|
||||||
|
@ -67,6 +73,9 @@ define swift::storage::xfs(
|
||||||
fail("Unable to fetch uuid of ${device}")
|
fail("Unable to fetch uuid of ${device}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'label': {
|
||||||
|
$mount_device = "LABEL=${label}"
|
||||||
|
}
|
||||||
default: { # path
|
default: { # path
|
||||||
$mount_device = $device
|
$mount_device = $device
|
||||||
}
|
}
|
||||||
|
@ -87,8 +96,14 @@ define swift::storage::xfs(
|
||||||
# so we format it. If device has a valid XFS FS, command returns 0
|
# so we format it. If device has a valid XFS FS, command returns 0
|
||||||
# So we do NOT touch it.
|
# So we do NOT touch it.
|
||||||
if $manage_filesystem {
|
if $manage_filesystem {
|
||||||
|
$mkfs_command = ['mkfs.xfs', '-f', '-i', "size=${byte_size}"]
|
||||||
|
$mkfs_label_opt = $mount_type ? {
|
||||||
|
'label' => ['-L', $label],
|
||||||
|
default => []
|
||||||
|
}
|
||||||
|
|
||||||
exec { "mkfs-${name}":
|
exec { "mkfs-${name}":
|
||||||
command => "mkfs.xfs -f -i size=${byte_size} ${device}",
|
command => $mkfs_command + $mkfs_label_opt + [$device],
|
||||||
path => ['/sbin/', '/usr/sbin/'],
|
path => ['/sbin/', '/usr/sbin/'],
|
||||||
unless => "xfs_admin -l ${device}",
|
unless => "xfs_admin -l ${device}",
|
||||||
before => Anchor['swift::config::end'],
|
before => Anchor['swift::config::end'],
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The ``swift::storage::xfs`` defined resource type now supports
|
||||||
|
``type => 'label'``, which uses filesystem label for mount.
|
||||||
|
When this is used, the defined type adds the label, according to the new
|
||||||
|
``label`` parameter, which defaults to the title, when creating a XFS file
|
||||||
|
system.
|
|
@ -47,7 +47,7 @@ describe 'swift::storage::mount' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_exec("restorecon_mount_dans_mount_point").with(
|
it { is_expected.to contain_exec("restorecon_mount_dans_mount_point").with(
|
||||||
:command => "restorecon /srv/node/dans_mount_point",
|
:command => ['restorecon', '/srv/node/dans_mount_point'],
|
||||||
:path => ['/usr/sbin', '/sbin'],
|
:path => ['/usr/sbin', '/sbin'],
|
||||||
:refreshonly => true
|
:refreshonly => true
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -36,8 +36,9 @@ describe 'swift::storage::xfs' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_exec("mkfs-foo").with(
|
it { is_expected.to contain_exec("mkfs-foo").with(
|
||||||
:command => "mkfs.xfs -f -i size=#{param_hash[:byte_size]} #{param_hash[:device]}",
|
:command => ['mkfs.xfs', '-f', '-i', "size=#{param_hash[:byte_size]}", param_hash[:device]],
|
||||||
:path => ['/sbin/', '/usr/sbin/'],
|
:path => ['/sbin/', '/usr/sbin/'],
|
||||||
|
:unless => "xfs_admin -l #{param_hash[:device]}",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
it { is_expected.to contain_swift__storage__mount(title).with(
|
it { is_expected.to contain_swift__storage__mount(title).with(
|
||||||
|
@ -47,6 +48,30 @@ describe 'swift::storage::xfs' do
|
||||||
)}
|
)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with mount type label' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:mount_type => :label
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :param_hash do
|
||||||
|
default_params.merge(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to contain_exec("mkfs-foo").with(
|
||||||
|
:command => ['mkfs.xfs', '-f', '-i', "size=#{param_hash[:byte_size]}", '-L', title, param_hash[:device]],
|
||||||
|
:path => ['/sbin/', '/usr/sbin/'],
|
||||||
|
:unless => "xfs_admin -l #{param_hash[:device]}",
|
||||||
|
)}
|
||||||
|
|
||||||
|
it { is_expected.to contain_swift__storage__mount(title).with(
|
||||||
|
:device => "LABEL=#{title}",
|
||||||
|
:mnt_base_dir => param_hash[:mnt_base_dir],
|
||||||
|
:loopback => param_hash[:loopback],
|
||||||
|
)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
type Swift::MountDevice = Variant[
|
||||||
|
Stdlib::Absolutepath,
|
||||||
|
Pattern[/^LABEL=.+$/]
|
||||||
|
]
|
Loading…
Reference in New Issue