From 2a60291bc26794307e6fa50225117e4ad3f28232 Mon Sep 17 00:00:00 2001 From: Nick Maludy Date: Wed, 12 Feb 2020 15:54:32 -0500 Subject: [PATCH 1/2] Initial work on litmus integration testing --- .fixtures.yml | 7 ++++++- .gitignore | 1 + .sync.yml | 6 ++++++ Gemfile | 10 ++++++---- Rakefile | 2 ++ build/scripts/ci_litmus.sh | 11 +++++++++++ build/scripts/ci_litmus_clean.sh | 6 ++++++ build/scripts/install_puppet.sh | 2 +- metadata.json | 8 ++++---- provision.yaml | 14 ++++++++++++++ spec/acceptance/01_apply_spec.rb | 15 +++++++++++++++ spec/spec_helper.rb | 2 ++ spec/spec_helper_acceptance.rb | 6 ++++++ 13 files changed, 80 insertions(+), 10 deletions(-) create mode 100755 build/scripts/ci_litmus.sh create mode 100755 build/scripts/ci_litmus_clean.sh create mode 100644 provision.yaml create mode 100644 spec/acceptance/01_apply_spec.rb create mode 100644 spec/spec_helper_acceptance.rb diff --git a/.fixtures.yml b/.fixtures.yml index 576564a3..1401072f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,7 +9,6 @@ fixtures: apt: "puppetlabs/apt" epel: "stahnma/epel" concat: "puppetlabs/concat" - wget: "puppet/wget" sudo: "saz/sudo" python: "puppet/python" gcc: "puppetlabs/gcc" @@ -21,3 +20,9 @@ fixtures: selinux: "puppet/selinux" nginx: "puppet/nginx" nodejs: "puppet/nodejs" + repositories: + # needed for Litmus + # https://github.com/puppetlabs/puppet_litmus/wiki/Converting-a-module-to-use-Litmus + facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' + puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' + provision: 'https://github.com/puppetlabs/provision.git' diff --git a/.gitignore b/.gitignore index fc9b866b..47580cd6 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ .coverage .librarian .kitchen +.r10k .tmp .bundle /cover/ diff --git a/.sync.yml b/.sync.yml index b6667b61..91151382 100644 --- a/.sync.yml +++ b/.sync.yml @@ -4,6 +4,7 @@ - .coverage - .librarian - .kitchen + - .r10k - .tmp - .bundle - /cover/ @@ -25,6 +26,11 @@ appveyor.yml: Gemfile: required: ':development': + # needed for ed25519 support + - gem: 'bcrypt_pbkdf' + version: '>= 1.0.0' + - gem: 'ed25519' + version: '>= 1.2.0' - gem: 'puppet-lint-absolute_classname-check' # pin to 2.0.0 to comply with new standard which removes the leading :: version: '>= 2.0.0' diff --git a/Gemfile b/Gemfile index aecc7e89..206ec511 100644 --- a/Gemfile +++ b/Gemfile @@ -24,10 +24,12 @@ group :development do gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "bcrypt_pbkdf", '>= 1.0.0', require: false + gem "ed25519", '>= 1.2.0', require: false gem "puppet-lint-absolute_classname-check", '>= 2.0.0', require: false gem "puppet-lint-absolute_template_path", '>= 1.0.1', require: false gem "puppet-lint-alias-check", '>= 0.1.1', require: false diff --git a/Rakefile b/Rakefile index 395df547..cb7ed0cc 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' diff --git a/build/scripts/ci_litmus.sh b/build/scripts/ci_litmus.sh new file mode 100755 index 00000000..9012f37a --- /dev/null +++ b/build/scripts/ci_litmus.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +set -o xtrace + +TEST_NAME=docker_centos7 +PUPPET_COLLECTION=puppet5 +bundle exec rake "litmus:provision_list[$TEST_NAME]" +bundle exec bolt command run 'yum -y install wget' --inventoryfile inventory.yaml --targets='localhost*' +bundle exec rake "litmus:install_agent[$PUPPET_COLLECTION]" +bundle exec rake "litmus:install_module" +bundle exec rake "litmus:acceptance:parallel" diff --git a/build/scripts/ci_litmus_clean.sh b/build/scripts/ci_litmus_clean.sh new file mode 100755 index 00000000..27846b99 --- /dev/null +++ b/build/scripts/ci_litmus_clean.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +set -o xtrace + +# Tear down all targets in inventory.yml +bundle exec rake "litmus:tear_down" diff --git a/build/scripts/install_puppet.sh b/build/scripts/install_puppet.sh index e3c4a8cc..147204de 100755 --- a/build/scripts/install_puppet.sh +++ b/build/scripts/install_puppet.sh @@ -10,7 +10,7 @@ sudo /opt/puppetlabs/puppet/bin/gem install librarian-puppet sudo yum -y install git # Install puppet module dependencies -sudo -i bash -c "pushd /vagrant/build/centos7-puppet6 && /opt/puppetlabs/puppet/bin/librarian-puppet install --verbose --path=/etc/puppetlabs/code/modules" +sudo -i bash -c "pushd /vagrant/build/ubuntu18-puppet6 && /opt/puppetlabs/puppet/bin/librarian-puppet install --verbose --path=/etc/puppetlabs/code/modules" # Create symlink for the st2/ puppet module in the Pupept code directory. # This allows us to make changes locally, outside of the VM then automatically available diff --git a/metadata.json b/metadata.json index 806e4b69..f13254bb 100644 --- a/metadata.json +++ b/metadata.json @@ -42,7 +42,7 @@ }, { "name": "puppet/mongodb", - "version_requirement": ">= 0.14.0" + "version_requirement": ">= 3.1.0" }, { "name": "puppetlabs/postgresql", @@ -95,7 +95,7 @@ "version_requirement": ">= 4.7.0 < 7.0.0" } ], - "pdk-version": "1.14.1", - "template-url": "pdk-default#1.14.1", - "template-ref": "1.14.1-0-g0b5b39b" + "pdk-version": "1.16.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#1.16.0", + "template-ref": "tags/1.16.0-0-gaf44904" } diff --git a/provision.yaml b/provision.yaml new file mode 100644 index 00000000..a72db6bc --- /dev/null +++ b/provision.yaml @@ -0,0 +1,14 @@ +--- +docker_centos6: + provisioner: docker + images: ['litmusimage/centos:6'] +docker_centos7: + provisioner: docker + images: ['litmusimage/centos:7'] +docker_ubuntu16: + provisioner: docker + images: ['litmusimage/ubuntu:16.04'] +docker_ubuntu18: + provisioner: docker + images: ['litmusimage/ubuntu:18.04'] +# TODO vagrant diff --git a/spec/acceptance/01_apply_spec.rb b/spec/acceptance/01_apply_spec.rb new file mode 100644 index 00000000..1669a06c --- /dev/null +++ b/spec/acceptance/01_apply_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper_acceptance' + +describe 'apply' do + context 'when full install' do + let(:pp) do + <<-MANIFEST + include st2::profile::fullinstall + MANIFEST + end + + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 012cbacb..e92dced8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |c| c.mock_with :rspec end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 00000000..c37fc242 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require 'serverspec' +require 'puppet_litmus' +require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) +PuppetLitmus.configure! From 1e6d0d77fa5286713e2f992117df5e588b090096 Mon Sep 17 00:00:00 2001 From: Nick Maludy Date: Mon, 17 Feb 2020 21:01:11 -0500 Subject: [PATCH 2/2] Got litmus working for idempotent_apply test --- .fixtures.yml | 4 +-- .sync.yml | 3 +++ Gemfile | 2 ++ build/centos6-puppet5/Puppetfile | 2 -- build/centos6-puppet6/Puppetfile | 2 -- build/centos7-puppet5/Puppetfile | 2 -- build/centos7-puppet6/Puppetfile | 2 -- build/scripts/ci_litmus.sh | 8 ++++-- build/ubuntu14-puppet5/Puppetfile | 2 -- build/ubuntu14-puppet6/Puppetfile | 2 -- build/ubuntu16-puppet5/Puppetfile | 2 -- build/ubuntu16-puppet6/Puppetfile | 2 -- manifests/init.pp | 3 +++ manifests/pack.pp | 41 ----------------------------- manifests/profile/repos.pp | 25 ++++-------------- manifests/profile/server.pp | 43 +++++++++++++++++++++++++++++++ manifests/repo.pp | 37 ++++++++++++++++++++++++++ manifests/repo/apt.pp | 22 ++++++++++++++++ manifests/repo/yum.pp | 20 ++++++++++++++ metadata.json | 8 +++--- provision.yaml | 16 ++++++------ spec/acceptance/01_apply_spec.rb | 5 +++- 22 files changed, 159 insertions(+), 94 deletions(-) create mode 100644 manifests/repo.pp create mode 100644 manifests/repo/apt.pp create mode 100644 manifests/repo/yum.pp diff --git a/.fixtures.yml b/.fixtures.yml index 1401072f..f15475a0 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -16,13 +16,13 @@ fixtures: mongodb: "puppet/mongodb" postgresql: "puppetlabs/postgresql" rabbitmq: "puppet/rabbitmq" - packagecloud: "computology/packagecloud" selinux: "puppet/selinux" nginx: "puppet/nginx" nodejs: "puppet/nodejs" + recursive_file_permissions: "npwalker/recursive_file_permissions" repositories: # needed for Litmus # https://github.com/puppetlabs/puppet_litmus/wiki/Converting-a-module-to-use-Litmus facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - provision: 'https://github.com/puppetlabs/provision.git' + provision: 'https://github.com/nmaludy/provision.git' diff --git a/.sync.yml b/.sync.yml index 91151382..bf8cf127 100644 --- a/.sync.yml +++ b/.sync.yml @@ -56,5 +56,8 @@ Gemfile: version: '>= 0.3.0' - gem: 'puppet-lint-version_comparison-check' version: '>= 0.2.1' + - gem: 'puppet_litmus' + git: 'https://github.com/puppetlabs/puppet_litmus.git' + - gem: 'serverspec' spec/spec_helper.rb: mock_with: ':rspec' diff --git a/Gemfile b/Gemfile index 206ec511..a4d1ac52 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,8 @@ group :development do gem "puppet-lint-trailing_comma-check", '>= 0.3.2', require: false gem "puppet-lint-unquoted_string-check", '>= 0.3.0', require: false gem "puppet-lint-version_comparison-check", '>= 0.2.1', require: false + gem "puppet_litmus", require: false, git: 'https://github.com/puppetlabs/puppet_litmus.git' + gem "serverspec", require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/build/centos6-puppet5/Puppetfile b/build/centos6-puppet5/Puppetfile index 8578a9b5..f790fd08 100644 --- a/build/centos6-puppet5/Puppetfile +++ b/build/centos6-puppet5/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 8578a9b5..f790fd08 100644 --- a/build/centos6-puppet6/Puppetfile +++ b/build/centos6-puppet6/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 8578a9b5..f790fd08 100644 --- a/build/centos7-puppet5/Puppetfile +++ b/build/centos7-puppet5/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 8578a9b5..f790fd08 100644 --- a/build/centos7-puppet6/Puppetfile +++ b/build/centos7-puppet6/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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/scripts/ci_litmus.sh b/build/scripts/ci_litmus.sh index 9012f37a..793b08f1 100755 --- a/build/scripts/ci_litmus.sh +++ b/build/scripts/ci_litmus.sh @@ -3,9 +3,13 @@ set -e set -o xtrace TEST_NAME=docker_centos7 -PUPPET_COLLECTION=puppet5 +PUPPET_COLLECTION=puppet6 bundle exec rake "litmus:provision_list[$TEST_NAME]" -bundle exec bolt command run 'yum -y install wget' --inventoryfile inventory.yaml --targets='localhost*' +# provisioner: docker +# bundle exec bolt command run 'yum -y install wget' --inventoryfile inventory.yaml --targets='localhost*' + +# provisioner: docker_exp +bundle exec bolt command run 'yum -y install wget' --inventoryfile inventory.yaml --targets='docker_nodes' bundle exec rake "litmus:install_agent[$PUPPET_COLLECTION]" bundle exec rake "litmus:install_module" bundle exec rake "litmus:acceptance:parallel" diff --git a/build/ubuntu14-puppet5/Puppetfile b/build/ubuntu14-puppet5/Puppetfile index 8578a9b5..f790fd08 100644 --- a/build/ubuntu14-puppet5/Puppetfile +++ b/build/ubuntu14-puppet5/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 8578a9b5..f790fd08 100644 --- a/build/ubuntu14-puppet6/Puppetfile +++ b/build/ubuntu14-puppet6/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 8578a9b5..f790fd08 100644 --- a/build/ubuntu16-puppet5/Puppetfile +++ b/build/ubuntu16-puppet5/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 8578a9b5..f790fd08 100644 --- a/build/ubuntu16-puppet6/Puppetfile +++ b/build/ubuntu16-puppet6/Puppetfile @@ -38,7 +38,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) @@ -60,7 +59,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 314b7cb7..9f709f2e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -65,6 +65,8 @@ # Set the number of actionrunner processes to start # @param packs # Hash of st2 packages to be installed +# @param packs_group +# Name of the group that will own the /opt/stackstorm/packs directory (default: st2packs) # @param index_url # Url to the StackStorm Exchange index file. (default undef) # @param mistral_db_host @@ -242,6 +244,7 @@ $cli_auth_url = "http://${::st2::params::hostname}:${::st2::params::auth_port}", $actionrunner_workers = $::st2::params::actionrunner_workers, $packs = {}, + $packs_group = $::st2::params::packs_group_name, $index_url = undef, $mistral_db_host = $::st2::params::hostname, $mistral_db_name = $::st2::params::mistral_db_name, diff --git a/manifests/pack.pp b/manifests/pack.pp index dbbb9985..199474c8 100644 --- a/manifests/pack.pp +++ b/manifests/pack.pp @@ -24,43 +24,6 @@ include st2 $_cli_username = $::st2::cli_username $_cli_password = $::st2::cli_password - $_st2_packs_group = $::st2::params::packs_group_name - - ensure_resource('group', $_st2_packs_group, { - 'ensure' => present, - }) - - ensure_resource('file', '/opt/stackstorm', { - 'ensure' => 'directory', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0755', - }) - - ensure_resource('file', '/opt/stackstorm/packs', { - 'ensure' => 'directory', - 'owner' => 'root', - 'group' => $_st2_packs_group, - 'recurse' => true, - 'tag' => 'st2::subdirs', - }) - - ensure_resource('file', '/opt/stackstorm/configs', { - 'ensure' => 'directory', - 'owner' => 'st2', - 'group' => 'root', - 'mode' => '0755', - 'tag' => 'st2::subdirs', - }) - - ensure_resource('file', '/opt/stackstorm/virtualenvs', { - 'ensure' => 'directory', - 'owner' => 'root', - 'group' => $_st2_packs_group, - 'mode' => '0755', - 'tag' => 'st2::subdirs', - }) - st2_pack { $pack: ensure => $ensure, @@ -86,10 +49,6 @@ ~> Exec<| tag == 'st2::register-configs' |> } - Group[$_st2_packs_group] - -> File['/opt/stackstorm'] - -> File<| tag == 'st2::subdirs' |> - Service<| tag == 'st2::service' |> -> St2_pack<||> Exec<| tag == 'st2::reload' |> -> St2_pack<||> } diff --git a/manifests/profile/repos.pp b/manifests/profile/repos.pp index 05fa2ef0..b66eba63 100644 --- a/manifests/profile/repos.pp +++ b/manifests/profile/repos.pp @@ -10,32 +10,17 @@ # # @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, + Enum['stable', 'unstable'] $repository = $st2::repository, ) 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], - } + # defines the StackStorm repo (Yum and Apt are handled here) + class { 'st2::repo': + repository => $repository, } + contain st2::repo } diff --git a/manifests/profile/server.pp b/manifests/profile/server.pp index 37bf95e3..79162ad7 100644 --- a/manifests/profile/server.pp +++ b/manifests/profile/server.pp @@ -65,6 +65,7 @@ $rabbitmq_port = $::st2::rabbitmq_port, $rabbitmq_vhost = $::st2::rabbitmq_vhost, $index_url = $::st2::index_url, + $packs_group = $::st2::packs_group_name, ) inherits st2 { include st2::notices include st2::params @@ -100,6 +101,45 @@ 'tag' => 'st2::server', }) + ensure_resource('group', $packs_group, { + 'ensure' => present, + }) + + ensure_resource('file', '/opt/stackstorm/configs', { + 'ensure' => 'directory', + 'owner' => 'st2', + 'group' => 'root', + 'mode' => '0755', + 'tag' => 'st2::server', + }) + + ensure_resource('file', '/opt/stackstorm/packs', { + 'ensure' => 'directory', + 'owner' => 'root', + 'group' => $packs_group, + 'tag' => 'st2::server', + }) + + ensure_resource('file', '/opt/stackstorm/virtualenvs', { + 'ensure' => 'directory', + 'owner' => 'root', + 'group' => $packs_group, + 'mode' => '0755', + 'tag' => 'st2::server', + }) + + recursive_file_permissions { '/opt/stackstorm/packs': + owner => 'root', + group => $packs_group, + tag => 'st2::server', + } + + recursive_file_permissions { '/opt/stackstorm/virtualenvs': + owner => 'root', + group => $packs_group, + tag => 'st2::server', + } + ######################################## ## Config file { $conf_dir: @@ -371,4 +411,7 @@ Service<| tag == 'st2::service' |> ~> Exec<| tag == 'st2::reload' |> + + St2_pack<||> + ~> Recursive_file_permissions<| tag == 'st2::server' |> } diff --git a/manifests/repo.pp b/manifests/repo.pp new file mode 100644 index 00000000..ef5eb012 --- /dev/null +++ b/manifests/repo.pp @@ -0,0 +1,37 @@ +# manages the StackStorm repo +class st2::repo ( + Variant[Enum['present', 'absent'], Boolean] $ensure = 'present', + Enum['stable', 'unstable'] $repository = 'stable', +) { + case $facts['os']['family'] { + 'RedHat', 'Linux': { + $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', + '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..24f07f12 --- /dev/null +++ b/manifests/repo/apt.pp @@ -0,0 +1,22 @@ +# Apt repo for StackStorm +class st2::repo::apt { + if $st2::repo::ensure == 'present' or $st2::repo::ensure == true { + 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_server, + }, + } + + 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..30ac6a7e --- /dev/null +++ b/manifests/repo/yum.pp @@ -0,0 +1,20 @@ +# Yum repo for StackStorm +class st2::repo::yum { + if $st2::repo::ensure == 'present' or $st2::repo::ensure == true { + 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 f13254bb..df84d815 100644 --- a/metadata.json +++ b/metadata.json @@ -56,10 +56,6 @@ "name": "ghoneycutt/facter", "version_requirement": ">= 3.0.0" }, - { - "name": "computology/packagecloud", - "version_requirement": ">= 0.3.1" - }, { "name": "puppet/selinux", "version_requirement": ">= 0.5.0" @@ -71,6 +67,10 @@ { "name": "puppet/nodejs", "version_requirement": ">= 1.3.0" + }, + { + "name": "npwalker/recursive_file_permissions", + "version_requirement": ">= 0.6.0 < 1.0.0" } ], "operatingsystem_support": [ diff --git a/provision.yaml b/provision.yaml index a72db6bc..eb3927dd 100644 --- a/provision.yaml +++ b/provision.yaml @@ -1,14 +1,14 @@ --- docker_centos6: - provisioner: docker - images: ['litmusimage/centos:6'] + provisioner: docker_exp + images: ['stackstorm/packagingtest:centos6-sshd'] docker_centos7: - provisioner: docker - images: ['litmusimage/centos:7'] + provisioner: docker_exp + images: ['stackstorm/packagingtest:centos7-systemd'] docker_ubuntu16: - provisioner: docker - images: ['litmusimage/ubuntu:16.04'] + provisioner: docker_exp + images: ['stackstorm/packagingtest:xenial-systemd'] docker_ubuntu18: - provisioner: docker - images: ['litmusimage/ubuntu:18.04'] + provisioner: docker_exp + images: ['stackstorm/packagingtest:bionic-systemd'] # TODO vagrant diff --git a/spec/acceptance/01_apply_spec.rb b/spec/acceptance/01_apply_spec.rb index 1669a06c..b24185a2 100644 --- a/spec/acceptance/01_apply_spec.rb +++ b/spec/acceptance/01_apply_spec.rb @@ -4,7 +4,10 @@ context 'when full install' do let(:pp) do <<-MANIFEST - include st2::profile::fullinstall + class { 'sudo': + purge => false, + } + contain st2::profile::fullinstall MANIFEST end