diff --git a/.fixtures.yml b/.fixtures.yml index a36b92b3..be5d81c9 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,15 +9,12 @@ fixtures: apt: "puppetlabs/apt" epel: "stahnma/epel" concat: "puppetlabs/concat" - wget: "puppet/wget" sudo: "saz/sudo" python: "puppet/python" - gcc: "puppetlabs/gcc" inifile: "puppetlabs/inifile" mongodb: "puppet/mongodb" postgresql: "puppetlabs/postgresql" rabbitmq: "puppet/rabbitmq" - packagecloud: "computology/packagecloud" selinux: "puppet/selinux" nginx: "puppet/nginx" nodejs: "puppet/nodejs" diff --git a/CHANGELOG.md b/CHANGELOG.md index 58f7be44..a4cd0b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## Development +- Refactored the system StackStorm repository handling. This replaces the `PackageCloud` + Puppet module because it was _not_ idempotent. At the same time we've moved the repository + handling from the old-school `st2::profile::repos` to the new idiomatic + `st2::repo` (base) and `st2::repo::apt` or `st2::repo::yum` based on OS type. + This is considered a minor breaking change if you were using the internal class + `st2::profile::repos`. The replacement class is `st2::repo` and is a direct replacement. (Enhancement) + Contributed by @nmaludy + - Fixed `/opt/stackstorm/packs` and `/opt/stackstorm/virtualenv` resources to be idempotent and manage the ownership of these directories recursively in a much more efficient manner. Instead of using the `file` resource with `recurse => true` we now utilize the module diff --git a/build/centos6-puppet5/Puppetfile b/build/centos6-puppet5/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/centos6-puppet5/Puppetfile +++ b/build/centos6-puppet5/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/centos6-puppet6/Puppetfile b/build/centos6-puppet6/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/centos6-puppet6/Puppetfile +++ b/build/centos6-puppet6/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/centos7-puppet5/Puppetfile b/build/centos7-puppet5/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/centos7-puppet5/Puppetfile +++ b/build/centos7-puppet5/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/centos7-puppet6/Puppetfile b/build/centos7-puppet6/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/centos7-puppet6/Puppetfile +++ b/build/centos7-puppet6/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/ubuntu14-puppet5/Puppetfile b/build/ubuntu14-puppet5/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/ubuntu14-puppet5/Puppetfile +++ b/build/ubuntu14-puppet5/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/ubuntu14-puppet6/Puppetfile b/build/ubuntu14-puppet6/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/ubuntu14-puppet6/Puppetfile +++ b/build/ubuntu14-puppet6/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/ubuntu16-puppet5/Puppetfile b/build/ubuntu16-puppet5/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/ubuntu16-puppet5/Puppetfile +++ b/build/ubuntu16-puppet5/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/ubuntu16-puppet6/Puppetfile b/build/ubuntu16-puppet6/Puppetfile index 01c7bb79..2dbedf4b 100644 --- a/build/ubuntu16-puppet6/Puppetfile +++ b/build/ubuntu16-puppet6/Puppetfile @@ -37,7 +37,6 @@ # │ ├── puppet-archive (v3.2.1) # │ └── camptocamp-systemd (v2.3.0) # ├── ghoneycutt-facter (v3.5.0) -# ├── computology-packagecloud (v0.3.2) # ├── puppet-selinux (v1.6.1) # ├── puppet-nginx (v0.16.0) # └── puppet-nodejs (v7.0.0) @@ -58,7 +57,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/ubuntu18-puppet5/Puppetfile b/build/ubuntu18-puppet5/Puppetfile index 621c9f49..37665e11 100644 --- a/build/ubuntu18-puppet5/Puppetfile +++ b/build/ubuntu18-puppet5/Puppetfile @@ -26,7 +26,6 @@ # ├── puppetlabs-stdlib (v5.2.0) # ├─┬ puppetlabs-apt (v6.3.0) # │ └── puppetlabs-translate (v1.2.0) -# ├── puppet-wget (v2.0.1) # ├── saz-sudo (v6.0.0) # ├─┬ puppet-python (v2.2.2) # │ └── stahnma-epel (v1.3.1) @@ -48,7 +47,6 @@ mod 'jamtur01-httpauth' mod 'puppetlabs-apt' mod 'stahnma-epel' mod 'puppetlabs-translate' # dependency of puppetlabs-apt -mod 'puppet-wget' mod 'saz-sudo' mod 'puppet-python' mod 'puppet-mongodb' @@ -58,7 +56,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/build/ubuntu18-puppet6/Puppetfile b/build/ubuntu18-puppet6/Puppetfile index 621c9f49..37665e11 100644 --- a/build/ubuntu18-puppet6/Puppetfile +++ b/build/ubuntu18-puppet6/Puppetfile @@ -26,7 +26,6 @@ # ├── puppetlabs-stdlib (v5.2.0) # ├─┬ puppetlabs-apt (v6.3.0) # │ └── puppetlabs-translate (v1.2.0) -# ├── puppet-wget (v2.0.1) # ├── saz-sudo (v6.0.0) # ├─┬ puppet-python (v2.2.2) # │ └── stahnma-epel (v1.3.1) @@ -48,7 +47,6 @@ mod 'jamtur01-httpauth' mod 'puppetlabs-apt' mod 'stahnma-epel' mod 'puppetlabs-translate' # dependency of puppetlabs-apt -mod 'puppet-wget' mod 'saz-sudo' mod 'puppet-python' mod 'puppet-mongodb' @@ -58,7 +56,6 @@ mod 'puppet-rabbitmq' mod 'puppet-archive' # dependency of puppet-rabbitmq mod 'camptocamp-systemd' # dependency of puppet-rabbitmq mod 'ghoneycutt-facter' -mod 'computology-packagecloud' mod 'puppet-selinux' mod 'puppet-nginx' mod 'puppet-nodejs' diff --git a/manifests/init.pp b/manifests/init.pp index 055005f3..1586c8ed 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,7 +4,7 @@ # Version of StackStorm package to install (default = 'present') # See the package 'ensure' property: # https://puppet.com/docs/puppet/5.5/types/package.html#package-attribute-ensure -# @param repository +# @param [St2::Repository] repository # Release repository to enable. 'stable', 'unstable' # (default = 'stable') # @param conf_dir @@ -223,7 +223,7 @@ # class st2( $version = 'present', - $repository = $::st2::params::repository, + St2::Repository $repository = $::st2::params::repository, $conf_dir = $::st2::params::conf_dir, $conf_file = "${::st2::params::conf_dir}/st2.conf", $use_ssl = $::st2::params::use_ssl, diff --git a/manifests/profile/fullinstall.pp b/manifests/profile/fullinstall.pp index 5aead41d..44c596a2 100644 --- a/manifests/profile/fullinstall.pp +++ b/manifests/profile/fullinstall.pp @@ -31,7 +31,7 @@ Anchor['st2::begin'] -> Anchor['st2::bootstrap'] -> class { 'st2::profile::facter': } - -> class { 'st2::profile::repos': } + -> class { 'st2::repo': } -> class { 'st2::profile::selinux': } -> Anchor['st2::pre_reqs'] -> class { 'st2::profile::nodejs': } diff --git a/manifests/profile/repos.pp b/manifests/profile/repos.pp deleted file mode 100644 index 05fa2ef0..00000000 --- a/manifests/profile/repos.pp +++ /dev/null @@ -1,41 +0,0 @@ -# @summary Manages the installation of st2 required repos for installing the StackStorm packages. -# -# @example Basic usage -# include st2::profile::repos -# -# @example Installing from unstable -# class { 'st2::profile::repos': -# repository => 'unstable', -# } -# -# @param repository -# Release repository to enable. Options: 'stable', 'unstable'. -# @param package_type -# Type of package management system used for repo. Options: 'rpm', 'deb' -# -class st2::profile::repos( - $repository = $::st2::repository, - $package_type = $::st2::params::package_type, -) inherits st2 { - require packagecloud - - if $::osfamily == 'RedHat' { - require epel - } - $_packagecloud_repo = "StackStorm/${repository}" - packagecloud::repo { $_packagecloud_repo: - type => $package_type, - } - - # On ubuntu 14, the packagecloud repo addition corrupts the apt-cache... - # this cleans it out and refreshes it - if ($::osfamily == 'Debian' and - versioncmp($::operatingsystemmajrelease, '14.04') == 0) { - exec { 'Refresh apt-cache after packagecloud': - command => 'rm -rf /var/lib/apt/lists/*; apt-get update', - path => ['/usr/bin/', '/bin/'], - refreshonly => true, - subscribe => Packagecloud::Repo[$_packagecloud_repo], - } - } -} diff --git a/manifests/repo.pp b/manifests/repo.pp new file mode 100644 index 00000000..90c0c85a --- /dev/null +++ b/manifests/repo.pp @@ -0,0 +1,57 @@ +# @summary Manages the installation of st2 required repos for installing the StackStorm packages. +# +# @example Basic usage +# include st2::repo +# +# @example Installing from unstable +# class { 'st2::repo': +# repository => 'unstable', +# } +# +# @param [Enum['present', 'absent']] ensure +# The basic state the repo should be in +# +# @param [St2::Repository] repository +# Release repository to enable +# +class st2::repo ( + Enum['present', 'absent'] $ensure = 'present', + St2::Repository $repository = 'stable', +) { + case $facts['os']['family'] { + 'RedHat': { + # RedHat distros need EPEL + require epel + + $dist_version = $facts['os']['release']['major'] + $baseurl = "https://packagecloud.io/StackStorm/${repository}/el/${dist_version}/\$basearch" + $gpgkey = "https://packagecloud.io/StackStorm/${repository}/gpgkey" + + contain st2::repo::yum + } + + 'Debian': { + # debian, ubuntu, etc + $osname = downcase($facts['os']['name']) + # trusty, xenial, bionic, etc + $release = downcase($facts['os']['distro']['codename']) + $location = "https://packagecloud.io/StackStorm/${repository}/${osname}" + $repos = 'main' + + $key_id = $repository ? { + 'stable' => '3CE01873543A4CCE', + 'staging-stable' => '527B93CA96ADF311', + 'staging-unstable' => '9A2236A8CEC0C6A8', + 'unstable' => '1CDF3CE710B2CCF3', + default => '3CE01873543A4CCE', # stable + } + $key_source = "https://packagecloud.io/StackStorm/${repository}/gpgkey" + + contain st2::repo::apt + } + + default: { + fail("Unsupported managed repository for osfamily: ${facts['os']['family']}, operatingsystem: ${facts['os']['name']}") + } + } +} diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp new file mode 100644 index 00000000..911d732f --- /dev/null +++ b/manifests/repo/apt.pp @@ -0,0 +1,22 @@ +# Apt repo for StackStorm +class st2::repo::apt { + if $st2::repo::ensure == 'present' { + apt::source { "StackStorm_${st2::repo::repository}": + location => $st2::repo::location, + release => $st2::repo::release, + repos => $st2::repo::repos, + key => { + 'id' => $st2::repo::key_id, + 'source' => $st2::repo::key_source, + }, + } + + Apt::Source["StackStorm_${st2::repo::repository}"] + -> Package<| tag == 'st2::server::packages' |> + } + else { + apt::source { "StackStorm_${st2::repo::repository}": + ensure => absent, + } + } +} diff --git a/manifests/repo/yum.pp b/manifests/repo/yum.pp new file mode 100644 index 00000000..d39fef88 --- /dev/null +++ b/manifests/repo/yum.pp @@ -0,0 +1,20 @@ +# Yum repo for StackStorm +class st2::repo::yum { + if $st2::repo::ensure == 'present' { + yumrepo { "StackStorm_${st2::repo::repository}": + baseurl => $st2::repo::baseurl, + enabled => '1', + gpgcheck => '0', + repo_gpgcheck => '1', + gpgkey => $st2::repo::gpgkey, + } + + Yumrepo["StackStorm_${st2::repo::repository}"] + -> Package<| tag == 'st2::server::packages' |> + } + else { + yumrepo { "StackStorm_${st2::repo::repository}": + ensure => absent, + } + } +} diff --git a/metadata.json b/metadata.json index 5cd42592..c3b0fc15 100644 --- a/metadata.json +++ b/metadata.json @@ -52,10 +52,6 @@ "name": "ghoneycutt/facter", "version_requirement": ">= 3.0.0 < 4.0.0" }, - { - "name": "computology/packagecloud", - "version_requirement": ">= 0.3.1 < 1.0.0" - }, { "name": "puppet/selinux", "version_requirement": ">= 0.5.0 < 4.0.0" diff --git a/types/repository.pp b/types/repository.pp new file mode 100644 index 00000000..ca155b03 --- /dev/null +++ b/types/repository.pp @@ -0,0 +1,2 @@ +# Validate the type of system package repository for StackStorm +type St2::Repository = Enum['stable', 'unstable', 'staging-stable', 'staging-unstable']