diff --git a/manifests/storage/xfs.pp b/manifests/storage/xfs.pp index 3de40dce..372eeaf1 100644 --- a/manifests/storage/xfs.pp +++ b/manifests/storage/xfs.pp @@ -17,11 +17,16 @@ # (optional) Define if the device must be mounted as a loopback or not # Defaults to false. # +# [*mount_type*] +# (optional) Define if the device is mounted by the device partition path or UUID. +# Defaults to 'path'. +# # Sample usage: # # swift::storage::xfs { # ['sdb', 'sdc', 'sde', 'sdf', 'sdg', 'sdh', 'sdi', 'sdj', 'sdk']: # mnt_base_dir => '/srv/node', +# mount_type => 'uuid', # require => Class['swift']; # } # @@ -32,7 +37,8 @@ define swift::storage::xfs( $device = '', $byte_size = '1024', $mnt_base_dir = '/srv/node', - $loopback = false + $loopback = false, + $mount_type = 'path', ) { include ::swift::deps @@ -44,6 +50,14 @@ define swift::storage::xfs( $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])) { file { $mnt_base_dir: ensure => directory, @@ -67,7 +81,7 @@ define swift::storage::xfs( } swift::storage::mount { $name: - device => $target_device, + device => $mount_device, mnt_base_dir => $mnt_base_dir, subscribe => Exec["mkfs-${name}"], loopback => $loopback, diff --git a/releasenotes/notes/add-device-mount-type-support-2a5f1df26c2d1e68.yaml b/releasenotes/notes/add-device-mount-type-support-2a5f1df26c2d1e68.yaml new file mode 100644 index 00000000..08aaf33f --- /dev/null +++ b/releasenotes/notes/add-device-mount-type-support-2a5f1df26c2d1e68.yaml @@ -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. diff --git a/spec/defines/swift_storage_xfs_spec.rb b/spec/defines/swift_storage_xfs_spec.rb index 517789da..47c1698b 100644 --- a/spec/defines/swift_storage_xfs_spec.rb +++ b/spec/defines/swift_storage_xfs_spec.rb @@ -10,7 +10,8 @@ describe 'swift::storage::xfs' do :device => "/dev/#{title}", :byte_size => '1024', :mnt_base_dir => '/srv/node', - :loopback => false + :loopback => false, + :device_type => 'path' } end