Add Support of mounting devices by UUIDs
In currently, swift::storage::xfs will mount device by its file path, like /dev/sda1. But the device file path will change when the computer reboots. This will lead Swift services fails to boot. This patch introduces $device_type param to support mount disk by UUIDs. By default, it will set to 'path' to keep compatiable. Change-Id: I1782c0b18a27203e90d27473d94fa16968c3f913
This commit is contained in:
parent
28d2018d0a
commit
4ba33cdff2
@ -17,11 +17,16 @@
|
|||||||
# (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*]
|
||||||
|
# (optional) Define if the device is mounted by the device partition path or UUID.
|
||||||
|
# Defaults to 'path'.
|
||||||
|
#
|
||||||
# Sample usage:
|
# Sample usage:
|
||||||
#
|
#
|
||||||
# swift::storage::xfs {
|
# swift::storage::xfs {
|
||||||
# ['sdb', 'sdc', 'sde', 'sdf', 'sdg', 'sdh', 'sdi', 'sdj', 'sdk']:
|
# ['sdb', 'sdc', 'sde', 'sdf', 'sdg', 'sdh', 'sdi', 'sdj', 'sdk']:
|
||||||
# mnt_base_dir => '/srv/node',
|
# mnt_base_dir => '/srv/node',
|
||||||
|
# mount_type => 'uuid',
|
||||||
# require => Class['swift'];
|
# require => Class['swift'];
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
@ -32,7 +37,8 @@ define swift::storage::xfs(
|
|||||||
$device = '',
|
$device = '',
|
||||||
$byte_size = '1024',
|
$byte_size = '1024',
|
||||||
$mnt_base_dir = '/srv/node',
|
$mnt_base_dir = '/srv/node',
|
||||||
$loopback = false
|
$loopback = false,
|
||||||
|
$mount_type = 'path',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include ::swift::deps
|
include ::swift::deps
|
||||||
@ -44,6 +50,14 @@ define swift::storage::xfs(
|
|||||||
$target_device = $device
|
$target_device = $device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case $mount_type {
|
||||||
|
'path': { $mount_device = $target_device }
|
||||||
|
'uuid': { $mount_device = dig44($facts, ['partitions', $target_device, 'uuid'])
|
||||||
|
unless $mount_device { fail("Unable to fetch uuid of ${target_device}") }
|
||||||
|
}
|
||||||
|
default: { fail("Unsupported mount_type parameter value: '${mount_type}'. Should be 'path' or 'uuid'.") }
|
||||||
|
}
|
||||||
|
|
||||||
if(!defined(File[$mnt_base_dir])) {
|
if(!defined(File[$mnt_base_dir])) {
|
||||||
file { $mnt_base_dir:
|
file { $mnt_base_dir:
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
@ -67,7 +81,7 @@ define swift::storage::xfs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
swift::storage::mount { $name:
|
swift::storage::mount { $name:
|
||||||
device => $target_device,
|
device => $mount_device,
|
||||||
mnt_base_dir => $mnt_base_dir,
|
mnt_base_dir => $mnt_base_dir,
|
||||||
subscribe => Exec["mkfs-${name}"],
|
subscribe => Exec["mkfs-${name}"],
|
||||||
loopback => $loopback,
|
loopback => $loopback,
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Add device_type param to support mount disk partitions by UUID,
|
||||||
|
this is more helpful than device path in production environment.
|
@ -10,7 +10,8 @@ describe 'swift::storage::xfs' do
|
|||||||
:device => "/dev/#{title}",
|
:device => "/dev/#{title}",
|
||||||
:byte_size => '1024',
|
:byte_size => '1024',
|
||||||
:mnt_base_dir => '/srv/node',
|
:mnt_base_dir => '/srv/node',
|
||||||
:loopback => false
|
:loopback => false,
|
||||||
|
:device_type => 'path'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user