diff --git a/.editorconfig b/.editorconfig index d77700e..ecb10a8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,7 @@ # editorconfig.org -# MANAGED BY MODULESYNC +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ root = true diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cace33e..daceb64 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -25,7 +25,7 @@ By participating in this project you agree to abide by its terms. * Fork the repo. * Create a separate branch for your change. -* We only take pull requests with passing tests, and documentation. [travis-ci](http://travis-ci.org) runs the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). * Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. * Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. * Squash your commits down into logical components. Make sure to rebase against our current master. @@ -124,26 +124,36 @@ If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: ```sh -export PUPPET_VERSION="~> 5.5.6" +export PUPPET_GEM_VERSION="~> 6.1.0" ``` You can install all needed gems for spec tests into the modules directory by running: ```sh -bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +bundle config set --local path '.vendor/' +bundle config set --local without 'development system_tests release' +bundle install --jobs "$(nproc)" ``` If you also want to run acceptance tests: ```sh -bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" ``` Our all in one solution if you don't know if you need to install or update gems: ```sh -bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +bundle update +bundle clean ``` As an alternative to the `--jobs "$(nproc)` parameter, you can set an @@ -232,52 +242,31 @@ simple tests against it after applying the module. You can run this with: ```sh -bundle exec rake acceptance +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` -This will run the tests on the module's default nodeset. You can override the -nodeset used, e.g., +or ```sh -BEAKER_set=centos-7-x64 bundle exec rake acceptance +BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker ``` -There are default rake tasks for the various acceptance test modules, e.g., +This latter example will use the distribution's own version of Puppet. -```sh -bundle exec rake beaker:centos-7-x64 -bundle exec rake beaker:ssh:centos-7-x64 -``` - -If you don't want to have to recreate the virtual machine every time you can -use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at -least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the -created virtual machines will be in `.vagrant/beaker_vagrant_files`. - -Beaker also supports docker containers. We also use that in our automated CI -pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant: - -```sh -PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker -``` - -You can replace the string `debian10` with any common operating system. +You can replace the string `debian11` with any common operating system. The following strings are known to work: -* ubuntu1604 -* ubuntu1804 * ubuntu2004 -* debian9 -* debian10 -* centos6 -* centos7 -* centos8 - -The easiest way to debug in a docker container is to open a shell: - -```sh -docker exec -it -u root ${container_id_or_name} bash -``` +* ubuntu2204 +* debian11 +* debian12 +* centos9 +* archlinux +* almalinux8 +* almalinux9 +* fedora36 + +For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) repository. diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index cacadf2..0000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Vox Pupuli Security Policy - -Our vulnerabilities reporting process is at https://voxpupuli.org/security/ diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..f2d08d6 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,6 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +skip-changelog: + - head-branch: ['^release-*', 'release'] diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f5b5d7a --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,42 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes + +changelog: + exclude: + labels: + - duplicate + - invalid + - modulesync + - question + - skip-changelog + - wont-fix + - wontfix + + categories: + - title: Breaking Changes 🛠 + labels: + - backwards-incompatible + + - title: New Features 🎉 + labels: + - enhancement + + - title: Bug Fixes 🐛 + labels: + - bug + + - title: Documentation Updates 📚 + labels: + - documentation + - docs + + - title: Dependency Updates ⬆️ + labels: + - dependencies + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8c32acf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +# yamllint disable-line rule:truthy +on: + pull_request: {} + push: + branches: + - main + - master + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +jobs: + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v3 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..73be88d --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,18 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: "Pull Request Labeler" + +# yamllint disable-line rule:truthy +on: + pull_request_target: {} + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4adf65c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +# yamllint disable-line rule:truthy +on: + push: + tags: + - '*' + +jobs: + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v3 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} + + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + steps: + - name: Create GitHub release + uses: voxpupuli/gha-create-a-github-release@v1 diff --git a/.gitignore b/.gitignore index e9b3cf4..adea1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,25 @@ -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.librarian/ -Puppetfile.lock +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock *.iml .*.sw? -.yardoc/ -Guardfile +/.yardoc/ +/Guardfile +bolt-debug.log +.rerun.json diff --git a/.msync.yml b/.msync.yml index 5758ace..ac84b45 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1,2 +1,5 @@ --- -modulesync_config_version: '3.1.0' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '9.3.0' diff --git a/.overcommit.yml b/.overcommit.yml index 0af0fdc..4ed994c 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -1,4 +1,5 @@ -# Managed by https://github.com/voxpupuli/modulesync_configs +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # # Hooks are only enabled if you take action. # @@ -42,10 +43,12 @@ PreCommit: enabled: true description: 'Runs rubocop on modified files only' command: ['bundle', 'exec', 'rubocop'] - PuppetLint: + RakeTarget: enabled: true - description: 'Runs puppet-lint on modified files only' - command: ['bundle', 'exec', 'puppet-lint'] + description: 'Runs lint on modified files only' + targets: + - 'lint' + command: ['bundle', 'exec', 'rake'] YamlSyntax: enabled: true JsonSyntax: diff --git a/.pmtignore b/.pmtignore index 4e6d54b..a9d37aa 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1,21 +1,39 @@ -docs/ -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.librarian/ -Puppetfile.lock +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock +/Puppetfile *.iml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml .*.sw? -.yardoc/ -Dockerfile +/.yardoc/ +/.yardopts +/Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..05d28a2 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,6 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rspec b/.rspec deleted file mode 100644 index 8c18f1a..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---format documentation ---color diff --git a/.rspec_parallel b/.rspec_parallel deleted file mode 100644 index e4d136b..0000000 --- a/.rspec_parallel +++ /dev/null @@ -1 +0,0 @@ ---format progress diff --git a/.rubocop.yml b/.rubocop.yml index 198a359..fded90c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,7 @@ --- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +inherit_from: .rubocop_todo.yml inherit_gem: voxpupuli-test: rubocop.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..de3a079 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,30 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-08-17 21:38:56 UTC using RuboCop version 1.50.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 3 +RSpec/RepeatedExampleGroupDescription: + Exclude: + - 'spec/acceptance/2_upgrades_spec.rb' + +# Offense count: 11 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'spec/acceptance/1_installs_spec.rb' + - 'spec/acceptance/2_upgrades_spec.rb' + - 'spec/classes/stash_backup_spec.rb' + - 'spec/classes/stash_config_spec.rb' + - 'spec/classes/stash_facts_spec.rb' + - 'spec/classes/stash_gc_spec.rb' + - 'spec/classes/stash_init_spec.rb' + - 'spec/classes/stash_install_spec.rb' + - 'spec/classes/stash_service_spec.rb' + - 'spec/classes/stash_upgrade_spec.rb' + - 'spec/spec_helper_acceptance.rb' diff --git a/.sync.yml b/.sync.yml index 335d73d..6e81d4c 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,6 +1,4 @@ --- -.travis.yml: - secure: "HJzcyYqTo3Wrg7Jye1c+BLLv3P2JbXIePIFt0hd25fnlxyjMl2FIWjqwxJ0LO6mFSXU/PxEkfrqjyhzRodtMS5x9Ut90hWV3gSFDWSXBVssVrCSZgQMksXa+tQhk6ieWy3t0sdJmuuALr2v+SrDG2UybTggfKfNdM2k277rdR7w=" spec/spec_helper.rb: spec_overrides: - "STASH_VERSION = '6.8.1'.freeze" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c26517a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -# yamllint disable rule:line-length rule:truthy -os: linux -dist: focal -language: ruby -cache: bundler -before_install: - - yes | gem update --system - - bundle --version -script: - - 'bundle exec rake $CHECK' -jobs: - fast_finish: true - include: - - rvm: 2.4.4 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=test - - rvm: 2.5.3 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls - - rvm: 2.5.3 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 6.0" CHECK=rubocop - - rvm: 2.4.4 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes -branches: - only: - - master - - /^v\d/ -notifications: - email: false - webhooks: https://voxpupu.li/incoming/travis - irc: - on_success: always - on_failure: always - channels: - - "chat.freenode.org#voxpupuli-notifications" -deploy: - provider: puppetforge - username: puppet - password: - secure: "HJzcyYqTo3Wrg7Jye1c+BLLv3P2JbXIePIFt0hd25fnlxyjMl2FIWjqwxJ0LO6mFSXU/PxEkfrqjyhzRodtMS5x9Ut90hWV3gSFDWSXBVssVrCSZgQMksXa+tQhk6ieWy3t0sdJmuuALr2v+SrDG2UybTggfKfNdM2k277rdR7w=" - on: - tags: true - # all_branches is required to use tags - all_branches: true - # Only publish the build marked with "DEPLOY_TO_FORGE" - condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 3687f51..0000000 --- a/.yardopts +++ /dev/null @@ -1,2 +0,0 @@ ---markup markdown ---output-dir docs/ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6fd6342..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM ruby:2.5.3 - -WORKDIR /opt/puppet - -# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 -RUN mkdir -p /etc/sv - -ARG PUPPET_VERSION="~> 6.0" -ARG PARALLEL_TEST_PROCESSORS=4 - -# Cache gems -COPY Gemfile . -RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} - -COPY . . - -RUN bundle install -RUN bundle exec rake release_checks - -# Container should not saved -RUN exit 1 diff --git a/Gemfile b/Gemfile index 2fce93c..2ac98f8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,48 +1,32 @@ -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -def location_for(place, fake_version = nil) - if place =~ /^(git[:@][^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact - elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] - else - [place, { :require => false }] - end -end +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 2.1', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false + gem 'voxpupuli-test', '~> 9.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 4.0', :require => false end group :development do - gem 'travis', :require => false - gem 'travis-lint', :require => false gem 'guard-rake', :require => false gem 'overcommit', '>= 0.39.1', :require => false end group :system_tests do - gem 'voxpupuli-acceptance', :require => false + gem 'voxpupuli-acceptance', '~> 3.0', :require => false end group :release do - gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes' - gem 'puppet-blacksmith', :require => false - gem 'voxpupuli-release', :require => false - gem 'puppet-strings', '>= 2.2', :require => false + gem 'voxpupuli-release', '~> 3.0', :require => false end +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] - -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion.to_s, :require => false, :groups => [:test] -else - gem 'facter', :require => false, :groups => [:test] -end - -ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 6.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +puppetversion = ENV['PUPPET_GEM_VERSION'] || [">= 7.24", "< 9"] gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index b450fe7..7684e3c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,33 @@ -require 'voxpupuli/test/rake' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end +end + +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError +end # load optional tasks for releases # only available if gem group releases is installed begin require 'voxpupuli/release/rake_tasks' rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-stash' end desc "Run main 'test' task and report merged results to coveralls" @@ -18,37 +41,4 @@ task test_with_coveralls: [:test] do end end -desc 'Generate REFERENCE.md' -task :reference, [:debug, :backtrace] do |t, args| - patterns = '' - Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) -end - -begin - require 'github_changelog_generator/task' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - version = (Blacksmith::Modulefile.new).version - config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/ - config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." - config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} - config.user = 'voxpupuli' - metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') - metadata = JSON.load(File.read(metadata_json)) - config.project = metadata['name'] - end - - # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 - require 'rbconfig' - if RbConfig::CONFIG['host_os'] =~ /linux/ - task :changelog do - puts 'Fixing line endings...' - changelog_file = File.join(__dir__, 'CHANGELOG.md') - changelog_txt = File.read(changelog_file) - new_contents = changelog_txt.gsub(%r{\r\n}, "\n") - File.open(changelog_file, "w") {|file| file.puts new_contents } - end - end - -rescue LoadError -end # vim: syntax=ruby diff --git a/manifests/gc.pp b/manifests/gc.pp index 58094dc..05dcbf1 100644 --- a/manifests/gc.pp +++ b/manifests/gc.pp @@ -24,8 +24,8 @@ $user = $stash::user, $homedir = $stash::homedir, ) { - if $::stash_version { - if versioncmp($::stash_version, '3.2') < 0 { + if $facts['stash_version'] { + if versioncmp($facts['stash_version'], '3.2') < 0 { $shared = '' } else { $shared = '/shared' diff --git a/manifests/init.pp b/manifests/init.pp index 27aaf8e..fd3cbfb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -81,10 +81,10 @@ ) inherits stash::params { Exec { path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/'] } - if $::stash_version { + if $facts['stash_version'] { # If the running version of stash is less than the expected version of stash # Shut it down in preparation for upgrade. - if versioncmp($version, $::stash_version) > 0 { + if versioncmp($version, $facts['stash_version']) > 0 { notify { 'Attempting to upgrade stash': } exec { $stop_stash: } if versioncmp($version, '3.2.0') > 0 { diff --git a/spec/acceptance/1_installs_spec.rb b/spec/acceptance/1_installs_spec.rb index e9f475f..074dfe9 100644 --- a/spec/acceptance/1_installs_spec.rb +++ b/spec/acceptance/1_installs_spec.rb @@ -4,11 +4,7 @@ # Set environment variable download_url to use local webserver # export download_url = 'http://10.0.0.XXX/' download_url = ENV['download_url'] if ENV['download_url'] -download_url = if ENV['download_url'] - ENV['download_url'] - else - 'undef' - end +download_url = ENV['download_url'] || 'undef' java_url = if download_url == 'undef' 'http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz' else @@ -61,7 +57,7 @@ class { 'stash': backupclient_url => #{download_url}, } include ::stash::facts - EOS + EOS apply_manifest(pp, catch_failures: true) sleep 180 shell 'wget -q --tries=20 --retry-connrefused --read-timeout=10 localhost:7990/stash1' diff --git a/spec/acceptance/2_upgrades_spec.rb b/spec/acceptance/2_upgrades_spec.rb index 9536152..2f814b1 100644 --- a/spec/acceptance/2_upgrades_spec.rb +++ b/spec/acceptance/2_upgrades_spec.rb @@ -1,11 +1,7 @@ require 'spec_helper_acceptance' download_url = ENV['download_url'] if ENV['download_url'] -download_url = if ENV['download_url'] - ENV['download_url'] - else - 'undef' - end +download_url = ENV['download_url'] || 'undef' # We add the sleeps everywhere to give stash enough # time to install/upgrade/run migration tasks/start diff --git a/spec/classes/stash_backup_spec.rb b/spec/classes/stash_backup_spec.rb index 6011df5..6d73328 100644 --- a/spec/classes/stash_backup_spec.rb +++ b/spec/classes/stash_backup_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper.rb' +require 'spec_helper' describe 'stash' do describe 'stash::backup' do @@ -38,6 +38,7 @@ 'owner' => 'stash', 'group' => 'stash') end + it 'manages the backup cron job' do is_expected.to contain_cron('Backup Stash'). with('ensure' => 'present', @@ -46,6 +47,7 @@ 'hour' => '5', 'minute' => '0') end + it 'removes old archives' do is_expected.to contain_tidy('remove_old_archives'). with('path' => '/opt/stash-backup/archives', diff --git a/spec/classes/stash_config_spec.rb b/spec/classes/stash_config_spec.rb index 4473aff..5a9f50b 100644 --- a/spec/classes/stash_config_spec.rb +++ b/spec/classes/stash_config_spec.rb @@ -21,7 +21,9 @@ it do is_expected.not_to contain_file('/opt/stash/atlassian-bitbucket-6.8.1/bin/setenv.sh') end + it { is_expected.not_to contain_file('/opt/stash/atlassian-bitbucket-6.8.1/bin/user.sh') } + it do is_expected.not_to contain_file('/opt/stash/atlassian-bitbucket-6.8.1/conf/server.xml') end @@ -52,7 +54,9 @@ with_content(%r{^STASH_MAX_PERM_SIZE=256m}). with_content(%r{JAVA_OPTS="}) end + it { is_expected.to contain_file('/opt/stash/atlassian-stash-3.8.1/bin/user.sh') } + it do is_expected.to contain_file('/home/stash/shared/server.xml'). with_content(%r{ '/random/homedir', 'shell' => '/bin/bash', - 'uid' => 333, - 'gid' => 444) + 'uid' => 333, + 'gid' => 444) end + it { is_expected.to contain_group('bar') } + it 'manages the stash home directory' do is_expected.to contain_file('/random/homedir').with('ensure' => 'directory', 'owner' => 'foo', diff --git a/spec/classes/stash_service_spec.rb b/spec/classes/stash_service_spec.rb index 00090cd..bae7126 100644 --- a/spec/classes/stash_service_spec.rb +++ b/spec/classes/stash_service_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper.rb' +require 'spec_helper' describe 'stash' do describe 'stash::service' do diff --git a/spec/classes/stash_upgrade_spec.rb b/spec/classes/stash_upgrade_spec.rb index 6cfe56c..b21b7bc 100644 --- a/spec/classes/stash_upgrade_spec.rb +++ b/spec/classes/stash_upgrade_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper.rb' +require 'spec_helper' describe 'stash' do context 'supported operating systems' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 22a6428..950fc3a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,19 +1,24 @@ -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config +# frozen_string_literal: true + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # puppetlabs_spec_helper will set up coverage if the env variable is set. # We want to do this if lib exists and it hasn't been explicitly set. -ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) require 'voxpupuli/test/spec_helper' +RSpec.configure do |c| + c.facterdb_string_keys = false +end + +add_mocked_facts! + if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) - if facts - facts.each do |name, value| - add_custom_fact name.to_sym, value - end + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end @@ -24,3 +29,4 @@ BITBUCKET_VERSION = '4.0.2'.freeze BITBUCKET_BACKUP_VERSION = '2.0.0'.freeze +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index e21f811..430ca8f 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,38 +1,11 @@ -require 'beaker-rspec' -require 'beaker-puppet' -require 'beaker/puppet_install_helper' -require 'beaker/module_install_helper' +require 'voxpupuli/acceptance/spec_helper_acceptance' -run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' - -proxy_host = ENV['BEAKER_PACKAGE_PROXY'] || '' -unless proxy_host.empty? - hosts.each do |host| - on host, "echo 'export http_proxy='#{proxy_host}'' >> /root/.bashrc" - on host, "echo 'export https_proxy='#{proxy_host}'' >> /root/.bashrc" - on host, "echo 'export no_proxy=\"localhost,127.0.0.1,localaddress,.localdomain.com,#{host.name}\"' >> /root/.bashrc" +configure_beaker do |host| + if fact('osfamily') == 'Debian' + on host, "echo \"en_US ISO-8859-1\nen_NG.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\n\" > /etc/locale.gen" + on host, '/usr/sbin/locale-gen' + on host, '/usr/sbin/update-locale' end -end - -RSpec.configure do |c| - # Readable test descriptions - c.formatter = :documentation - # Configure all nodes in nodeset - c.before :suite do - install_module - install_module_dependencies - - hosts.each do |host| - on host, "/bin/touch #{default['puppetpath']}/hiera.yaml" - on host, 'chmod 755 /root' - if fact('osfamily') == 'Debian' - on host, "echo \"en_US ISO-8859-1\nen_NG.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\n\" > /etc/locale.gen" - on host, '/usr/sbin/locale-gen' - on host, '/usr/sbin/update-locale' - end - - on host, puppet('module', 'install', 'puppetlabs-postgresql'), acceptable_exit_codes: [0, 1] - end - end + install_module_from_forge_on(host, 'puppetlabs-postgresql', '>= 0.0.0') end