From 31b0d5d604a2beecb0d37fc8f48a54673889c8c4 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 29 Aug 2019 17:08:40 +0200 Subject: [PATCH] An lvm module that can set issue_discards and global_filter --- modules/lvm/manifests/init.pp | 24 ++++++++++++++++++++++ modules/lvm/templates/lvm.conf-buster.erb | 9 ++++++++ modules/lvm/templates/lvm.conf-stretch.erb | 10 +++++++++ 3 files changed, 43 insertions(+) create mode 100644 modules/lvm/manifests/init.pp diff --git a/modules/lvm/manifests/init.pp b/modules/lvm/manifests/init.pp new file mode 100644 index 000000000..782827ffe --- /dev/null +++ b/modules/lvm/manifests/init.pp @@ -0,0 +1,24 @@ +# put a lvm.conf file on the host, +# optionally with the global_filter attribute set, +# with issue_discards set as configured. +class lvm( + Optional[String] $global_filter = undef, + Boolean $issue_discards = false, +) { + if (versioncmp($::lsbmajdistrelease, '10') >= 0) { + $template = 'lvm/lvm.conf-buster.erb' + } else { + $template = 'lvm/lvm.conf-stretch.erb' + } + + file { '/etc/lvm/lvm.conf': + ensure => file, + content => template($template), + notify => [ Exec['update-initramfs -u'], Exec['vgscan'] ]; + } + + exec { 'vgscan': + path => '/etc/init.d:/usr/bin:/usr/sbin:/bin:/sbin', + refreshonly => true; + } +} diff --git a/modules/lvm/templates/lvm.conf-buster.erb b/modules/lvm/templates/lvm.conf-buster.erb index f2bcf0235..fe17ea969 100644 --- a/modules/lvm/templates/lvm.conf-buster.erb +++ b/modules/lvm/templates/lvm.conf-buster.erb @@ -148,6 +148,10 @@ devices { # global_filter are not opened by LVM. # This configuration option has an automatic default value. # global_filter = [ "a|.*/|" ] +<% if @global_filter -%> + global_filter = <%= @global_filter -%> + +<% end -%> # Configuration option devices/types. # List of additional acceptable block device types. @@ -282,8 +286,13 @@ devices { # benefit from discards, but SSDs and thinly provisioned LUNs # generally do. If enabled, discards will only be issued if both the # storage and kernel provide support. +<% if @issue_discards -%> + issue_discards = 1 + +<% else -%> issue_discards = 0 +<% end -%> # Configuration option devices/allow_changes_with_duplicate_pvs. # Allow VG modification while a PV appears on multiple devices. # When a PV appears on multiple devices, LVM attempts to choose the diff --git a/modules/lvm/templates/lvm.conf-stretch.erb b/modules/lvm/templates/lvm.conf-stretch.erb index feb491732..7392a4d12 100644 --- a/modules/lvm/templates/lvm.conf-stretch.erb +++ b/modules/lvm/templates/lvm.conf-stretch.erb @@ -149,6 +149,10 @@ devices { # global_filter are not opened by LVM. # This configuration option has an automatic default value. # global_filter = [ "a|.*/|" ] +<% if @global_filter -%> + global_filter = <%= @global_filter -%> + +<% end -%> # Configuration option devices/cache_dir. # Directory in which to store the device cache file. @@ -298,8 +302,14 @@ devices { # benefit from discards, but SSDs and thinly provisioned LUNs # generally do. If enabled, discards will only be issued if both the # storage and kernel provide support. +<% if @issue_discards -%> + issue_discards = 1 + +<% else -%> issue_discards = 0 +<% end -%> + # Configuration option devices/allow_changes_with_duplicate_pvs. # Allow VG modification while a PV appears on multiple devices. # When a PV appears on multiple devices, LVM attempts to choose the -- 2.20.1