From b9e8916fd800fa2c9c09492db17cf01da9cd29e9 Mon Sep 17 00:00:00 2001 From: Alex Izmaylov Date: Wed, 15 May 2019 13:54:14 +1000 Subject: [PATCH 1/2] Add ability to lock barman package --- manifests/init.pp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9659cae..1fafeab 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,10 @@ # class. # [*ensure*] - Ensure that Barman is installed. The default value is 'present'. # Otherwise it will be set as 'absent'. +# [*version*] - Specifies the version of barman packages. The default vaule is 'latest'. +# [*release*] - Optional, specifies the release of barman packages. The default vaule is 'undef'. +# [*arch*] - Optional, specifies the architecture of barman packages. The default vaule is 'noarch'. +# [*epoch*] - Optional, specifies the epoch of barman packages. The default vaule is '0'. # [*conf_template*] - Path of the template of the barman.conf configuration # file. The default value does not need to be changed. # [*logrotate_template*] - Path of the template of the logrotate.conf file. @@ -227,6 +231,10 @@ $user = $::barman::settings::user, $group = $::barman::settings::group, $ensure = 'present', + $version = 'latest', + $release = 'undef', + $arch = 'noarch', + $epoch = '0', $conf_template = 'barman/barman.conf.erb', $logrotate_template = 'barman/logrotate.conf.erb', $barman_fqdn = $::fqdn, @@ -410,9 +418,32 @@ } } } - package { 'barman': - ensure => $ensure, - tag => 'postgresql', + if $version == 'latest'{ + package { 'barman': + ensure => $ensure, + tag => 'postgresql', + } + }else{ + + # If no release specified - just use version + $install_version = $release ? {'undef' => $version, default => "${version}-${release}" } + case $ensure { + 'present': {$package_ensure = $install_version} # 'latest' or $install_version + 'absent': {$package_ensure = 'absent'} + } + case $release { + # If no release specified for locking - use * + 'undef': {$lock_version = "${version}-*"} + default: {$lock_version = $install_version} + } + yum::versionlock {"${epoch}:barman-${lock_version}.${arch}": + ensure => $ensure, + before => Package['barman'], + } -> + package {'barman': + ensure => $package_ensure, + tag => 'postgresql', + } } file { '/etc/barman.conf.d': From 4d507fdfc4949a644b3a50433c5dd489fdac98c2 Mon Sep 17 00:00:00 2001 From: Alex Izmaylov Date: Wed, 15 May 2019 14:05:26 +1000 Subject: [PATCH 2/2] Fix syntax as per linter warnings --- manifests/init.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 1fafeab..00e0460 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -429,18 +429,18 @@ $install_version = $release ? {'undef' => $version, default => "${version}-${release}" } case $ensure { 'present': {$package_ensure = $install_version} # 'latest' or $install_version - 'absent': {$package_ensure = 'absent'} + default: {$package_ensure = 'absent'} } case $release { - # If no release specified for locking - use * + # If no release specified for locking - use * 'undef': {$lock_version = "${version}-*"} default: {$lock_version = $install_version} } yum::versionlock {"${epoch}:barman-${lock_version}.${arch}": ensure => $ensure, before => Package['barman'], - } -> - package {'barman': + } + -> package {'barman': ensure => $package_ensure, tag => 'postgresql', }