diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 12ed4ff109624ca4b2696bdfa6638dcf8967fcbe..0000000000000000000000000000000000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM puppet/pdk:latest - -# [Optional] Uncomment this section to install additional packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends <your-package-list-here> - diff --git a/.devcontainer/README.md b/.devcontainer/README.md deleted file mode 100644 index a719361689897b67e53c12da1c50e68c5b8c7dc8..0000000000000000000000000000000000000000 --- a/.devcontainer/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# devcontainer - - -For format details, see https://aka.ms/devcontainer.json. - -For config options, see the README at: -https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet - -``` json -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ], - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pdk --version", -} -``` - - - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index fe7a8b12b998dab13c95cce183eec95e387ae6bc..0000000000000000000000000000000000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/.gitignore b/.gitignore index 988dcbbe627164747384a785867e442b781e9001..88b73b3647b69b149f784f7314b2a0526b2bcda4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.devcontainer/ +.vscode/ +.yardopts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6d5e786c6bec6bec6ddf91c1a909f6a89e3b9e74..72818c1b2ba5d2f9ee591cebdac808a084399d3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ stages: - syntax - unit + - acceptance default: cache: @@ -19,35 +20,57 @@ default: - bundle -v - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) -validate lint check rubocop-Ruby 2.5.7-Puppet ~> 6: +validate lint check rubocop-Ruby 2.7.5-Puppet ~> 7: stage: syntax - image: ruby:2.5.7 + image: ruby:2.7.5 script: - - bundle exec rake validate lint check rubocop + - bundle exec rake validate lint check rubocop variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.5.7-Puppet ~> 6: + PUPPET_GEM_VERSION: "~> 7" +parallel_spec-Ruby 2.7.5-Puppet ~> 6: stage: unit - image: ruby:2.5.7 + image: ruby:2.7.5 script: - - bundle exec rake parallel_spec + - bundle exec rake parallel_spec variables: - PUPPET_GEM_VERSION: '~> 6' - -validate lint check rubocop-Ruby 2.7.2-Puppet ~> 7: - stage: syntax - image: ruby:2.7.2 + PUPPET_GEM_VERSION: "~> 6" +parallel_spec-Ruby 2.7.5-Puppet ~> 7: + stage: unit + image: ruby:2.7.5 script: - - bundle exec rake validate lint check rubocop + - bundle exec rake parallel_spec variables: - PUPPET_GEM_VERSION: '~> 7' - -parallel_spec-Ruby 2.7.2-Puppet ~> 7: - stage: unit - image: ruby:2.7.2 + PUPPET_GEM_VERSION: "~> 7" +acceptance with puppet6 ubuntu2004: + needs: + - parallel_spec-Ruby 2.7.5-Puppet ~> 6 + stage: acceptance + variables: + RBENV_VERSION: 2.7.5 + PUPPET_INSTALL_TYPE: agent + BEAKER_IS_PE: 'no' + BEAKER_PUPPET_COLLECTION: puppet6 + BEAKER_debug: 'true' + BEAKER_setfile: ubuntu2004-64 + BEAKER_HYPERVISOR: docker script: - - bundle exec rake parallel_spec + - bundle exec rake beaker + tags: + - puppet-tests +acceptance with puppet7 ubuntu2004: + needs: + - parallel_spec-Ruby 2.7.5-Puppet ~> 7 + stage: acceptance variables: - PUPPET_GEM_VERSION: '~> 7' + RBENV_VERSION: 2.7.5 + PUPPET_INSTALL_TYPE: agent + BEAKER_IS_PE: 'no' + BEAKER_PUPPET_COLLECTION: puppet7 + BEAKER_debug: 'true' + BEAKER_setfile: ubuntu2004-64 + BEAKER_HYPERVISOR: docker + script: + - bundle exec rake beaker + tags: + - puppet-tests diff --git a/.sync.yml b/.sync.yml index 2fbf0ffd710189ce2905acb59a57eba453b1b9f9..b9deeee4f26d50904e99f76ac4285b8e9db7ce01 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1 +1,94 @@ ---- {} +--- +.travis.yml: + delete: true +appveyor.yml: + delete: true +.gitignore: + paths: + - .devcontainer/ + - .vscode/ + - .yardopts + +.gitlab-ci.yml: + override: true + custom: + cache: + paths: + - vendor/bundle + bundler_args: '--without system_tests --path vendor/bundle --jobs $(nproc)' + custom_stages: + - syntax + - unit + - acceptance + custom_jobs: + validate lint check rubocop-Ruby 2.7.5-Puppet ~> 7: + stage: syntax + image: ruby:2.7.5 + script: + - bundle exec rake validate lint check rubocop + variables: + PUPPET_GEM_VERSION: '~> 7' + parallel_spec-Ruby 2.7.5-Puppet ~> 6: + stage: unit + image: ruby:2.7.5 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 6' + parallel_spec-Ruby 2.7.5-Puppet ~> 7: + stage: unit + image: ruby:2.7.5 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 7' + + acceptance with puppet6 ubuntu2004: + needs: + - parallel_spec-Ruby 2.7.5-Puppet ~> 6 + stage: acceptance + variables: + RBENV_VERSION: '2.7.5' + PUPPET_INSTALL_TYPE: 'agent' + BEAKER_IS_PE: 'no' + BEAKER_PUPPET_COLLECTION: 'puppet6' + BEAKER_debug: 'true' + BEAKER_setfile: 'ubuntu2004-64' + BEAKER_HYPERVISOR: 'docker' + script: + - bundle exec rake beaker + tags: + - puppet-tests + acceptance with puppet7 ubuntu2004: + needs: + - parallel_spec-Ruby 2.7.5-Puppet ~> 7 + stage: acceptance + variables: + RBENV_VERSION: '2.7.5' + PUPPET_INSTALL_TYPE: 'agent' + BEAKER_IS_PE: 'no' + BEAKER_PUPPET_COLLECTION: 'puppet7' + BEAKER_debug: 'true' + BEAKER_setfile: 'ubuntu2004-64' + BEAKER_HYPERVISOR: 'docker' + script: + - bundle exec rake beaker + tags: + - puppet-tests + +Gemfile: + required: + ':development': + - gem: 'beaker-rspec' + - gem: 'beaker-puppet' + - gem: 'beaker-docker' + - gem: 'beaker-puppet_install_helper' + - gem: 'beaker-module_install_helper' + - gem: 'pdk' + version: '<= 2.5.0' + - gem: 'puppet-strings' + version: '<= 2.8.0' + + +spec/spec_helper.rb: + mock_with: ':rspec' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 444e17acff58b014521a979b9e8034a9220a6988..0000000000000000000000000000000000000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -os: linux -dist: xenial -language: ruby -cache: bundler -before_install: - - bundle -v - - rm -f Gemfile.lock - - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" - - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - - gem --version - - bundle -v -script: - - 'bundle exec rake $CHECK' -bundler_args: --without system_tests -rvm: - - 2.5.7 -stages: - - static - - spec - - acceptance - - - if: tag =~ ^v\d - name: deploy -jobs: - fast_finish: true - include: - - - env: CHECK="validate lint check rubocop" - stage: static - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.7 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy -branches: - only: - - main - - /^v\d/ -notifications: - email: false diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 2f1e4f73a56f0d7cec69242da71c204461ceeee5..0000000000000000000000000000000000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recommendations": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 29c933bcf15d56c2583bbfafabc88093ffa1da68..0000000000000000000000000000000000000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ ---markup markdown diff --git a/Gemfile b/Gemfile index fc28658599631b7120cffbab087dfa5c030e418e..f16e6e4c840596d7940d211efffa995ddc7dada7 100644 --- a/Gemfile +++ b/Gemfile @@ -25,6 +25,13 @@ group :development do gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "voxpupuli-puppet-lint-plugins", '>= 3.0', require: false + gem "beaker-rspec", require: false + gem "beaker-puppet", require: false + gem "beaker-docker", require: false + gem "beaker-puppet_install_helper", require: false + gem "beaker-module_install_helper", require: false + gem "pdk", '<= 2.5.0', require: false + gem "puppet-strings", '<= 2.8.0', require: false end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a70c01eb9872d5d4a2c1974f55b9d0af08f5e62b..0000000000000000000000000000000000000000 --- a/appveyor.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -version: 1.1.x.{build} -skip_branch_with_pr: true -branches: - only: - - main - - release -skip_commits: - message: /^\(?doc\)?.*/ -clone_depth: 10 -init: - - SET - - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' -environment: - matrix: - - - RUBY_VERSION: 25-x64 - CHECK: validate lint check rubocop - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25-x64 - CHECK: parallel_spec -matrix: - fast_finish: true -install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 --without system_tests - - type Gemfile.lock -build: off -test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake %CHECK% -notifications: - - provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false diff --git a/manifests/goose.pp b/manifests/goose.pp index 683f94f1b2041c16ebad4ae2156aec84aaa7cb95..80162a6b9cbfe083df24d41abd327773eb18d9c1 100644 --- a/manifests/goose.pp +++ b/manifests/goose.pp @@ -17,7 +17,8 @@ class cfssl::goose { command => '/usr/local/bin/go get bitbucket.org/liamstask/goose/cmd/goose', creates => "/home/${cfssl::sysuser}/go/bin/goose", user => $cfssl::sysuser, - environment => ["HOME=/home/${cfssl::sysuser}/"], + environment => ["HOME=/home/${cfssl::sysuser}"], + cwd => '/tmp', require => User[$cfssl::sysuser], } } diff --git a/manifests/init.pp b/manifests/init.pp index 537babf92eac6493384a515175fd377ccba17700..daa922f02af7bce00ce52db02bdb3626fd828f73 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -8,7 +8,7 @@ class cfssl ( Hash $rootca_manifest = {}, Stdlib::HTTPSUrl $downloadurl = 'https://github.com/cloudflare/cfssl/releases/download', String[1] $version = '1.6.3', - String[1] $downloadchecksum = '824ff707e54611e8911210a5e8e1afbf745bba1dab55babdeb1a39d85b2f8c10', + String[1] $downloadchecksum = '16b42bfc592dc4d0ba1e51304f466cae7257edec13743384caf4106195ab6047', Enum['md5', 'sha1', 'sha2','sha256', 'sha384', 'sha512'] $checksum_type = 'sha256', String[1] $sysuser = 'cfssl', String[1] $sysgroup = 'cfssl', @@ -43,12 +43,12 @@ class cfssl ( gid => $sysgroup, } - archive::download { "${binpath}/cfssl" : - ensure => present, - url => "${downloadurl}/v${version}/cfssl_${version}_linux_amd64", - checksum => true, - digest_type => $checksum_type, - digest_string => $downloadchecksum, + archive { "${binpath}/cfssl" : + ensure => present, + source => "${downloadurl}/v${version}/cfssl_${version}_linux_amd64", + checksum_verify => true, + checksum_type => $checksum_type, + checksum => $downloadchecksum, } -> file { "${binpath}/cfssl" : ensure => file, @@ -61,12 +61,13 @@ class cfssl ( $_binaries.each | String $_bin | { $_archiveurn = "v${version}/${_bin}_${version}_linux_amd64" - archive::download { "${binpath}/${_bin}" : - ensure => present, - url => "${downloadurl}/${_archiveurn}", - subscribe => Archive::Download["${binpath}/cfssl"], + archive { "${binpath}/${_bin}" : + ensure => present, + source => "${downloadurl}/${_archiveurn}", + checksum_verify => false, + subscribe => Archive["${binpath}/cfssl"], } - ~> file { "${binpath}/${_bin}" : + -> file { "${binpath}/${_bin}" : ensure => file, mode => '0700', owner => $sysuser, @@ -136,8 +137,8 @@ class cfssl ( require => [ File[$cfssl::confdir], File["${cfssl::confdir}/ca"], - Archive::Download["${binpath}/cfssl"], - Archive::Download["${binpath}/cfssljson"], + Archive["${binpath}/cfssl"], + Archive["${binpath}/cfssljson"], ], } @@ -152,14 +153,14 @@ class cfssl ( ensure => 'running', enable => true, require => [ - Archive::Download["${binpath}/cfssl"], + Archive["${binpath}/cfssl"], Postgresql::Server::Db[$dbname], Exec['goose pg up'], File["${confdir}/${_serve_config_json}"], File["${confdir}/${_db_config_json}"], Class['cfssl::ca::root'], ], - subscribe => Archive::Download["${binpath}/cfssl"], + subscribe => Archive["${binpath}/cfssl"], provider => 'systemd', } } diff --git a/metadata.json b/metadata.json index 00fd7dcf0ae9594417957490547d33c863b77f8b..ce4a3a96005254743a6300addbf8b5e0f62e454f 100644 --- a/metadata.json +++ b/metadata.json @@ -6,19 +6,28 @@ "license": "AGPL-3.0", "source": "", "dependencies": [ - - ], - "operatingsystem_support": [ { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "10" - ] + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.17.0 < 9.0.0" + }, + { + "name": "puppetlabs/vcsrepo", + "version_requirement": ">= 5.0.0 < 6.0.0" }, + { + "name": "puppet/archive", + "version_requirement": ">= 4.0.0 < 7.0.0" + }, + { + "name": "puppetlabs/postgresql", + "version_requirement": ">= 6.1.0 < 9.0.0" + } + ], + "operatingsystem_support": [ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "18.04" + "20.04" ] } ], diff --git a/spec/acceptance/cfssl_spec.rb b/spec/acceptance/cfssl_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..86ad2d9c71605663853d49ebfb848e5bd59d1612 --- /dev/null +++ b/spec/acceptance/cfssl_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper_acceptance' + +describe 'cfssl' do + context 'with defaults' do + pp = %( + include cfssl + ) + + it 'applies without error' do + apply_manifest(pp, catch_failures: true) + end + it 'applies idempotently' do + apply_manifest(pp, catch_changes: true) + end + + describe port(8080) do + it { is_expected.to be_listening.on('127.0.0.1').with('tcp') } + end + + describe command('curl -s -d "{}" -H "Content-Type: application/json" -X POST 127.0.0.1:8080/api/v1/cfssl/info') do + its(:stdout) { is_expected.to match %r{BEGIN CERTIFICATE} } + end + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000000000000000000000000000000000..1064aeb3769eb223c6b634aba31938ba93cfa159 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,20 @@ +require 'beaker-rspec' +require 'beaker-puppet' +require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' + +run_puppet_install_helper +install_module_on(hosts) +install_module_dependencies_on(hosts) + +RSpec.configure do |c| + # Configure all nodes in nodeset + c.before :suite do + # vcsrepo expect git already installed + # curl is used during tests to interact with CA + pp_prepare_sut = %( + package { ['git','curl']: ensure => present } + ) + apply_manifest(pp_prepare_sut, catch_failures: true) + end +end