diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d7a7e3a..f2b30c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,6 +7,7 @@ on: - master pull_request: + jobs: unit: runs-on: ubuntu-latest @@ -15,27 +16,27 @@ jobs: fail-fast: false matrix: include: - - ruby: 2.5.7 - puppet: 6 + - ruby: 2.7.7 + puppet: 7 fixtures: .fixtures.yml allow_failure: false - - ruby: 2.7.0 - puppet: 7 + - ruby: 3.2.2 + puppet: 8 fixtures: .fixtures.yml allow_failure: false env: BUNDLE_WITHOUT: system_tests:release PUPPET_GEM_VERSION: "~> ${{ matrix.puppet }}.0" - FACTER_GEM_VERSION: "< 4.0" FIXTURES_YML: ${{ matrix.fixtures }} name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + cache-version: 2 bundler: '2.1.0' - name: Validate run: bundle exec rake check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint @@ -47,15 +48,13 @@ jobs: fail-fast: false matrix: set: - - "centos-7" - - "rocky-8" - - "debian-9" + - "el7" + - "el8" - "debian-10" - - "ubuntu-1804" - "ubuntu-2004" puppet: - - "puppet6" - "puppet7" + - "puppet8" env: BUNDLE_WITHOUT: development:release BEAKER_debug: true @@ -70,14 +69,16 @@ jobs: run: | set -x sudo apt-get remove mysql-server --purge + sudo apt-get update sudo apt-get install apparmor-profiles sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' bundler-cache: true + cache-version: 2 bundler: '2.1.0' - name: Run tests run: bundle exec rake beaker diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 495a715..f55e6af 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.rubocop.yml b/.rubocop.yml index 5307849..3b93cd8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,11 @@ --- require: - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.5' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -21,13 +20,6 @@ AllCops: Metrics/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -40,10 +32,6 @@ Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining -Style/BracesAroundHashParameters: - Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. - See https://github.com/rubocop-hq/rubocop/pull/7643 - Enabled: true Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact @@ -72,13 +60,16 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets +RSpec/ImplicitSubject: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Naming/MethodParameterName: + AllowedNames: + - is RSpec/MessageSpies: EnforcedStyle: receive Style/Documentation: @@ -93,15 +84,9 @@ Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: - Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: - Enabled: false -GetText/DecorateStringFormattingUsingPercent: - Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/HeredocIndentation: Enabled: false Metrics/AbcSize: Enabled: false diff --git a/.sync.yml b/.sync.yml index bccb309..201417c 100644 --- a/.sync.yml +++ b/.sync.yml @@ -2,15 +2,14 @@ .github/workflows/ci.yaml: acceptance_matrix: set: - - centos-7 - - rocky-8 - - debian-9 + - el7 + - el8 + - ---el9 - debian-10 - - ubuntu-1804 - ubuntu-2004 puppet: - - puppet6 - puppet7 + - puppet8 .gitlab-ci.yml: delete: true appveyor.yml: @@ -19,3 +18,9 @@ spec/spec_helper_acceptance.rb: spec_overrides: - "proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))" - "copy_root_module_to(hosts, source: File.join(proj_root, 'tests/site_munge'), module_name: 'site_munge', ignore_list: [])" +spec/acceptance/nodesets/el9.yml: + delete: true +spec/acceptance/nodesets/debian-11.yml: + delete: true +spec/acceptance/nodesets/ubuntu-2204.yml: + delete: true diff --git a/Gemfile b/Gemfile index 2f01d84..4bc7150 100644 --- a/Gemfile +++ b/Gemfile @@ -17,30 +17,22 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - 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.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 "puppet-lint-param-docs", require: false - gem "github_changelog_generator", require: false + gem "voxpupuli-test", '5.4.1', require: false + gem "faraday", '~> 1.0', require: false + gem "github_changelog_generator", require: false + gem "puppet-blacksmith", require: false + gem "puppet-strings", require: false end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0') + gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.29') gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') gem "beaker-pe", require: false gem "beaker-hostgenerator" gem "beaker-rspec" - gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || '~> 0.7.0') + gem "beaker-docker" gem "beaker-puppet" + gem "beaker-puppet_install_helper", require: false + gem "beaker-module_install_helper", require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index dc7ab0a..1bdbda9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,8 @@ # 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' +require 'beaker-rspec/rake_task' if Bundler.rubygems.find_name('beaker-rspec').any? require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? diff --git a/manifests/config.pp b/manifests/config.pp index 07f8e3b..43f2ba5 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,53 +1,52 @@ # @summary Manage munge config # @api private class munge::config { - file { '/etc/munge/munge.key': ensure => 'file', - path => $::munge::munge_key_path, - owner => $::munge::user, - group => $::munge::group, + path => $munge::munge_key_path, + owner => $munge::user, + group => $munge::group, mode => '0400', - source => $::munge::munge_key_source, - content => $::munge::munge_key_content, + source => $munge::munge_key_source, + content => $munge::munge_key_content, } - if $::munge::conf_dir { + if $munge::conf_dir { file { '/etc/munge': ensure => 'directory', - path => $::munge::conf_dir, - owner => $::munge::user, - group => $::munge::group, + path => $munge::conf_dir, + owner => $munge::user, + group => $munge::group, mode => '0700', } } - if $::munge::log_dir { + if $munge::log_dir { file { '/var/log/munge': ensure => 'directory', - path => $::munge::log_dir, - owner => $::munge::user, - group => $::munge::group, + path => $munge::log_dir, + owner => $munge::user, + group => $munge::group, mode => '0700', } } - if $::munge::lib_dir { + if $munge::lib_dir { file { '/var/lib/munge': ensure => 'directory', - path => $::munge::lib_dir, - owner => $::munge::user, - group => $::munge::group, + path => $munge::lib_dir, + owner => $munge::user, + group => $munge::group, mode => '0700', } } - if $::munge::run_dir { + if $munge::run_dir { file { '/run/munge': ensure => 'directory', - path => $::munge::run_dir, - owner => $::munge::user, - group => $::munge::group, + path => $munge::run_dir, + owner => $munge::user, + group => $munge::group, mode => '0755', } } diff --git a/manifests/init.pp b/manifests/init.pp index 6b62c0a..d81aa5c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -84,17 +84,15 @@ Stdlib::Absolutepath $munge_user_home = '/var/run/munge', Optional[Array[String]] $package_install_options = undef, ) { + contain munge::user + contain munge::repo + contain munge::install + contain munge::config + contain munge::service - if ! $facts['os']['family'] in ['RedHat'] { - fail("Unsupported osfamily: ${facts['os']['family']}, module ${module_name} only support osfamily RedHat") - } - - anchor { 'munge::start': } - -> class { '::munge::user': } - -> class { '::munge::repo': } - -> class { '::munge::install': } - -> class { '::munge::config': } - ~> class { '::munge::service': } - -> anchor { 'munge::end': } - + Class['munge::user'] + -> Class['munge::repo'] + -> Class['munge::install'] + -> Class['munge::config'] + ~> Class['munge::service'] } diff --git a/manifests/install.pp b/manifests/install.pp index bb0242f..9114691 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,18 +1,17 @@ # @summary Manage munge packages # @api private class munge::install { - package { 'munge': - ensure => $::munge::package_ensure, - name => $::munge::package_name, - install_options => $::munge::package_install_options, + ensure => $munge::package_ensure, + name => $munge::package_name, + install_options => $munge::package_install_options, + notify => Service['munge'], } - if $::munge::install_dev { + if $munge::install_dev { package { 'munge-devel': - ensure => $::munge::package_ensure, - name => $::munge::dev_package_name, + ensure => $munge::package_ensure, + name => $munge::dev_package_name, } } - } diff --git a/manifests/repo.pp b/manifests/repo.pp index 7967bba..8a9f75b 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -1,16 +1,14 @@ # @summary Manage munge repo # @api private class munge::repo { - - if $::munge::manage_repo { - case $::osfamily { + if $munge::manage_repo { + case $facts['os']['family'] { 'RedHat': { - contain ::epel + contain epel } default: { # Do nothing } } } - } diff --git a/manifests/service.pp b/manifests/service.pp index dd85df7..43cb114 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,13 +1,11 @@ # @summary Manage munge service # @api private class munge::service { - service { 'munge': - ensure => $::munge::service_ensure, - enable => $::munge::service_enable, - name => $::munge::service_name, - hasstatus => $::munge::service_hasstatus, - hasrestart => $::munge::service_hasrestart, + ensure => $munge::service_ensure, + enable => $munge::service_enable, + name => $munge::service_name, + hasstatus => $munge::service_hasstatus, + hasrestart => $munge::service_hasrestart, } - } diff --git a/manifests/user.pp b/manifests/user.pp index 8794ce4..7d05ea7 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -1,28 +1,26 @@ # @summary Manage munge user and group # @api private class munge::user { - - if $::munge::manage_user { + if $munge::manage_user { group { 'munge': ensure => 'present', - name => $::munge::group, - gid => $::munge::munge_group_gid, + name => $munge::group, + gid => $munge::munge_group_gid, system => true, forcelocal => true, } user { 'munge': ensure => 'present', - name => $::munge::user, - uid => $::munge::munge_user_uid, - gid => $::munge::group, - shell => $::munge::munge_user_shell, - home => $::munge::munge_user_home, + name => $munge::user, + uid => $munge::munge_user_uid, + gid => $munge::group, + shell => $munge::munge_user_shell, + home => $munge::munge_user_home, managehome => false, comment => "Runs Uid 'N' Gid Emporium", system => true, forcelocal => true, } } - } diff --git a/metadata.json b/metadata.json index dd88138..fc4dfb4 100644 --- a/metadata.json +++ b/metadata.json @@ -10,11 +10,11 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.13.1 <9.0.0" + "version_requirement": ">= 4.13.1 <10.0.0" }, { "name": "puppet/epel", - "version_requirement": ">= 3.0.0 <5.0.0" + "version_requirement": ">= 3.0.0 <6.0.0" } ], "operatingsystem_support": [ @@ -37,17 +37,21 @@ "8" ] }, + { + "operatingsystem": "AlmaLinux", + "operatingsystemrelease": [ + "8" + ] + }, { "operatingsystem": "Debian", "operatingsystemrelease": [ - "9", "10" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "18.04", "20.04" ] } @@ -55,13 +59,13 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.1.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "tags": [ "munge" ], - "pdk-version": "1.17.0", + "pdk-version": "2.7.1", "template-url": "https://github.com/treydock/pdk-templates.git#master", - "template-ref": "heads/master-0-g3b13f94" + "template-ref": "heads/master-0-g70732db" } diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index cf00cc9..7570b23 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'munge class:' do @@ -15,11 +17,11 @@ dev_package = 'libmunge-dev' end - context 'default parameters' do + context 'with default parameters' do it 'runs successfully' do - pp = <<-EOS + pp = <<-PP class { 'munge': munge_key_source => 'puppet:///modules/site_munge/munge.key' } - EOS + PP apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) @@ -48,12 +50,12 @@ class { 'munge': munge_key_source => 'puppet:///modules/site_munge/munge.key' } context 'when install_dev => true' do it 'runs successfully' do - pp = <<-EOS + pp = <<-PP class { 'munge': install_dev => true, munge_key_source => 'puppet:///modules/site_munge/munge.key', } - EOS + PP apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) diff --git a/spec/acceptance/nodesets/debian-9.yml b/spec/acceptance/nodesets/debian-9.yml deleted file mode 100644 index 48f5e6b..0000000 --- a/spec/acceptance/nodesets/debian-9.yml +++ /dev/null @@ -1,28 +0,0 @@ -HOSTS: - debian9: - roles: - - agent - platform: debian-9-amd64 - hypervisor: docker - image: debian:9 - docker_preserve_image: true - docker_cmd: - - '/sbin/init' - docker_image_commands: - - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates' - - 'echo "LC_ALL=en_US.UTF-8" >> /etc/environment' - - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - - 'locale-gen en_US.UTF-8' - docker_env: - - LANG=en_US.UTF-8 - - LANGUAGE=en_US.UTF-8 - - LC_ALL=en_US.UTF-8 - docker_container_name: 'munge-debian9' -CONFIG: - log_level: debug - type: foss -ssh: - password: root - auth_methods: ["password"] - diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/el7.yml similarity index 65% rename from spec/acceptance/nodesets/centos-7.yml rename to spec/acceptance/nodesets/el7.yml index a972ff7..ff12a3d 100644 --- a/spec/acceptance/nodesets/centos-7.yml +++ b/spec/acceptance/nodesets/el7.yml @@ -10,6 +10,8 @@ HOSTS: - '/usr/sbin/init' docker_image_commands: - 'yum install -y wget which cronie iproute initscripts' + - 'wget --no-check-certificate https://copr.fedorainfracloud.org/coprs/jsynacek/systemd-backports-for-centos-7/repo/epel-7/jsynacek-systemd-backports-for-centos-7-epel-7.repo -O /etc/yum.repos.d/jsynacek-systemd-centos-7.repo' + - 'yum update -y systemd' docker_env: - LANG=en_US.UTF-8 - LANGUAGE=en_US.UTF-8 diff --git a/spec/acceptance/nodesets/rocky-8.yml b/spec/acceptance/nodesets/el8.yml similarity index 88% rename from spec/acceptance/nodesets/rocky-8.yml rename to spec/acceptance/nodesets/el8.yml index 4bfa0b7..eeba76a 100644 --- a/spec/acceptance/nodesets/rocky-8.yml +++ b/spec/acceptance/nodesets/el8.yml @@ -4,14 +4,14 @@ HOSTS: - agent platform: el-8-x86_64 hypervisor: docker - image: rockylinux/rockylinux:8 + image: almalinux:8 docker_preserve_image: true docker_cmd: - '/usr/sbin/init' docker_image_commands: - 'dnf install -y dnf-utils' - 'dnf config-manager --set-enabled powertools' - - 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks' + - 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks glibc-langpack-en cpio' docker_env: - LANG=en_US.UTF-8 - LANGUAGE=en_US.UTF-8 diff --git a/spec/acceptance/nodesets/ubuntu-1804.yml b/spec/acceptance/nodesets/ubuntu-1804.yml deleted file mode 100644 index 96b259b..0000000 --- a/spec/acceptance/nodesets/ubuntu-1804.yml +++ /dev/null @@ -1,25 +0,0 @@ -HOSTS: - ubuntu1804: - roles: - - agent - platform: ubuntu-18.04-amd64 - hypervisor : docker - image: ubuntu:18.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - "rm -f /etc/dpkg/dpkg.cfg.d/excludes" - - 'apt-get install -y wget net-tools iproute2 locales apt-transport-https ca-certificates' - - 'locale-gen en_US.UTF-8' - docker_env: - - LANG=en_US.UTF-8 - - LANGUAGE=en_US.UTF-8 - - LC_ALL=en_US.UTF-8 - docker_container_name: 'munge-ubuntu1804' -CONFIG: - log_level: debug - type: foss -ssh: - password: root - auth_methods: ["password"] - diff --git a/spec/classes/munge_spec.rb b/spec/classes/munge_spec.rb index 3f6533c..6b494f7 100644 --- a/spec/classes/munge_spec.rb +++ b/spec/classes/munge_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'munge' do @@ -9,11 +11,7 @@ case facts[:osfamily] when 'RedHat' - epel = if facts[:os]['release']['major'].to_i >= 8 - false - else - true - end + epel = facts[:os]['release']['major'].to_i < 8 dev_package = 'munge-devel' user_shell = '/sbin/nologin' user_home = '/var/run/munge' @@ -26,15 +24,13 @@ it { is_expected.to create_class('munge') } - it { is_expected.to contain_anchor('munge::start').that_comes_before('Class[munge::user]') } it { is_expected.to contain_class('munge::user').that_comes_before('Class[munge::repo]') } it { is_expected.to contain_class('munge::repo').that_comes_before('Class[munge::install]') } it { is_expected.to contain_class('munge::install').that_comes_before('Class[munge::config]') } it { is_expected.to contain_class('munge::config').that_notifies('Class[munge::service]') } - it { is_expected.to contain_class('munge::service').that_comes_before('Anchor[munge::end]') } - it { is_expected.to contain_anchor('munge::end') } + it { is_expected.to contain_class('munge::service') } - context 'munge::user' do + describe 'munge::user' do it do is_expected.to contain_group('munge').with(ensure: 'present', name: 'munge', @@ -76,7 +72,7 @@ end end - context 'munge::repo' do + describe 'munge::repo' do it do if epel is_expected.to contain_class('epel') @@ -92,10 +88,11 @@ end end - context 'munge::install' do + describe 'munge::install' do it do is_expected.to contain_package('munge').only_with(ensure: 'present', - name: 'munge') + name: 'munge', + notify: 'Service[munge]') end it { is_expected.not_to contain_package('munge-devel') } @@ -110,7 +107,7 @@ end end - context 'munge::config' do + describe 'munge::config' do it do is_expected.to contain_file('/etc/munge/munge.key').only_with(ensure: 'file', path: '/etc/munge/munge.key', @@ -120,7 +117,7 @@ end end - context 'munge::service' do + describe 'munge::service' do it do is_expected.to contain_service('munge').only_with(ensure: 'running', enable: 'true', diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b367fde..7272754 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,24 +9,24 @@ require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) -include RspecPuppetFacts +include RspecPuppetFacts # rubocop:disable Style/MixinUsage default_facts = { puppetversion: Puppet.version, - facterversion: Facter.version, + facterversion: Facter.version } default_fact_files = [ File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), + File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')) ] default_fact_files.each do |f| next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e + default_facts.merge!(YAML.safe_load(File.read(f))) + rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 3e341ef..8867310 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'beaker-rspec' require 'beaker-puppet' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' -dir = File.expand_path(File.dirname(__FILE__)) +dir = __dir__ Dir["#{dir}/acceptance/shared_examples/**/*.rb"].sort.each { |f| require f } require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) diff --git a/spec/spec_helper_acceptance_setup.rb b/spec/spec_helper_acceptance_setup.rb index 163aa77..8b12614 100644 --- a/spec/spec_helper_acceptance_setup.rb +++ b/spec/spec_helper_acceptance_setup.rb @@ -1,16 +1,18 @@ +# frozen_string_literal: true + # Hack to work around issues with recent systemd and docker and running services as non-root if (fact('os.family') == 'RedHat' && fact('os.release.major').to_i >= 7) || (fact('os.name') == 'Ubuntu' && fact('os.release.full') == '16.04') - service_hack = <<-EOS + service_hack = <<-HACK [Service] User=root Group=root -EOS + HACK on hosts, 'mkdir -p /etc/systemd/system/munge.service.d' create_remote_file(hosts, '/etc/systemd/system/munge.service.d/hack.conf', service_hack) - hiera_yaml = <<-EOS + hiera_yaml = <<-HIERA --- version: 5 defaults: @@ -19,8 +21,8 @@ hierarchy: - name: "Common" path: "common.yaml" -EOS - common_yaml = <<-EOS + HIERA + common_yaml = <<-HIERA --- munge::manage_user: false munge::user: root @@ -29,7 +31,7 @@ munge::log_dir: /var/log/munge munge::conf_dir: /etc/munge munge::run_dir: /run/munge -EOS + HIERA create_remote_file(hosts, '/etc/puppetlabs/puppet/hiera.yaml', hiera_yaml) on hosts, 'mkdir -p /etc/puppetlabs/puppet/data'