Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix puppet-lint warnings / switch to facts hash / drop legacy gluster versions 4.0 and older #203

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
565 changes: 565 additions & 0 deletions REFERENCE.md

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,17 +23,27 @@
# @author Scott Merrill <[email protected]>
# @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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering about this pattern. It's hard to discover from reading the reference. Should the parameter be Optional[Variant[Stdlib::Absolutepath, Stdlib::HTTPSUrl]]? In that case maybe this could be simplified to assert_type(NotUndef, $repo_key_source).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the resource ordering, but I think this is redundant code. The value of $repo and $repo_key_source is already defined at manifests/params.pp and we check the type at manifests/repo.pp.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's redundant because manifests/repo.pp already checks it. That's a better approach than duplicating it here.

}

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,
}
}
49 changes: 31 additions & 18 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
# HTTP Link or absolute path to the GPG key for the repository.
# @example
# class { ::gluster:
# client => false,
Expand All @@ -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,
$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 {
Expand Down
28 changes: 20 additions & 8 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# 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
# @param repo_key_source
# HTTP Link or absolute path to the GPG key for the repository.
#
# @example
# class { gluster::install:
Expand All @@ -26,19 +30,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,
}
}
}
Expand Down
41 changes: 20 additions & 21 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@
# 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
# 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
Expand All @@ -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'
}
}

Expand Down
26 changes: 21 additions & 5 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
# @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
#
# @param repo_key_source
# HTTP Link or absolute path to the GPG key for the repository.
#
# @example
# class { gluster::repo
# version => '3.5.2',
Expand All @@ -16,18 +22,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!") }
Expand Down
47 changes: 20 additions & 27 deletions manifests/repo/apt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#
# @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
# @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
Expand All @@ -24,25 +27,24 @@
# @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,
String[1] $release,
$priority,
Variant[Stdlib::Absolutepath,Stdlib::HTTPSUrl] $repo_key_source,
) {

assert_private()

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'^5\.(\d)+$' => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C',
default => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C',

/^6/ => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C',
/^7/ => 'F9C958A3AEE0D2184FAD1CBD43607F0DC2F8238C',
default => '849512C2CA648EF425048F55C883F50CB2289A17',
}

$repo_key_source = "https://download.gluster.org/pub/gluster/glusterfs/${release}/rsa.pub"

# basic sanity check
if $version == 'LATEST' {
$repo_ver = $version
Expand All @@ -55,36 +57,27 @@
}

# 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,
}
$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')
}
}
if ! $arch {
fail("Architecture ${::architecture} not yet supported for ${::operatingsystem}.")
fail("Architecture ${facts['architecture']} not yet supported for ${facts['operatingsystem']}.")
}

$repo = {
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
"glusterfs-${version}" => {
ensure => present,
location => $repo_url,
release => $::lsbdistcodename,
repos => 'main',
key => {
id => $repo_key_name,
Expand Down
12 changes: 8 additions & 4 deletions manifests/repo/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,10 +17,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' {
Expand Down
Loading