diff --git a/.gitignore b/.gitignore index f217231..3ee72d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,16 @@ -*.log -*~ -.DS_Store -spec/fixtures/* -*.tmp -.librarian -pkg/* - +.*.sw? +.yardoc +dist/ +pkg/ +spec/fixtures/ +spec/rp_env/ +!/spec/hieradata/default.yaml +!/spec/fixtures/site.pp +.rspec_system +.vagrant/ +.bundle/ +Gemfile.lock +vendor/ +junit/ +log/ +doc/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..63b2af8 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,229 @@ +# The testing matrix considers ruby/puppet versions supported by SIMP and PE: +# +# https://puppet.com/docs/pe/2019.0/component_versions_in_recent_pe_releases.html +# https://puppet.com/misc/puppet-enterprise-lifecycle +# https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html +# ------------------------------------------------------------------------------ +# Release Puppet Ruby EOL +# SIMP 6.1 4.10.6 2.1.9 TBD +# SIMP 6.2 4.10.12 2.1.9 TBD +# SIMP 6.3 5.5.7 2.4.4 TBD*** +# PE 2018.1 5.5.8 2.4.4 2020-05 (LTS)*** +# PE 2019.0 6.0 2.5.1 2019-08-31^^^ +# +# *** = Modules created for SIMP 6.3+ are not required to support Puppet < 5.5 +# ^^^ = SIMP doesn't support 6 yet; tests are info-only and allowed to fail +--- +stages: + - 'sanity' + - 'validation' + - 'acceptance' + - 'compliance' + - 'deployment' + +variables: + PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail) + BUNDLER_VERSION: '1.17.1' + + # Force dependencies into a path the gitlab-runner user can write to. + # (This avoids some failures on Runners with misconfigured ruby environments.) + GEM_HOME: .vendor/gem_install + BUNDLE_CACHE_PATH: .vendor/bundle + BUNDLE_PATH: .vendor/bundle + BUNDLE_BIN: .vendor/gem_install/bin + BUNDLE_NO_PRUNE: 'true' + + +# bundler dependencies and caching +# +# - Cache bundler gems between pipelines foreach Ruby version +# - Try to use cached and local resources before downloading dependencies +# -------------------------------------- +.setup_bundler_env: &setup_bundler_env + cache: + untracked: true + key: "${CI_PROJECT_NAMESPACE}_ruby-${MATRIX_RUBY_VERSION}_bundler" + paths: + - '.vendor' + before_script: + - 'ruby -e "puts %(\n\n), %q(=)*80, %(\nSIMP-relevant Environment Variables:\n\n#{e=ENV.keys.grep(/^PUPPET|^SIMP|^BEAKER|MATRIX/); pad=e.map{|x| x.size}.max+1; e.map{|v| %( * #{%(#{v}:).ljust(pad)} #{39.chr + ENV[v] + 39.chr}\n)}.join}\n), %q(=)*80, %(\n\n)"' + - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-1.17.1}")' + - 'declare GEM_INSTALL_CMD=(gem install --no-document)' + - 'declare BUNDLER_INSTALL_CMD=(bundle install --no-binstubs --jobs $(nproc) "${FLAGS[@]}")' + - 'mkdir -p ${GEM_HOME} ${BUNDLER_BIN}' + - 'gem list -ie "${GEM_BUNDLER_VER[@]}" --silent bundler || "${GEM_INSTALL_CMD[@]}" --local "${GEM_BUNDLER_VER[@]}" bundler || "${GEM_INSTALL_CMD[@]}" "${GEM_BUNDLER_VER[@]}" bundler' + - 'rm -rf pkg/ || :' + - 'bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL_CMD[@]}" --local || "${BUNDLER_INSTALL_CMD[@]}" || bundle pristine || "${BUNDLER_INSTALL_CMD[@]}") || { echo "PIPELINE: Bundler could not install everything (see log output above)" && exit 99 ; }' + +# To avoid running a prohibitive number of tests every commit, +# don't set this env var in your gitlab instance +.only_with_SIMP_FULL_MATRIX: &only_with_SIMP_FULL_MATRIX + only: + variables: + - $SIMP_FULL_MATRIX == "yes" + +# Puppet Versions +#----------------------------------------------------------------------- + +.pup_4: &pup_4 + image: 'ruby:2.1' + variables: + PUPPET_VERSION: '~> 4.0' + MATRIX_RUBY_VERSION: '2.1' + +.pup_4_10: &pup_4_10 + image: 'ruby:2.1' + variables: + PUPPET_VERSION: '~> 4.10.4' + MATRIX_RUBY_VERSION: '2.1' + +.pup_5: &pup_5 + image: 'ruby:2.4' + variables: + PUPPET_VERSION: '~> 5.0' + BEAKER_PUPPET_COLLECTION: 'puppet5' + MATRIX_RUBY_VERSION: '2.4' + +.pup_5_5_7: &pup_5_5_7 + image: 'ruby:2.4' + variables: + PUPPET_VERSION: '5.5.7' + BEAKER_PUPPET_COLLECTION: 'puppet5' + MATRIX_RUBY_VERSION: '2.4' + +.pup_6: &pup_6 + allow_failure: true + image: 'ruby:2.5' + variables: + PUPPET_VERSION: '~> 6.0' + BEAKER_PUPPET_COLLECTION: 'puppet6' + MATRIX_RUBY_VERSION: '2.5' + + +# Testing Environments +#----------------------------------------------------------------------- + +.lint_tests: &lint_tests + stage: 'validation' + tags: ['docker'] + <<: *setup_bundler_env + script: + - 'bundle exec rake syntax' + - 'bundle exec rake lint' + - 'bundle exec rake metadata_lint' + +.unit_tests: &unit_tests + stage: 'validation' + tags: ['docker'] + <<: *setup_bundler_env + script: + - 'bundle exec rake spec' + +.acceptance_base: &acceptance_base + stage: 'acceptance' + tags: ['beaker'] + <<: *setup_bundler_env + +.compliance_base: &compliance_base + stage: 'compliance' + tags: ['beaker'] + <<: *setup_bundler_env + + +# Pipeline / testing matrix +#======================================================================= + +sanity_checks: + <<: *pup_5 + <<: *setup_bundler_env + stage: 'sanity' + tags: ['docker'] + script: + - 'if `hash apt-get`; then apt-get update; fi' + - 'if `hash apt-get`; then apt-get install -y rpm; fi' + - 'bundle exec rake check:dot_underscore' + - 'bundle exec rake check:test_file' + - 'bundle exec rake pkg:check_version' + - 'bundle exec rake pkg:compare_latest_tag' + - 'bundle exec rake pkg:create_tag_changelog' + - 'bundle exec puppet module build' + +# Linting +#----------------------------------------------------------------------- + +pup4-lint: + <<: *pup_4 + <<: *lint_tests + +pup5-lint: + <<: *pup_5 + <<: *lint_tests + +pup6-lint: + <<: *pup_6 + <<: *lint_tests + +# Unit Tests +#----------------------------------------------------------------------- + +pup5-unit: + <<: *pup_5 + <<: *unit_tests + +pup5.5.7-unit: + <<: *pup_5_5_7 + <<: *unit_tests + +pup4.10-unit: + <<: *pup_4_10 + <<: *unit_tests + +pup6-unit: + <<: *pup_6 + <<: *unit_tests + +# Acceptance Tests +# ============================================================================== +pup4.10: + <<: *pup_4_10 + <<: *acceptance_base + script: + - 'bundle exec rake beaker:suites' + +pup4.10-fips: + <<: *pup_4_10 + <<: *acceptance_base + <<: *only_with_SIMP_FULL_MATRIX + script: + - 'BEAKER_fips=yes bundle exec rake beaker:suites' + +pup5.5.7: + <<: *pup_5_5_7 + <<: *acceptance_base + script: + - 'bundle exec rake beaker:suites' + +pup5.5.7-fips: + <<: *pup_5_5_7 + <<: *acceptance_base + script: + - 'BEAKER_fips=yes bundle exec rake beaker:suites' + +pup5.5.7-oel: + <<: *pup_5_5_7 + <<: *acceptance_base + script: + - 'bundle exec rake beaker:suites[default,oel]' + +pup5.5.7-oel-fips: + <<: *pup_5_5_7 + <<: *acceptance_base + <<: *only_with_SIMP_FULL_MATRIX + script: + - 'BEAKER_fips=yes bundle exec rake beaker:suites[default,oel]' + +# pup5.5.7-compliance-fips: +# <<: *pup_5_5_7 +# <<: *compliance_tests +# script: +# - 'BEAKER_fips=yes bundle exec rake beaker:suites[compliance]' diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..71ffc7b --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,4 @@ +--log-format="%{path}:%{line}:%{check}:%{KIND}:%{message}" +--relative +--no-140chars-check +--no-trailing_comma-check diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4cd92bf --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--format documentation +--color +--fail-fast diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..79a6144 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.4.4 diff --git a/.travis.yml b/.travis.yml index 361fb37..4dcb309 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,120 @@ +# The testing matrix considers ruby/puppet versions supported by SIMP and PE: +# +# https://puppet.com/docs/pe/2018.1/component_versions_in_recent_pe_releases.html +# https://puppet.com/misc/puppet-enterprise-lifecycle +# https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html +# ------------------------------------------------------------------------------ +# Release Puppet Ruby EOL +# SIMP 6.2 4.10 2.1.9 TBD +# PE 2016.4 4.10 2.1.9 2018-12-31 (LTS) +# PE 2017.3 5.3 2.4.4 2018-12-31 +# SIMP 6.3 5.5 2.4.4 TBD*** +# PE 2018.1 5.5 2.4.4 2020-05 (LTS)*** +# PE 2019.0 6.0 2.5.1 2019-08-31^^^ +# +# *** = Modules created for SIMP 6.3+ are not required to support Puppet < 5.5 +# ^^^ = SIMP doesn't support 6 yet; tests are info-only and allowed to fail + --- language: ruby -script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" -bundler_args: --without development -matrix: - fast_finish: true - include: - - rvm: 2.1.5 - env: PUPPET_VERSION="~> 3.0" - - rvm: 2.1.5 - env: PUPPET_VERSION="~> 3.0" FUTURE_PARSER="yes" - - rvm: 2.1.6 - env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" - - rvm: 2.4.4 - env: PUPPET_VERSION="~> 5.0" STRICT_VARIABLES="yes" +cache: bundler sudo: false + +stages: + - check + - spec + - name: deploy + if: 'tag IS present' + +bundler_args: --without development system_tests --path .vendor + +notifications: + email: false + +addons: + apt: + packages: + - rpm + +before_install: + - rm -f Gemfile.lock + +global: + - STRICT_VARIABLES=yes + +jobs: + allow_failures: + - name: 'Latest Puppet 6.x (allowed to fail)' + + include: + - stage: check + name: 'Syntax, style, and validation checks' + rvm: 2.4.4 + env: PUPPET_VERSION="~> 5" + script: + - bundle exec rake check:dot_underscore + - bundle exec rake check:test_file + - bundle exec rake pkg:check_version + - bundle exec rake metadata_lint + - bundle exec rake pkg:compare_latest_tag + - bundle exec rake pkg:create_tag_changelog + - bundle exec rake lint + - bundle exec puppet module build + + - stage: spec + name: 'Puppet 4.10 (SIMP 6.2, PE 2016.4)' + rvm: 2.1.9 + env: PUPPET_VERSION="~> 4.10.0" + script: + - bundle exec rake spec + + - stage: spec + name: 'Puppet 5.3 (PE 2017.3)' + rvm: 2.4.4 + env: PUPPET_VERSION="~> 5.3.0" + script: + - bundle exec rake spec + + - stage: spec + rvm: 2.4.4 + name: 'Puppet 5.5 (SIMP 6.3, PE 2018.1)' + env: PUPPET_VERSION="~> 5.5.0" + script: + - bundle exec rake spec + + - stage: spec + name: 'Latest Puppet 5.x' + rvm: 2.4.4 + env: PUPPET_VERSION="~> 5.0" + script: + - bundle exec rake spec + + - stage: spec + name: 'Latest Puppet 6.x (allowed to fail)' + rvm: 2.5.1 + env: PUPPET_VERSION="~> 6.0" + script: + - bundle exec rake spec + + - stage: deploy + rvm: 2.4.4 + script: + - true + before_deploy: + - "export PUPMOD_METADATA_VERSION=`ruby -r json -e \"puts JSON.parse(File.read('metadata.json')).fetch('version')\"`" + - '[[ $TRAVIS_TAG =~ ^simp-${PUPMOD_METADATA_VERSION}$|^${PUPMOD_METADATA_VERSION}$ ]]' + deploy: + - provider: releases + api_key: + secure: "a7NDwZiQUJtofLmiTsVciMKig5aX3YFwLcv0QjW68UXSmCXdPHYcaV/AAVTPbG8+vpRTLxnN2eUNoS4aikUlbbokC814H8H/Cv7L1RxRS4HSrUZFeQX6Pt+4EYe37eenbife5QVufiEO/J7sDwBdMygbSTMIOY3akScA4OEbrEkPmVb1fXL0+e4h6jiinYMWy8AmrW3or4F2KOH3O14Kf0o16pluVZsix5IK7MY8D7LzqIRmfMSlm7ykeGFSuP2qLM+l99mGpztwWQXcjWPNJSYoBAV+yz8a7dzReQqqzQnKMvOiV4u40spstIhZn1u/fMe6fHGtVeaW97xiLeRrSsl4APcAIt/DQt+Njyf5U3nbQ7yc7mqZzYbiUxzRP/niTG+PX+V5P0stHn9V/kSIZso4UVKPPdsbAuuulOeSDfPxXCZOMzkIEtXtNF/z5J6WXk1OQdNAFw2uyeVR02m59LJh817N8vB8BuwDnaAHeTQgmAs9IwX2Ru7XPDkNgEnnm49x+vjzdjp/Vm6gqQwV7pT2rXI4a6VrwFLfS+UrL0cKmzR7+nHRebEnI1MZmo5MXVt3yiae5DyUBp1lNwM+SjL3KsUnUO/HYY34rUoof/PEvZJuKa54Ik1JnE9VWDIgEWx/pOpa3ajYJlhA02BGx64VPkjjI+o4an00G08C7OQ=" + skip_cleanup: true + on: + tags: true + condition: '($SKIP_FORGE_PUBLISH != true)' + - provider: puppetforge + user: simp + password: + secure: "EPe9z4DrHZzOALuRhB/u8Cxby3Dk744Qk77sW+CC+ac9JalaYbERkgBeyZqZjrgGZSoIWjHzKS8jcn/ssiEKiVXRU0XZhek77is70t5EKSxKy67fcGRcL4fqJn1fU/5ackmyCp/7xHmgRMiaGqeUq1zHCjrQPbY78QSGW1dWeSbLuvtOhjVp5tfR7OeODLGnTmvrAfzkphQfroPAEUAw0t3CDBSNELrKMGDDQCUMJXSpSiK+rvKr/qgcihxYDRp2zW5z0xbBnGNLfkmvhan8yT3vCISEFWICN8mCuSIvyvpWfP5E2E1gzQUx3ZBgV20GIqoZX87RJpVAfruZYHn15yBxnPwxnKwkELPKchCiih4IHa1E0YZv2xtxyJvZogUvIkQgJaaDZ7sk93hXAWk0AaGqeBbQML32VaGhYXROpRZecXFx+3kFnFhLxJVYVakjYQhll6r0a8BOSem7Jcy0SsNqGllVMmx7LqXX071ooA2wb0GVOO7qrvKR77He5Wt0lf/S3mg+XPBnnW4p4OyLw3fWERMFgr/pClla/r0NdM3WrMwGKcMbtTgC4Jg/WPHrsCcNgqGs+KaGUkmQxIl4QOPzHCWlDtfoConSFR1t/heNwVc8hKP9Oe+1Y+euSIqbLWwIJ37egE6tO9dIF28V2hNlaHyWJIEXeTQV8lDurTY=" + on: + tags: true + condition: '($SKIP_FORGE_PUBLISH != true)' diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..c97fba2 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,7 @@ +* Thu Mar 07 2019 Nicholas Markowski - 1.0.0-0 +- Forked from cristifalcas/puppet-journald +- Removed default options from API +- Added SIMP assets +- Updated Puppet dependency for hiera v5 support +- Added inifile dependency in metadata, and updated stdlib version dependency +- Initial release diff --git a/Gemfile b/Gemfile index cadbc32..f71b1ab 100644 --- a/Gemfile +++ b/Gemfile @@ -1,35 +1,30 @@ -source 'https://rubygems.org' +gem_sources = ENV.fetch('GEM_SERVERS','https://rubygems.org').split(/[, ]+/) -gem 'puppet', ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : '>= 2.7' +gem_sources.each { |gem_source| source gem_source } -gem 'rake' -gem 'rspec' -gem 'rspec-puppet' -gem 'rspec-puppet-facts' -gem 'puppetlabs_spec_helper' -gem 'puppet-lint' -gem 'puppet-lint-absolute_classname-check' -gem 'puppet-lint-absolute_template_path' -gem 'puppet-lint-classes_and_types_beginning_with_digits-check' -gem 'puppet-lint-empty_string-check' -gem 'puppet-lint-file_ensure-check' -gem 'puppet-lint-leading_zero-check' -gem 'puppet-lint-numericvariable' -gem 'puppet-lint-param-docs', '>= 1.3.0' -gem 'puppet-lint-resource_reference_syntax' -gem 'puppet-lint-spaceship_operator_without_tag-check' -gem 'puppet-lint-strict_indent-check' -gem 'puppet-lint-trailing_comma-check' -gem 'puppet-lint-undef_in_function-check' -gem 'puppet-lint-unquoted_string-check' -gem 'puppet-lint-variable_contains_upcase' -gem 'puppet-lint-version_comparison-check' -gem 'simplecov' -gem 'puppet-blacksmith', '>= 3.1.0', {"groups"=>["development"]} -gem 'json', '~> 1.0', {"platforms"=>["ruby_19"], "groups"=>["test"]} -gem 'json_pure', '~> 1.0', {"platforms"=>["ruby_19"], "groups"=>["test"]} -gem 'metadata-json-lint' -gem 'webmock', '< 2.0' -gem 'addressable', '< 2.4', {"platforms"=>["ruby_18"]} -gem 'oauth' -gem 'parallel_tests', {"platforms"=>["ruby_20", "ruby_21"]} +group :test do + gem 'rake' + gem 'puppet', ENV.fetch('PUPPET_VERSION', '~> 5.5') + gem 'rspec' + gem 'rspec-puppet' + gem 'hiera-puppet-helper' + gem 'puppetlabs_spec_helper' + gem 'metadata-json-lint' + gem 'puppet-strings' + gem 'puppet-lint-empty_string-check', :require => false + gem 'puppet-lint-trailing_comma-check', :require => false + gem 'simp-rspec-puppet-facts', ENV.fetch('SIMP_RSPEC_PUPPET_FACTS_VERSION', '~> 2.2') + gem 'simp-rake-helpers', ENV.fetch('SIMP_RAKE_HELPERS_VERSION', '~> 5.6') +end + +group :development do + gem 'pry' + gem 'pry-byebug' + gem 'pry-doc' +end + +group :system_tests do + gem 'beaker' + gem 'beaker-rspec' + gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', '~> 1.12') +end diff --git a/README.md b/README.md index 6318117..a03bcda 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -# journald -[![Build Status](https://travis-ci.org/cristifalcas/puppet-journald.png?branch=master)](https://travis-ci.org/cristifalcas/puppet-journald) +[![License](https://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) +[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/73/badge)](https://bestpractices.coreinfrastructure.org/projects/73) +[![Puppet Forge](https://img.shields.io/puppetforge/v/simp/journald.svg)](https://forge.puppetlabs.com/simp/journald) +[![Puppet Forge Downloads](https://img.shields.io/puppetforge/dt/simp/journald.svg)](https://forge.puppetlabs.com/simp/journald) +[![Build Status](https://travis-ci.org/simp/pupmod-simp-journald.svg)](https://travis-ci.org/simp/pupmod-simp-journald) #### Table of Contents diff --git a/Rakefile b/Rakefile index b0cb303..1b7080e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,22 +1,3 @@ -require 'bundler' -Bundler.require(:rake) -require 'rake/clean' - -CLEAN.include('spec/fixtures/', 'doc', 'pkg') -CLOBBER.include('.tmp', '.librarian') - -require 'puppetlabs_spec_helper/rake_tasks' - -task :default => [:clean, :spec] - -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_class_parameter_defaults') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.send('disable_empty_string_assignment') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] - +require 'simp/rake/pupmod/helpers' +Simp::Rake::Pupmod::Helpers.new(File.dirname(__FILE__)) diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 0000000..dafcad0 --- /dev/null +++ b/data/common.yaml @@ -0,0 +1,21 @@ +--- + +journald::persist_log: true + +journald::options: + Storage: 'auto' + Compress: 'yes' + Seal: 'yes' + SplitMode: 'login' + SyncIntervalSec: '5m' + RateLimitInterval: '30s' + RateLimitBurst: '10000' + MaxFileSec: '1month' + ForwardToSyslog: 'yes' + ForwardToKMsg: 'yes' + ForwardToConsole: 'no' + TTYPath: '/dev/console' + MaxLevelStore: 'debug' + MaxLevelSyslog: 'debug' + MaxLevelKMsg: 'notice' + MaxLevelConsole: 'info' diff --git a/hiera.yaml b/hiera.yaml new file mode 100644 index 0000000..49a6e6a --- /dev/null +++ b/hiera.yaml @@ -0,0 +1,8 @@ +--- +version: 5 +defaults: + datadir: data + data_hash: yaml_data +hierarchy: + - name: "common" + path: "common.yaml" diff --git a/manifests/config.pp b/manifests/config.pp index 5bbc1be..5cb93c9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,9 +1,6 @@ +# Class: journald::config +# class journald::config { - if $::journald::enable_defaults { - $merged_options = merge($::journald::params::default_options, $::journald::options) - } else { - $merged_options = $::journald::options - } if $::journald::persist_log { $journald_dir = 'directory' @@ -24,7 +21,7 @@ } $ini_settings = { - 'Journal' => $merged_options, + 'Journal' => $::journald::options, } create_ini_settings($ini_settings, $defaults) } diff --git a/manifests/init.pp b/manifests/init.pp index 72eb842..2d8280a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,20 +4,20 @@ # # === Parameters: # -# $persist_log:: By default, the journal stores log data in /run/log/journal/. -# Since /run/ is volatile, log data is lost at reboot. To make the -# data persistent, it is sufficient to create /var/log/journal/ -# where systemd-journald will then store the data. +# @param persist_log +# By default, the journal stores log data in /run/log/journal/. +# Since /run/ is volatile, log data is lost at reboot. To make the +# data persistent, it is sufficient to create /var/log/journal/ +# where systemd-journald will then store the data. # -# $enable_defaults:: if defaults parameters should be used or not -# -# $options:: a hash with journald parameters +# @param options +# A hash with journald parameters # class journald ( - $persist_log = $journald::params::persist_log, - $enable_defaults = $journald::params::enable_defaults, - $options = {}, -) inherits journald::params { + # Module data + Boolean $persist_log, + Hash $options, +) { contain ::journald::config contain ::journald::service diff --git a/manifests/params.pp b/manifests/params.pp deleted file mode 100644 index b816f23..0000000 --- a/manifests/params.pp +++ /dev/null @@ -1,22 +0,0 @@ -class journald::params { - $persist_log = true - $enable_defaults = true - $default_options = { - 'Storage' => 'auto', - 'Compress' => 'yes', - 'Seal' => 'yes', - 'SplitMode' => 'login', - 'SyncIntervalSec' => '5m', - 'RateLimitInterval' => '30s', - 'RateLimitBurst' => '10000', - 'MaxFileSec' => '1month', - 'ForwardToSyslog' => 'yes', - 'ForwardToKMsg' => 'yes', - 'ForwardToConsole' => 'no', - 'TTYPath' => '/dev/console', - 'MaxLevelStore' => 'debug', - 'MaxLevelSyslog' => 'debug', - 'MaxLevelKMsg' => 'notice', - 'MaxLevelConsole' => 'info', - } -} diff --git a/manifests/service.pp b/manifests/service.pp index db89787..beebeb9 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,6 +1,10 @@ +# Class: journald::service +# class journald::service { + service { ['systemd-journald']: ensure => running, enable => true, } + } diff --git a/metadata.json b/metadata.json index 4258cbf..e758a5e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,40 +1,50 @@ { - "name": "cristifalcas-journald", - "author": "Cristian Falcas", - "version": "0.6.1", - "source": "git@github.com:cristifalcas/puppet-journald.git", - "project_page": "https://github.com/cristifalcas/puppet-journald", - "issues_url": "https://github.com/cristifalcas/puppet-journald/issues", - "dependencies": [{ - "name": "puppetlabs/stdlib", - "version_requirement": "4.x" - } - ], - "license": "Apache-2.0", - "operatingsystem_support": [{ - "operatingsystem": "RedHat", - "operatingsystemrelease": [ "7" - ] - },{ - "operatingsystem": "CentOS", - "operatingsystemrelease": [ "7" - ] - },{ - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ "7" - ] - },{ - "operatingsystem": "Scientific", - "operatingsystemrelease": [ "7" - ] - },{ - "operatingsystem": "Fedora", - "operatingsystemrelease": [ "21" - ] - } - ], - "requirements": [], - "summary": "Configures journald on el7", - "tags": [ "journald" - ] + "name": "simp-journald", + "author": "SIMP Team", + "version": "1.0.0", + "summary": "Configures journald on el7", + "source": "git@github.com:simp/pupmod-simp-journald.git", + "project_page": "https://github.com/simp/pupmod-simp-journald", + "issues_url": "https://github.com/simp/pupmod-simp-journald/issues", + "tags": [ + "simp", + "journald" + ], + "dependencies": [ + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.19.0 < 6.0.0" + }, + { + "name": "puppetlabs/inifile", + "version_requirement": ">= 2.5.0 < 3.0.0" + } + ], + "license": "Apache-2.0", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "7" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "7" + ] + } + ], + "requirements": [ + { + "name": "puppet", + "version_requirement": ">= 4.10.4 < 6.0.0" + } + ] } diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000..de9afa3 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,26 @@ +<% + if ENV['BEAKER_HYPERVISOR'] + hypervisor = ENV['BEAKER_HYPERVISOR'] + else + hypervisor = 'vagrant' + end +-%> +HOSTS: + el7: + roles: + - server + - default + - master + - client + platform: el-7-x86_64 + box: centos/7 + hypervisor: <%= hypervisor %> + +CONFIG: + log_level: verbose + synced_folder : disabled + type: aio + vagrant_memsize: 256 +<% if ENV['BEAKER_PUPPET_COLLECTION'] -%> + puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %> +<% end -%> diff --git a/spec/acceptance/nodesets/oel.yml b/spec/acceptance/nodesets/oel.yml new file mode 100644 index 0000000..31d4ef5 --- /dev/null +++ b/spec/acceptance/nodesets/oel.yml @@ -0,0 +1,26 @@ +<% + if ENV['BEAKER_HYPERVISOR'] + hypervisor = ENV['BEAKER_HYPERVISOR'] + else + hypervisor = 'vagrant' + end +-%> +HOSTS: + oel7: + roles: + - server + - default + - master + - client + platform: el-7-x86_64 + box: onyxpoint/oel-7-x86_64 + hypervisor: <%= hypervisor %> + +CONFIG: + log_level: verbose + synced_folder : disabled + type: aio + vagrant_memsize: 256 +<% if ENV['BEAKER_PUPPET_COLLECTION'] -%> + puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %> +<% end -%> diff --git a/spec/acceptance/suites/default/class_spec.rb b/spec/acceptance/suites/default/class_spec.rb new file mode 100644 index 0000000..60eb639 --- /dev/null +++ b/spec/acceptance/suites/default/class_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper_acceptance' + +test_name 'journald class' + +describe 'journald class' do + let(:manifest) { + <<-EOS + include '::journald' + EOS + } + + context 'with defaults' do + + # Using puppet_apply as a helper + it 'should work with no errors' do + apply_manifest(manifest, :catch_failures => true) + end + + it 'should be idempotent' do + apply_manifest(manifest, {:catch_changes => true}) + end + + describe service('systemd-journald') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + end +end + diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 429d046..3b692c1 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -2,13 +2,30 @@ describe 'journald' do on_supported_os.each do |os, facts| + let(:facts) do + facts + end context "with defaults on #{os}" do - let(:facts) do - facts.merge({:puppetmaster => 'localhost.localdomain'}) - end - let(:params) { { :options => {} } } it { should compile.with_all_deps } - it { should contain_class('journald') } + it { should contain_class('journald').with(options: + [ 'Storage' => 'auto', + 'Compress' => 'yes', + 'Seal' => 'yes', + 'SplitMode' => 'login', + 'SyncIntervalSec' => '5m', + 'RateLimitInterval' => '30s', + 'RateLimitBurst' => '10000', + 'MaxFileSec' => '1month', + 'ForwardToSyslog' => 'yes', + 'ForwardToKMsg' => 'yes', + 'ForwardToConsole' => 'no', + 'TTYPath' => '/dev/console', + 'MaxLevelStore' => 'debug', + 'MaxLevelSyslog' => 'debug', + 'MaxLevelKMsg' => 'notice', + 'MaxLevelConsole' => 'info'] + ) + } end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2bd4b3a..f2014d0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,154 @@ -require 'rubygems' - require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -include RspecPuppetFacts +require 'rspec-puppet' +require 'simp/rspec-puppet-facts' +include Simp::RspecPuppetFacts + +require 'pathname' + +# RSpec Material +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) +module_name = File.basename(File.expand_path(File.join(__FILE__,'../..'))) + +# Add fixture lib dirs to LOAD_PATH. Work-around for PUP-3336 +if Puppet.version < "4.0.0" + Dir["#{fixture_path}/modules/*/lib"].entries.each do |lib_dir| + $LOAD_PATH << lib_dir + end +end + + +if !ENV.key?( 'TRUSTED_NODE_DATA' ) + warn '== WARNING: TRUSTED_NODE_DATA is unset, using TRUSTED_NODE_DATA=yes' + ENV['TRUSTED_NODE_DATA']='yes' +end + +default_hiera_config =<<-EOM +--- +:backends: + - "yaml" +:yaml: + :datadir: "stub" +:hierarchy: + - "%{custom_hiera}" + - "%{module_name}" + - "default" +EOM + +# This can be used from inside your spec tests to set the testable environment. +# You can use this to stub out an ENC. +# +# Example: +# +# context 'in the :foo environment' do +# let(:environment){:foo} +# ... +# end +# +def set_environment(environment = :production) + RSpec.configure { |c| c.default_facts['environment'] = environment.to_s } +end + +# This can be used from inside your spec tests to load custom hieradata within +# any context. +# +# Example: +# +# describe 'some::class' do +# context 'with version 10' do +# let(:hieradata){ "#{class_name}_v10" } +# ... +# end +# end +# +# Then, create a YAML file at spec/fixtures/hieradata/some__class_v10.yaml. +# +# Hiera will use this file as it's base of information stacked on top of +# 'default.yaml' and .yaml per the defaults above. +# +# Note: Any colons (:) are replaced with underscores (_) in the class name. +def set_hieradata(hieradata) + RSpec.configure { |c| c.default_facts['custom_hiera'] = hieradata } +end + +if not File.directory?(File.join(fixture_path,'hieradata')) then + FileUtils.mkdir_p(File.join(fixture_path,'hieradata')) +end + +if not File.directory?(File.join(fixture_path,'modules',module_name)) then + FileUtils.mkdir_p(File.join(fixture_path,'modules',module_name)) +end + +RSpec.configure do |c| + # If nothing else... + c.default_facts = { + :production => { + #:fqdn => 'production.rspec.test.localdomain', + :path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin', + :concat_basedir => '/tmp' + } + } + + c.mock_framework = :rspec + c.mock_with :mocha + + c.module_path = File.join(fixture_path, 'modules') + c.manifest_dir = File.join(fixture_path, 'manifests') + + c.hiera_config = File.join(fixture_path,'hieradata','hiera.yaml') + + # Useless backtrace noise + backtrace_exclusion_patterns = [ + /spec_helper/, + /gems/ + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns + end + + c.before(:all) do + data = YAML.load(default_hiera_config) + data[:yaml][:datadir] = File.join(fixture_path, 'hieradata') + + File.open(c.hiera_config, 'w') do |f| + f.write data.to_yaml + end + end + + c.before(:each) do + @spec_global_env_temp = Dir.mktmpdir('simpspec') + + if defined?(environment) + set_environment(environment) + FileUtils.mkdir_p(File.join(@spec_global_env_temp,environment.to_s)) + end + + # ensure the user running these tests has an accessible environmentpath + Puppet[:environmentpath] = @spec_global_env_temp + Puppet[:user] = Etc.getpwuid(Process.uid).name + Puppet[:group] = Etc.getgrgid(Process.gid).name + + # sanitize hieradata + if defined?(hieradata) + set_hieradata(hieradata.gsub(':','_')) + elsif defined?(class_name) + set_hieradata(class_name.gsub(':','_')) + end + end + + c.after(:each) do + # clean up the mocked environmentpath + FileUtils.rm_rf(@spec_global_env_temp) + @spec_global_env_temp = nil + end +end -RSpec.configure do |config| - config.mock_with :rspec do |c| - c.syntax = :expect +Dir.glob("#{RSpec.configuration.module_path}/*").each do |dir| + begin + Pathname.new(dir).realpath + rescue + fail "ERROR: The module '#{dir}' is not installed. Tests cannot continue." end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..c6d2148 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,53 @@ +require 'beaker-rspec' +require 'tmpdir' +require 'yaml' +require 'simp/beaker_helpers' +include Simp::BeakerHelpers + +unless ENV['BEAKER_provision'] == 'no' + hosts.each do |host| + # Install Puppet + if host.is_pe? + install_pe + else + install_puppet + end + end +end + + +RSpec.configure do |c| + # ensure that environment OS is ready on each host + fix_errata_on hosts + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + begin + # Install modules and dependencies from spec/fixtures/modules + copy_fixture_modules_to( hosts ) + begin + server = only_host_with_role(hosts, 'server') + rescue ArgumentError =>e + server = only_host_with_role(hosts, 'default') + end + + # Generate and install PKI certificates on each SUT + Dir.mktmpdir do |cert_dir| + run_fake_pki_ca_on(server, hosts, cert_dir ) + hosts.each{ |sut| copy_pki_to( sut, cert_dir, '/etc/pki/simp-testing' )} + end + + # add PKI keys + copy_keydist_to(server) + rescue StandardError, ScriptError => e + if ENV['PRY'] + require 'pry'; binding.pry + else + raise e + end + end + end +end diff --git a/tests/init.pp b/tests/init.pp deleted file mode 100644 index 578823a..0000000 --- a/tests/init.pp +++ /dev/null @@ -1 +0,0 @@ -include ::journald