From ce5c38c91c4445b31d8f17c069b886a1a3191487 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 19 Oct 2019 16:08:17 +0200 Subject: [PATCH 01/11] fix puppet-lint warnings / switch to facts hash --- manifests/repo/apt.pp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index db0894e9..6694550c 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -55,21 +55,17 @@ } # the Gluster repo only supports x86_64 (amd64) and arm64. The Ubuntu PPA also supports armhf and arm64. - case $::operatingsystem { + case $facts['os']['name'] { 'Debian': { - case $::lsbdistcodename { - 'jessie', 'stretch': { - $arch = $::architecture ? { - 'amd64' => 'amd64', - 'arm64' => 'arm64', - default => false, - } - if versioncmp($release, '3.12') < 0 { - $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${::lsbdistcodename}/apt/" - } else { - $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${::lsbdistcodename}/${arch}/apt/" - } - } + $arch = $facts['architecture'] ? { + 'amd64' => 'amd64', + 'arm64' => 'arm64', + default => false, + } + if versioncmp($release, '3.12') < 0 { + $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${facts['lsbdistcodename']}/apt/" + } else { + $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${facts['lsbdistcodename']}/${arch}/apt/" } } default: { @@ -77,7 +73,7 @@ } } if ! $arch { - fail("Architecture ${::architecture} not yet supported for ${::operatingsystem}.") + fail("Architecture ${facts['architecture']} not yet supported for ${facts['operatingsystem']}.") } $repo = { From 479c937ebb2b6fc5b2a2854874340101fae5931d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 19 Oct 2019 18:20:29 +0200 Subject: [PATCH 02/11] remove uneeded param for apt resource --- manifests/repo/apt.pp | 1 - spec/classes/repo_apt_spec.rb | 4 ---- 2 files changed, 5 deletions(-) diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 6694550c..d8c3e719 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -80,7 +80,6 @@ "glusterfs-${version}" => { ensure => present, location => $repo_url, - release => $::lsbdistcodename, repos => 'main', key => { id => $repo_key_name, diff --git a/spec/classes/repo_apt_spec.rb b/spec/classes/repo_apt_spec.rb index 3ea51572..8dd5f369 100644 --- a/spec/classes/repo_apt_spec.rb +++ b/spec/classes/repo_apt_spec.rb @@ -18,7 +18,6 @@ it 'installs' do is_expected.to contain_apt__source('glusterfs-LATEST').with( repos: 'main', - release: facts[:lsbdistcodename].to_s, location: "https://download.gluster.org/pub/gluster/glusterfs/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/" ) end @@ -46,7 +45,6 @@ it 'installs' do is_expected.to contain_apt__source('glusterfs-LATEST').with( repos: 'main', - release: facts[:lsbdistcodename].to_s, location: "https://download.gluster.org/pub/gluster/glusterfs/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/", pin: '700' ) @@ -63,7 +61,6 @@ it 'installs' do is_expected.to contain_apt__source('glusterfs-LATEST').with( repos: 'main', - release: facts[:lsbdistcodename].to_s, key: { 'id' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97', 'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/4.1/rsa.pub' @@ -83,7 +80,6 @@ it 'installs' do is_expected.to contain_apt__source('glusterfs-LATEST').with( repos: 'main', - release: facts[:lsbdistcodename].to_s, key: { 'id' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4', 'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub' From 9f2fb971b2cc5f999047a928e3940742aa3bcae3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 19 Oct 2019 18:53:03 +0200 Subject: [PATCH 03/11] configure GPG keys for gluster 6/7 deb repos --- manifests/repo/apt.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index d8c3e719..fbf4ea13 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -38,6 +38,8 @@ '4.0' => '55F839E173AC06F364120D46FA86EEACB306CEE1', '4.1' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97', '^5\.(\d)+$' => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C', + /^6/ => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C', + /^7/ => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C', default => '849512C2CA648EF425048F55C883F50CB2289A17', } From abdc0903d1bd6f109d1a4ad2a474247f135f45b1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 19 Oct 2019 19:10:25 +0200 Subject: [PATCH 04/11] use parameters from main class --- manifests/repo/apt.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index fbf4ea13..0fa05b68 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -24,9 +24,9 @@ # @note Copyright 2015 RL Solutions, unless otherwise noted # class gluster::repo::apt ( - $version = $gluster::params::version, - $release = $gluster::params::release, - $priority = $gluster::params::repo_priority, + $version = $gluster::version, + $release = $gluster::release, + $priority = $gluster::repo_priority, ) { include 'apt' From 631ce5993b3a9adf986620fdca908684388e1916 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 19 Oct 2019 19:36:16 +0200 Subject: [PATCH 05/11] enforce release param as string --- manifests/init.pp | 2 +- manifests/repo/apt.pp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 48208e53..25e20846 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,7 +43,7 @@ $client_package = $gluster::params::client_package, $pool = $gluster::params::pool, $repo = $gluster::params::repo, - $release = $gluster::params::release, + String $release = $gluster::params::release, $server = $gluster::params::install_server, $server_package = $gluster::params::server_package, $use_exported_resources = $gluster::params::export_resources, diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 0fa05b68..327ce50f 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -24,9 +24,9 @@ # @note Copyright 2015 RL Solutions, unless otherwise noted # class gluster::repo::apt ( - $version = $gluster::version, - $release = $gluster::release, - $priority = $gluster::repo_priority, + $version = $gluster::version, + String[1] $release = $gluster::release, + $priority = $gluster::repo_priority, ) { include 'apt' From e548bff396080171cc3ecd1d268954e226580a38 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 19 Oct 2019 19:37:22 +0200 Subject: [PATCH 06/11] set default gluterfs version 3.12->6 --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index f3dc0ea3..930aa404 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,7 +8,7 @@ # parameters dealing with installation $install_server = true $install_client = true - $release = '3.12' + $release = '6' $version = 'LATEST' # we explicitly do NOT set a priority here. The user must define From be291142e17f5b8368cbd2fc87b874ce15bea8fe Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 20 Oct 2019 16:54:36 +0200 Subject: [PATCH 07/11] drop legacy glusterfs code --- manifests/repo/apt.pp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 327ce50f..1e6573cb 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -31,11 +31,6 @@ include 'apt' $repo_key_name = $release ? { - '3.10' => 'C784DD0FD61E38B8B1F65E10DAD761554A72C1DF', - '3.11' => 'DE82F0BACC4DB70DBEF95CA65EC2255642304A6E', - '3.12' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4', - '3.13' => '9B5AE8E6FD2581F293104ACC38675E5F30F779AF', - '4.0' => '55F839E173AC06F364120D46FA86EEACB306CEE1', '4.1' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97', '^5\.(\d)+$' => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C', /^6/ => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C', @@ -64,11 +59,7 @@ 'arm64' => 'arm64', default => false, } - if versioncmp($release, '3.12') < 0 { - $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${facts['lsbdistcodename']}/apt/" - } else { - $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${facts['lsbdistcodename']}/${arch}/apt/" - } + $repo_url = "https://download.gluster.org/pub/gluster/glusterfs/${release}/LATEST/Debian/${facts['lsbdistcodename']}/${arch}/apt/" } default: { fail('gluster::repo::apt currently only works on Debian') From 3c00b160dde0a455e4bd3980dacec5704420b0bc Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 20 Oct 2019 17:24:20 +0200 Subject: [PATCH 08/11] enhance datatype handling --- manifests/volume.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/volume.pp b/manifests/volume.pp index e09b2e59..e32ab3fa 100644 --- a/manifests/volume.pp +++ b/manifests/volume.pp @@ -48,7 +48,7 @@ Boolean $rebalance = true, Boolean $heal = true, Boolean $remove_options = false, - Optional[Array] $options = undef, + Array[String[1]] $options = [], Optional[Integer] $stripe = undef, Optional[Integer] $replica = undef, Optional[Integer] $arbiter = undef, @@ -74,7 +74,7 @@ $_transport = "transport ${transport}" - if $options and ! empty( $options ) { + if ! empty( $options ) { $_options = sort( $options ) } else { $_options = undef From 55f593d981e1a8de5cca7ee98927b549b806fbbb Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 20 Oct 2019 17:24:34 +0200 Subject: [PATCH 09/11] fix datatype in volume::options --- manifests/volume/option.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/volume/option.pp b/manifests/volume/option.pp index 127db0a8..e8536278 100644 --- a/manifests/volume/option.pp +++ b/manifests/volume/option.pp @@ -26,7 +26,7 @@ # @note Copyright 2014 CoverMyMeds, unless otherwise noted # define gluster::volume::option ( - Optional[String] $value = undef, + $value = undef, Enum['present', 'absent'] $ensure = 'present', ) { From 20decb51ad014a16c0554ff0dd057766009a452f Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 20 Oct 2019 18:37:37 +0200 Subject: [PATCH 10/11] refactor parameter handling --- manifests/client.pp | 26 +++++++--- manifests/init.pp | 49 +++++++++++------- manifests/install.pp | 26 +++++++--- manifests/params.pp | 39 +++++++-------- manifests/repo.pp | 23 +++++++-- manifests/repo/apt.pp | 15 +++--- manifests/repo/yum.pp | 10 ++-- manifests/service.pp | 2 + spec/classes/install_spec.rb | 73 --------------------------- spec/classes/repo_apt_spec.rb | 94 ----------------------------------- spec/classes/repo_yum_spec.rb | 72 --------------------------- spec/classes/service_spec.rb | 25 ---------- 12 files changed, 121 insertions(+), 333 deletions(-) delete mode 100644 spec/classes/install_spec.rb delete mode 100644 spec/classes/repo_apt_spec.rb delete mode 100644 spec/classes/repo_yum_spec.rb delete mode 100644 spec/classes/service_spec.rb diff --git a/manifests/client.pp b/manifests/client.pp index 89e09aa6..40cdbcce 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -21,17 +21,27 @@ # @author Scott Merrill # @note Copyright 2014 CoverMyMeds, unless otherwise noted # +# class gluster::client ( - Boolean $repo = $gluster::params::repo, - String $client_package = $gluster::params::client_package, - String $version = $gluster::params::version, + Boolean $repo = $gluster::params::repo, + String $client_package = $gluster::params::client_package, + String $version = $gluster::params::version, + String $release = $gluster::params::release, + Optional $repo_key_source = $gluster::params::repo_key_source, ) inherits gluster::params { + # if we manage the repository, we also need a GPG key + if $repo { + assert_type(Variant[Stdlib::Absolutepath, Stdlib::HTTPSUrl], $repo_key_source) + } + class { 'gluster::install': - server => false, - client => true, - repo => $repo, - version => $version, - client_package => $client_package, + server => false, + client => true, + repo => $repo, + version => $version, + client_package => $client_package, + release => $release, + repo_key_source => $repo_key_source, } } diff --git a/manifests/init.pp b/manifests/init.pp index 25e20846..861e83aa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -15,7 +15,10 @@ # the version to install # @param volumes # optional list of volumes (and their properties) to create -# +# @param priority +# The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL +# @param repo_key_source +# Link/path to the GPG key for the repository. Currently only used at RedHat based platforms # @example # class { ::gluster: # client => false, @@ -39,25 +42,35 @@ # @note Copyright 2014 CoverMyMeds, unless otherwise noted # class gluster ( - Boolean $client = $gluster::params::install_client, - $client_package = $gluster::params::client_package, - $pool = $gluster::params::pool, - $repo = $gluster::params::repo, - String $release = $gluster::params::release, - $server = $gluster::params::install_server, - $server_package = $gluster::params::server_package, - $use_exported_resources = $gluster::params::export_resources, - $version = $gluster::params::version, - Optional[Hash] $volumes = undef, -) inherits ::gluster::params { + Boolean $client = $gluster::params::install_client, + $client_package = $gluster::params::client_package, + $pool = $gluster::params::pool, + $repo = $gluster::params::repo, + String $release = $gluster::params::release, + $server = $gluster::params::install_server, + $server_package = $gluster::params::server_package, + $use_exported_resources = $gluster::params::export_resources, + $version = $gluster::params::version, + Optional $repo_key_source = $gluster::params::repo_key_source, + Optional[Hash] $volumes = undef, + Optional[Integer] $priority = undef, +) inherits gluster::params { + + # if we manage the repository, we also need a GPG key + if $repo { + assert_type(Variant[Stdlib::Absolutepath, Stdlib::HTTPSUrl], $repo_key_source) + } class { 'gluster::install': - server => $server, - server_package => $server_package, - client => $client, - client_package => $client_package, - version => $version, - repo => $repo, + server => $server, + server_package => $server_package, + client => $client, + client_package => $client_package, + version => $version, + repo => $repo, + release => $release, + priority => $priority, + repo_key_source => $repo_key_source, } if $server { diff --git a/manifests/install.pp b/manifests/install.pp index 4d2250b5..e2be7e0a 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -13,6 +13,8 @@ # whether or not to use a repo, or the distribution's default packages # @param version # the Gluster version to install +# @param priority +# The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL # # @example # class { gluster::install: @@ -26,19 +28,27 @@ # @note Copyright 2014 CoverMyMeds, unless otherwise noted # class gluster::install ( - Boolean $server = $gluster::params::install_server, - Boolean $client = $gluster::params::install_client, - Boolean $repo = $gluster::params::repo, - String $version = $gluster::params::version, - String $server_package = $gluster::params::server_package, - String $client_package = $gluster::params::client_package, -) inherits gluster::params { + Boolean $server, + Boolean $client, + Boolean $repo, + String $version, + String $release, + Optional $repo_key_source = undef, + Optional[String[1]] $server_package = undef, + Optional[String[1]] $client_package = undef, + Optional[Integer] $priority = undef, +) { + + assert_private() if $repo { # install the correct repo if ! defined ( Class['::gluster::repo'] ) { class { 'gluster::repo': - version => $version, + version => $version, + release => $release, + priority => $priority, + repo_key_source => $repo_key_source, } } } diff --git a/manifests/params.pp b/manifests/params.pp index 930aa404..a94804a7 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,17 +11,13 @@ $release = '6' $version = 'LATEST' - # we explicitly do NOT set a priority here. The user must define - # a priority in order to ensure that it is activated - $repo_priority = undef - # Set distro/release specific names, repo versions, repo gpg keys, package versions, etc # if the user didn't specify a version, just use "installed" for package version. # if they did specify a version, assume they provided a valid one case $::osfamily { 'RedHat': { - $repo = true - $repo_gpg_key_source = 'https://raw.githubusercontent.com/CentOS-Storage-SIG/centos-release-storage-common/master/RPM-GPG-KEY-CentOS-SIG-Storage' + $repo = true + $repo_key_source = 'https://raw.githubusercontent.com/CentOS-Storage-SIG/centos-release-storage-common/master/RPM-GPG-KEY-CentOS-SIG-Storage' $server_package = $::operatingsystemmajrelease ? { # RHEL 6 and 7 provide Gluster packages natively @@ -36,30 +32,33 @@ $service_name = 'glusterd' } 'Debian': { - $repo = true - $server_package = 'glusterfs-server' - $client_package = 'glusterfs-client' - $service_name = 'glusterd' + $repo = true + $server_package = 'glusterfs-server' + $client_package = 'glusterfs-client' + $service_name = 'glusterd' + $repo_key_source = "https://download.gluster.org/pub/gluster/glusterfs/${release}/rsa.pub" } 'Archlinux': { $repo = false - $server_package = 'glusterfs' - $client_package = 'glusterfs' - $service_name = 'glusterd' + $server_package = 'glusterfs' + $client_package = 'glusterfs' + $service_name = 'glusterd' + $repo_key_source = undef } 'Suse': { $repo = false - $server_package = 'glusterfs' - $client_package = 'glusterfs' - $service_name = 'glusterd' + $server_package = 'glusterfs' + $client_package = 'glusterfs' + $service_name = 'glusterd' + $repo_key_source = undef } default: { $repo = false # these packages are the upstream names - $server_package = 'glusterfs-server' - $client_package = 'glusterfs-fuse' - - $service_name = 'glusterfs-server' + $server_package = 'glusterfs-server' + $client_package = 'glusterfs-fuse' + $repo_key_source = undef + $service_name = 'glusterfs-server' } } diff --git a/manifests/repo.pp b/manifests/repo.pp index 35c07608..dd0f865a 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -7,6 +7,9 @@ # @param version # the version of the upstream repo to enable # +# @param priority +# The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL +# # @example # class { gluster::repo # version => '3.5.2', @@ -16,18 +19,28 @@ # @note Copyright 2014 CoverMyMeds, unless otherwise noted # class gluster::repo ( - $release = $gluster::params::release, - $version = $gluster::params::version, -) inherits gluster::params { + $release, + $version, + Variant[Stdlib::Absolutepath,Stdlib::HTTPSUrl] $repo_key_source, + Optional[Integer] $priority = undef, +) { + + assert_private() + case $::osfamily { 'RedHat': { class { 'gluster::repo::yum': - release => $release, + release => $release, + priority => $priority, + repo_key_source => $repo_key_source, } } 'Debian': { class { 'gluster::repo::apt': - version => $version, + release => $release, + version => $version, + priority => $priority, + repo_key_source => $repo_key_source, } } default: { fail("${::osfamily} not yet supported!") } diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 1e6573cb..4aad09ff 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -3,7 +3,8 @@ # # @param version The version to use when building the repo URL # @param release The release to use when building the repo URL -# @param priority Apt pin priority to set for the Gluster repo +# @param priority +# The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL # # Currently only released versions are supported. If you want to use # QA releases or pre-releases, you'll need to edit line 54 below @@ -24,10 +25,14 @@ # @note Copyright 2015 RL Solutions, unless otherwise noted # class gluster::repo::apt ( - $version = $gluster::version, - String[1] $release = $gluster::release, - $priority = $gluster::repo_priority, + $version, + String[1] $release, + $priority, + Variant[Stdlib::Absolutepath,Stdlib::HTTPSUrl] $repo_key_source, ) { + + assert_private() + include 'apt' $repo_key_name = $release ? { @@ -38,8 +43,6 @@ default => '849512C2CA648EF425048F55C883F50CB2289A17', } - $repo_key_source = "https://download.gluster.org/pub/gluster/glusterfs/${release}/rsa.pub" - # basic sanity check if $version == 'LATEST' { $repo_ver = $version diff --git a/manifests/repo/yum.pp b/manifests/repo/yum.pp index 53b6fb19..82354304 100644 --- a/manifests/repo/yum.pp +++ b/manifests/repo/yum.pp @@ -15,10 +15,12 @@ # @note Copyright 2014 CoverMyMeds, unless otherwise noted # class gluster::repo::yum ( - String $release = $gluster::params::release, - String $repo_key_source = $gluster::params::repo_gpg_key_source, - Optional[String] $priority = $gluster::params::repo_priority, -) inherits gluster::params { + String $release, + Variant[Stdlib::Absolutepath,Stdlib::HTTPSUrl] $repo_key_source, + Optional[Integer] $priority = undef, +) { + + assert_private() # CentOS Gluster repo only supports x86_64 if $::architecture != 'x86_64' { diff --git a/manifests/service.pp b/manifests/service.pp index 02e04341..cbb64257 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -22,6 +22,8 @@ $service_name = $gluster::params::service_name, ) inherits ::gluster::params { + assert_private() + service { $service_name : ensure => $ensure, enable => $enable, diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb deleted file mode 100644 index d8320dd7..00000000 --- a/spec/classes/install_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'spec_helper' - -describe 'gluster::install', type: :class do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - let :pre_condition do - 'require ::gluster::service' - end - - context 'with defaults' do - it { is_expected.to compile.with_all_deps } - case facts[:osfamily] - when 'Redhat' - # rubocop:disable RSpec/RepeatedExample - it { is_expected.to create_package('glusterfs-server') } - it { is_expected.to create_package('glusterfs-fuse') } - it { is_expected.to create_class('gluster::repo').with(version: 'LATEST') } - when 'Debian' - it { is_expected.to create_package('glusterfs-server') } - it { is_expected.to create_package('glusterfs-client') } - it { is_expected.to create_class('gluster::repo').with(version: 'LATEST') } - # rubocop:enable RSpec/RepeatedExample - end - end - context 'when repo is false' do - let :params do - { repo: false } - end - - it { is_expected.not_to create_class('gluster::repo') } - end - context 'when client is false' do - let :params do - { client: false } - end - - case facts[:osfamily] - when 'Redhat' - it { is_expected.not_to create_package('glusterfs-fuse') } - when 'Debian' - it { is_expected.not_to create_package('glusterfs-client') } - end - end - context 'when server is false' do - let :params do - { server: false } - end - - case facts[:osfamily] - when 'Redhat', 'Debian' - it { is_expected.not_to create_package('glusterfs-server') } - end - end - context 'installing on an unsupported architecture' do - let :facts do - super().merge( - architecture: 'zLinux' - ) - end - - case facts[:osfamily] - when 'Archlinux', 'Suse' - it { is_expected.not_to create_class('gluster::repo') } - else - it { is_expected.to raise_error(Puppet::Error, %r{not yet supported}) } - end - end - end - end -end diff --git a/spec/classes/repo_apt_spec.rb b/spec/classes/repo_apt_spec.rb deleted file mode 100644 index 8dd5f369..00000000 --- a/spec/classes/repo_apt_spec.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'spec_helper' - -describe 'gluster::repo::apt', type: :class do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts - end - let :pre_condition do - 'require ::gluster::params' - end - - case facts[:osfamily] - when 'Debian' - context 'with all defaults' do - it { is_expected.to contain_class('gluster::repo::apt') } - it { is_expected.to compile.with_all_deps } - it 'installs' do - is_expected.to contain_apt__source('glusterfs-LATEST').with( - repos: 'main', - location: "https://download.gluster.org/pub/gluster/glusterfs/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/" - ) - end - end - context 'unsupported architecture' do - let :facts do - super().merge( - architecture: 'zLinux' - ) - end - - it 'does not install' do - expect do - is_expected.to create_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-gluster.pub') - end.to raise_error(Puppet::Error, %r{not yet supported}) - end - end - context 'latest Gluster with priority' do - let :params do - { - priority: '700' - } - end - - it 'installs' do - is_expected.to contain_apt__source('glusterfs-LATEST').with( - repos: 'main', - location: "https://download.gluster.org/pub/gluster/glusterfs/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/", - pin: '700' - ) - end - end - - context 'Specific Gluster release 4.1' do - let :params do - { - release: '4.1' - } - end - - it 'installs' do - is_expected.to contain_apt__source('glusterfs-LATEST').with( - repos: 'main', - key: { - 'id' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97', - 'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/4.1/rsa.pub' - }, - location: "https://download.gluster.org/pub/gluster/glusterfs/4.1/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/" - ) - end - end - - context 'Specific Gluster release 3.12' do - let :params do - { - release: '3.12' - } - end - - it 'installs' do - is_expected.to contain_apt__source('glusterfs-LATEST').with( - repos: 'main', - key: { - 'id' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4', - 'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub' - }, - location: "https://download.gluster.org/pub/gluster/glusterfs/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/" - ) - end - end - end - end - end -end diff --git a/spec/classes/repo_yum_spec.rb b/spec/classes/repo_yum_spec.rb deleted file mode 100644 index 86ae32cd..00000000 --- a/spec/classes/repo_yum_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'spec_helper' - -describe 'gluster::repo::yum', type: :class do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts - end - - case facts[:osfamily] - when 'Redhat' - context 'with all defaults' do - it { is_expected.to contain_class('gluster::repo::yum') } - it { is_expected.to compile.with_all_deps } - it 'installs' do - is_expected.not_to create_package('yum-plugin-priorities') - is_expected.to create_yumrepo('glusterfs-x86_64').with( - enabled: 1, - baseurl: "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}/storage/#{facts[:architecture]}/gluster-3.8/", - gpgcheck: 1, - gpgkey: "http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-#{facts[:operatingsystemmajrelease]}" - ) - end - end - context 'bogus version' do - let :params do - { - version: 'foobar' - } - end - - it 'does not install' do - expect do - is_expected.to create_file('/etc/yum.repos.d/glusterfs-x86_64.repo') - end.to raise_error(Puppet::Error, %r{doesn't make sense!}) - end - end - context 'unsupported architecture' do - let :facts do - super().merge( - architecture: 'zLinux' - ) - end - - it 'does not install' do - expect do - is_expected.to create_file('/etc/yum.repos.d/glusterfs-x86_64.repo') - end.to raise_error(Puppet::Error, %r{not yet supported}) - end - end - context 'latest Gluster with priority' do - let :params do - { - priority: '50' - } - end - - it 'installs' do - is_expected.to create_package('yum-plugin-priorities') - is_expected.to create_yumrepo('glusterfs-x86_64').with( - enabled: 1, - baseurl: "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}/storage/#{facts[:architecture]}/gluster-3.8/", - gpgcheck: 1, - gpgkey: "http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-#{facts[:operatingsystemmajrelease]}", - priority: '50' - ) - end - end - end - end - end -end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb deleted file mode 100644 index e00e69e5..00000000 --- a/spec/classes/service_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'gluster::service', type: :class do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts - end - - context 'with all defaults' do - it { is_expected.to compile.with_all_deps } - it 'starts the service' do - case facts[:osfamily] - when 'Redhat' - is_expected.to create_service('glusterd') - when 'Debian' - is_expected.to create_service('glusterd') - when 'Archlinux' - is_expected.to create_service('glusterd') - end - end - end - end - end -end From cc72b2c365b67a51e139b17cfb7ab23420426d51 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 20 Oct 2019 18:55:57 +0200 Subject: [PATCH 11/11] generate REFERENCE.md --- REFERENCE.md | 565 ++++++++++++++++++++++++++++++++++++++++++ manifests/client.pp | 2 + manifests/init.pp | 2 +- manifests/install.pp | 2 + manifests/repo.pp | 3 + manifests/repo/apt.pp | 2 + manifests/repo/yum.pp | 2 + 7 files changed, 577 insertions(+), 1 deletion(-) create mode 100644 REFERENCE.md diff --git a/REFERENCE.md b/REFERENCE.md new file mode 100644 index 00000000..02917555 --- /dev/null +++ b/REFERENCE.md @@ -0,0 +1,565 @@ +# Reference + + +## Table of Contents + +**Classes** + +_Public Classes_ + +* [`gluster`](#gluster): Installs GlusterFS and optionally creates a trusted storage pool +* [`gluster::client`](#glusterclient): Ensure that the Gluster FUSE client package is installed + +_Private Classes_ + +* `gluster::install`: install the Gluster packages +* `gluster::params`: establishes various defaults for use in other gluster manifests +* `gluster::repo`: enables an upstream GlusterFS repository +* `gluster::repo::apt`: enable the upstream Gluster Apt repo +* `gluster::repo::yum`: enable the upstream Gluster Yum repo +* `gluster::service`: manage the glusterd service + +**Defined types** + +* [`gluster::mount`](#glustermount): Mounts a Gluster volume +* [`gluster::peer`](#glusterpeer): Connects to a Gluster peer. +* [`gluster::volume`](#glustervolume): Create GlusterFS volumes, and maybe extend them +* [`gluster::volume::option`](#glustervolumeoption): set or remove a Gluster volume option + +## Classes + +### gluster + +Installs GlusterFS and optionally creates a trusted storage pool + +* **Note** Copyright 2014 CoverMyMeds, unless otherwise noted + +#### Examples + +##### + +```puppet +class { ::gluster: + client => false, + server => true, + pool => 'production', + use_exported_resources => true, + version => '3.5', + volumes => { 'data1' => { + replica => 2, + bricks => [ 'srv1.local:/export/brick1/brick', + 'srv2.local:/export/brick1/brick', + 'srv3.local:/export/brick1/brick', + 'srv4.local:/export/brick1/brick', ], + options => [ 'server.allow-insecure: on', + 'nfs.disable: true', ], + }, + }, +} +``` + +#### Parameters + +The following parameters are available in the `gluster` class. + +##### `client` + +Data type: `Boolean` + +whether to install the Gluster client package(s) + +Default value: $gluster::params::install_client + +##### `pool` + +Data type: `Any` + +the name of the trusted storage pool to create + +Default value: $gluster::params::pool + +##### `repo` + +Data type: `Any` + +whether to install and manage the upstream Gluster repo + +Default value: $gluster::params::repo + +##### `server` + +Data type: `Any` + +whether to the install the Gluster server packages + +Default value: $gluster::params::install_server + +##### `use_exported_resources` + +Data type: `Any` + +whether or not to export this server's gluster::server and collect other +gluster::server resources + +Default value: $gluster::params::export_resources + +##### `version` + +Data type: `Any` + +the version to install + +Default value: $gluster::params::version + +##### `volumes` + +Data type: `Optional[Hash]` + +optional list of volumes (and their properties) to create + +Default value: `undef` + +##### `priority` + +Data type: `Optional[Integer]` + +The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL + +Default value: `undef` + +##### `repo_key_source` + +Data type: `Optional` + +HTTP Link or absolute path to the GPG key for the repository. + +Default value: $gluster::params::repo_key_source + +##### `client_package` + +Data type: `Any` + + + +Default value: $gluster::params::client_package + +##### `release` + +Data type: `String` + + + +Default value: $gluster::params::release + +##### `server_package` + +Data type: `Any` + + + +Default value: $gluster::params::server_package + +### gluster::client + +Ensure that the Gluster FUSE client package is installed + +* **Note** This is a convenience class to ensure that *just* the client +is installed. If you need both client and server, please use +the main gluster class + +#### Examples + +##### + +```puppet +class { gluster::client: + repo => true, + client_package => 'glusterfs-fuse', + version => 'LATEST', +} +``` + +#### Parameters + +The following parameters are available in the `gluster::client` class. + +##### `repo` + +Data type: `Boolean` + +Whether to use the GlusterFS repository + +Default value: $gluster::params::repo + +##### `client_package` + +Data type: `String` + +The name of the client package to install. + +Default value: $gluster::params::client_package + +##### `version` + +Data type: `String` + +The version of the client tools to install. + +Default value: $gluster::params::version + +##### `repo_key_source` + +Data type: `Optional` + +HTTP Link or absolute path to the GPG key for the repository. + +Default value: $gluster::params::repo_key_source + +##### `release` + +Data type: `String` + + + +Default value: $gluster::params::release + +## Defined types + +### gluster::mount + +Mounts a Gluster volume + +* **Note** Copyright 2014 CoverMyMeds, unless otherwise noted + +#### Examples + +##### + +```puppet +gluster::mount { 'data1': + ensure => present, + volume => 'srv1.local:/data1', + transport => 'tcp', + atboot => true, + dump => 0, + pass => 0, +} +``` + +#### Parameters + +The following parameters are available in the `gluster::mount` defined type. + +##### `volume` + +Data type: `String` + +the volume to mount, in "server:/volname" format + +##### `log_level` + +Data type: `Optional[String]` + +the GlusterFS log level to use + +Default value: `undef` + +##### `log_file` + +Data type: `Optional[String]` + +the file to which to log this volume + +Default value: `undef` + +##### `transport` + +Data type: `Optional[String]` + +TCP or RDMA + +Default value: `undef` + +##### `direct_io_mode` + +Data type: `Optional[String]` + +whether or not to use direct io mode + +Default value: `undef` + +##### `readdirp` + +Data type: `Optional[Boolean]` + +whether or not to use readdirp + +Default value: `undef` + +##### `atboot` + +Data type: `Variant[Enum['yes', 'no'], Boolean]` + +whether to add this volume to /etc/fstab + +Default value: 'yes' + +##### `options` + +Data type: `String` + +a comma-separated list of GlusterFS mount options + +Default value: 'defaults' + +##### `dump` + +Data type: `Integer` + +enable or disable dump in /etc/fstab + +Default value: 0 + +##### `pass` + +Data type: `Integer` + +the sequence value for fsck for this volume in /etc/fstab + +Default value: 0 + +##### `ensure` + +Data type: `Enum['defined', 'present', 'unmounted', 'absent', 'mounted']` + +the state to ensure + +Default value: 'mounted' + +### gluster::peer + +Connects to a Gluster peer. Intended to be exported by each member of +a Gluster Trusted Storage Pool. Each server should also collect all +such exported resources for local realization. + +If the title of the exported resource is NOT the FQDN of the host +on which the resource is being realized, then try to initiate a +Gluster peering relationship. + +* **Note** Copyright 2014 CoverMyMeds, unless otherwise notes + +* **See also** +http://www.gluster.org/pipermail/gluster-users/2013-December/038354.html +When server-a probes server-b, server-b will only record the IP address +for server-a. When server-b next runs Puppet, it will probe server-a +because server-a's fqdn is not in the list of peers. The peering will +have been successfully established the first time, so this second +peering attempt only resolves a cosmetic issue, not a functional one. + +#### Examples + +##### Export this host's gluster::peer resource, and then collect all others: + +```puppet +@@gluster::peer { $::fqdn: + pool => 'production', +} +Gluster::Peer <<| pool == 'production' |>> +``` + +##### explicitly define peers: + +```puppet +gluster::peer { 'gluster1.example.com': + pool => 'pool1', +} +``` + +#### Parameters + +The following parameters are available in the `gluster::peer` defined type. + +##### `pool` + +Data type: `Any` + +the name of the storage pool to which this server should be assigned. + +Default value: 'default' + +##### `fqdn` + +Data type: `Any` + +the name of this peer to use in the pool + +Default value: $::fqdn + +### gluster::volume + +Create GlusterFS volumes, and maybe extend them + +* **Note** Copyright 2014 CoverMyMeds, unless otherwise noted + +* **See also** +https://github.com/gluster/glusterfs/blob/master/doc/admin-guide/en-US/markdown/admin_managing_volumes.md#tuning-options + +#### Examples + +##### + +```puppet +gluster::volume { 'storage1': + replica => 2, + bricks => [ + 'srv1.local:/export/brick1/brick', + 'srv2.local:/export/brick1/brick', + 'srv1.local:/export/brick2/brick', + 'srv2.local:/export/brick2/brick', + ], + options => [ + 'server.allow-insecure: on', + 'nfs.ports-insecure: on', + ], +} +``` + +#### Parameters + +The following parameters are available in the `gluster::volume` defined type. + +##### `stripe` + +Data type: `Optional[Integer]` + +the stripe count to use for a striped volume + +Default value: `undef` + +##### `replica` + +Data type: `Optional[Integer]` + +the replica count to use for a replica volume + +Default value: `undef` + +##### `arbiter` + +Data type: `Optional[Integer]` + +the arbiter count to use for a replica volume + +Default value: `undef` + +##### `transport` + +Data type: `Enum['tcp', 'rdma', 'tcp,rdma']` + +the transport to use. Defaults to tcp + +Default value: 'tcp' + +##### `rebalance` + +Data type: `Boolean` + +whether to rebalance a volume when new bricks are added + +Default value: `true` + +##### `heal` + +Data type: `Boolean` + +whether to heal a replica volume when adding bricks + +Default value: `true` + +##### `bricks` + +Data type: `Array[String, 1]` + +an array of bricks to use for this volume + +##### `options` + +Data type: `Array[String[1]]` + +an array of volume options for the volume + +Default value: [] + +##### `remove_options` + +Data type: `Boolean` + +whether to permit the removal of active options that are not defined for +this volume. + +Default value: `false` + +##### `force` + +Data type: `Boolean` + + + +Default value: `false` + +### gluster::volume::option + +set or remove a Gluster volume option + +* **Note** Copyright 2014 CoverMyMeds, unless otherwise noted + +#### Examples + +##### + +```puppet +gluster::volume::option { 'gv0:nfs.disable': + value => 'on', +} +``` + +##### + +```puppet +gluster::volume::option { 'gv0:server.allow-insecure': + value => 'on', +} +``` + +##### To remove a previously-set option: + +```puppet +gluster::volume::option { 'gv0:feature.read-only': + ensure => absent, +} +``` + +#### Parameters + +The following parameters are available in the `gluster::volume::option` defined type. + +##### `title` + +the name of the volume, a colon, and the name of the option + +##### `value` + +Data type: `Any` + +the value to set for this option + +Default value: `undef` + +##### `ensure` + +Data type: `Enum['present', 'absent']` + +whether to set or remove an option + +Default value: 'present' + diff --git a/manifests/client.pp b/manifests/client.pp index 40cdbcce..a59b8d15 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -10,6 +10,8 @@ # The name of the client package to install. # @param version # The version of the client tools to install. +# @param repo_key_source +# HTTP Link or absolute path to the GPG key for the repository. # # @example # class { gluster::client: diff --git a/manifests/init.pp b/manifests/init.pp index 861e83aa..0c5964ab 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -18,7 +18,7 @@ # @param priority # The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL # @param repo_key_source -# Link/path to the GPG key for the repository. Currently only used at RedHat based platforms +# HTTP Link or absolute path to the GPG key for the repository. # @example # class { ::gluster: # client => false, diff --git a/manifests/install.pp b/manifests/install.pp index e2be7e0a..ec5fa2ec 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -15,6 +15,8 @@ # the Gluster version to install # @param priority # The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL +# @param repo_key_source +# HTTP Link or absolute path to the GPG key for the repository. # # @example # class { gluster::install: diff --git a/manifests/repo.pp b/manifests/repo.pp index dd0f865a..07e67806 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -10,6 +10,9 @@ # @param priority # The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL # +# @param repo_key_source +# HTTP Link or absolute path to the GPG key for the repository. +# # @example # class { gluster::repo # version => '3.5.2', diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 4aad09ff..8b492361 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -5,6 +5,8 @@ # @param release The release to use when building the repo URL # @param priority # The priority for the apt/yum repository. Useful to overwrite other repositories like EPEL +# @param repo_key_source +# HTTP Link or absolute path to the GPG key for the repository. # # Currently only released versions are supported. If you want to use # QA releases or pre-releases, you'll need to edit line 54 below diff --git a/manifests/repo/yum.pp b/manifests/repo/yum.pp index 82354304..14381e44 100644 --- a/manifests/repo/yum.pp +++ b/manifests/repo/yum.pp @@ -7,6 +7,8 @@ # where to find this repo's GPG key # @param priority # YUM priority to set for the Gluster repo +# @param repo_key_source +# HTTP Link or absolute path to the GPG key for the repository. # # @note Currently only released versions are supported. If you want to use # QA releases or pre-releases, you'll need to edit line 47