From 61688866284e84b532a1d8dae465042a3d0ae8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 9 Feb 2022 08:37:37 -1000 Subject: [PATCH 01/23] Prepare for PDK update Sync from the puppetlabs-apt module for settings related to GitHub actions support and other CI "deprecation". --- .sync.yml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/.sync.yml b/.sync.yml index c6ff6c37..22edd120 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,14 +1,28 @@ +--- +".gitlab-ci.yml": + delete: true +appveyor.yml: + delete: true Gemfile: required: ':system_tests': - - gem: 'puppet-module-posix-system-r#{minor_version}' - platforms: ruby - - gem: 'puppet-module-win-system-r#{minor_version}' - platforms: - - mswin - - mingw - - x64_mingw - gem: 'nokogiri' platforms: ruby - gem: 'serverspec' platforms: ruby +spec/spec_helper.rb: + mock_with: ":rspec" + coverage_report: true +.github/workflows/pr_test.yml: + unmanaged: false +.github/workflows/nightly.yml: + unmanaged: false +.github/workflows/spec.yml: + checks: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop' + unmanaged: false +.github/workflows/release.yml: + unmanaged: false +.github/workflows/auto_release.yml: + unmanaged: false +.travis.yml: + delete: true From 1791e0986a0668dac8a6f325c8b35ee64a0cdfa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 9 Feb 2022 08:39:39 -1000 Subject: [PATCH 02/23] pdk update --template-ref 2.4.0 --- .devcontainer/Dockerfile | 6 + .devcontainer/README.md | 34 +++ .devcontainer/devcontainer.json | 17 ++ .github/workflows/auto_release.yml | 90 ++++++ .github/workflows/nightly.yml | 204 ++++++++++++++ .github/workflows/pr_test.yml | 185 +++++++++++++ .github/workflows/release.yml | 47 ++++ .github/workflows/spec.yml | 126 +++++++++ .gitignore | 1 + .pdkignore | 5 + .rubocop.yml | 424 +++++++++++++++++++++++++++-- .travis.yml | 53 ---- Gemfile | 32 +-- Rakefile | 15 +- metadata.json | 6 +- spec/spec_helper.rb | 17 ++ 16 files changed, 1155 insertions(+), 107 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/README.md create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/auto_release.yml create mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/pr_test.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/spec.yml delete mode 100644 .travis.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..12ed4ff1 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +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 + diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000..cc4675e5 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,34 @@ +# 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.shell.linux": "/bin/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 new file mode 100644 index 00000000..fe7a8b12 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + "settings": { + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + } + } + }, + + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/.github/workflows/auto_release.yml b/.github/workflows/auto_release.yml new file mode 100644 index 00000000..f4aed440 --- /dev/null +++ b/.github/workflows/auto_release.yml @@ -0,0 +1,90 @@ +name: "Auto release" + +on: + workflow_dispatch: + +env: + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + auto_release: + name: "Automatic release prep" + runs-on: ubuntu-20.04 + + steps: + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: start first step" + run: | + echo STEP_ID="auto-release" >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: "Checkout Source" + if: ${{ github.repository_owner == 'puppetlabs' }} + uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: "PDK Release prep" + uses: docker://puppet/iac_release:ci + with: + args: 'release prep --force' + env: + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Get Version" + if: ${{ github.repository_owner == 'puppetlabs' }} + id: gv + run: | + echo "::set-output name=ver::$(jq --raw-output .version metadata.json)" + + - name: "Check if a release is necessary" + if: ${{ github.repository_owner == 'puppetlabs' }} + id: check + run: | + git diff --quiet CHANGELOG.md && echo "::set-output name=release::false" || echo "::set-output name=release::true" + + - name: "Commit changes" + if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }} + run: | + git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com" + git config --local user.name "GitHub Action" + git add . + git commit -m "Release prep v${{ steps.gv.outputs.ver }}" + + - name: Create Pull Request + id: cpr + uses: puppetlabs/peter-evans-create-pull-request@v3 + if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Release prep v${{ steps.gv.outputs.ver }}" + branch: "release-prep" + delete-branch: true + title: "Release prep v${{ steps.gv.outputs.ver }}" + body: | + Automated release-prep through [pdk-templates](https://github.com/puppetlabs/pdk-templates/blob/main/moduleroot/.github/workflows/auto_release.yml.erb) from commit ${{ github.sha }}. + Please verify before merging: + - [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green + - [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests + - [ ] Ensure the [changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) version and [metadata](https://github.com/${{ github.repository }}/blob/release-prep/metadata.json) version match + labels: "maintenance" + + - name: PR outputs + if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + + - name: "Honeycomb: Record finish step" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Finished auto release workflow' diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 00000000..c8fe88a5 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,204 @@ +name: "nightly" + +on: + schedule: + - cron: '0 0 * * *' + + +env: + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + +jobs: + setup_matrix: + if: ${{ github.repository_owner == 'puppetlabs' }} + name: "Setup Test Matrix" + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.get-matrix.outputs.matrix }} + + steps: + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: Start first step" + run: | + echo STEP_ID=setup-environment >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Checkout Source + uses: actions/checkout@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + + - name: Activate Ruby 2.7 + uses: ruby/setup-ruby@v1 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + ruby-version: "2.7" + bundler-cache: true + + - name: Print bundle environment + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + - name: "Honeycomb: Record Setup Environment time" + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' + echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Setup Acceptance Test Matrix + id: get-matrix + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then + buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 + else + echo "::set-output name=matrix::{}" + fi + + - name: "Honeycomb: Record Setup Test Matrix time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' + Acceptance: + name: "${{matrix.platforms.label}}, ${{matrix.collection}}" + needs: + - setup_matrix + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} + + env: + BUILDEVENT_FILE: '../buildevents.txt' + + steps: + - run: | + echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE + echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE + echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE + + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }} + + - name: "Honeycomb: start first step" + run: | + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Checkout Source + uses: actions/checkout@v2 + + - name: Activate Ruby 2.7 + uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.7" + bundler-cache: true + + - name: Print bundle environment + run: | + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + - name: "Honeycomb: Record Setup Environment time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Provision test environment + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + echo ::group::=== INVENTORY === + if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; + then + FILE='spec/fixtures/litmus_inventory.yaml' + elif [ -f 'inventory.yaml' ]; + then + FILE='inventory.yaml' + fi + sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true + echo ::endgroup:: + + - name: Install agent + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' + + - name: Install module + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' + + - name: "Honeycomb: Record deployment times" + if: ${{ always() }} + run: | + echo ::group::honeycomb step + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + echo ::endgroup:: + + - name: Run acceptance tests + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' + + - name: "Honeycomb: Record acceptance testing times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Remove test environment + if: ${{ always() }} + continue-on-error: true + run: | + if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + fi + + - name: "Honeycomb: Record removal times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' + + slack-workflow-status: + if: ${{ github.repository_owner == 'puppetlabs' }} + name: Post Workflow Status To Slack + needs: + - Acceptance + runs-on: ubuntu-20.04 + steps: + - name: Slack Workflow Notification + uses: puppetlabs/Gamesight-slack-workflow-status@pdk-templates-v1 + with: + # Required Input + repo_token: ${{ secrets.GITHUB_TOKEN }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + # Optional Input + channel: '#team-ia-bots' + name: 'GABot' diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml new file mode 100644 index 00000000..fd310e65 --- /dev/null +++ b/.github/workflows/pr_test.yml @@ -0,0 +1,185 @@ +name: "PR Testing" + +on: [pull_request] + + +env: + + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + +jobs: + setup_matrix: + name: "Setup Test Matrix" + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.get-matrix.outputs.matrix }} + + steps: + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: Start first step" + run: | + echo STEP_ID=setup-environment >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Checkout Source + uses: actions/checkout@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + + - name: Activate Ruby 2.7 + uses: ruby/setup-ruby@v1 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + ruby-version: "2.7" + bundler-cache: true + + - name: Print bundle environment + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + - name: "Honeycomb: Record Setup Environment time" + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' + echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Run validation steps + run: | + bundle exec rake validate + if: ${{ github.repository_owner == 'puppetlabs' }} + + - name: Setup Acceptance Test Matrix + id: get-matrix + run: | + if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then + buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 + else + echo "::set-output name=matrix::{}" + fi + + - name: "Honeycomb: Record Setup Test Matrix time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' + Acceptance: + name: "${{matrix.platforms.label}}, ${{matrix.collection}}" + needs: + - setup_matrix + if: ${{ needs.setup_matrix.outputs.matrix != '{}' }} + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} + + env: + BUILDEVENT_FILE: '../buildevents.txt' + + steps: + - run: | + echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE + echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE + echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }} + + - name: "Honeycomb: start first step" + run: | + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Checkout Source + uses: actions/checkout@v2 + + - name: Activate Ruby 2.7 + uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.7" + bundler-cache: true + + - name: Print bundle environment + run: | + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + - name: "Honeycomb: Record Setup Environment time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Provision test environment + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + echo ::group::=== INVENTORY === + if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; + then + FILE='spec/fixtures/litmus_inventory.yaml' + elif [ -f 'inventory.yaml' ]; + then + FILE='inventory.yaml' + fi + sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true + echo ::endgroup:: + + - name: Install agent + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' + + - name: Install module + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' + + - name: "Honeycomb: Record deployment times" + if: ${{ always() }} + run: | + echo ::group::honeycomb step + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + echo ::endgroup:: + - name: Run acceptance tests + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' + + - name: "Honeycomb: Record acceptance testing times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' + echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Remove test environment + if: ${{ always() }} + continue-on-error: true + run: | + if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + fi + + - name: "Honeycomb: Record removal times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1509f6e9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: "Publish module" + +on: + workflow_dispatch: + +jobs: + create-github-release: + name: Deploy GitHub Release + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + clean: true + fetch-depth: 0 + - name: Get Version + id: gv + run: | + echo "::set-output name=ver::$(jq --raw-output .version metadata.json)" + - name: Create Release + uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "v${{ steps.gv.outputs.ver }}" + draft: false + prerelease: false + + deploy-forge: + name: Deploy to Forge + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + clean: true + - name: "PDK Build" + uses: docker://puppet/pdk:nightly + with: + args: 'build' + - name: "Push to Forge" + uses: docker://puppet/pdk:nightly + with: + args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force' diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml new file mode 100644 index 00000000..6c1ae10d --- /dev/null +++ b/.github/workflows/spec.yml @@ -0,0 +1,126 @@ +name: "Spec Tests" + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + pull_request: + + +env: + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + +jobs: + setup_matrix: + name: "Setup Test Matrix" + runs-on: ubuntu-20.04 + outputs: + spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }} + + steps: + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: Start first step" + run: | + echo STEP_ID=setup-environment >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Checkout Source + uses: actions/checkout@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + + - name: Activate Ruby 2.7 + uses: ruby/setup-ruby@v1 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + ruby-version: "2.7" + bundler-cache: true + + - name: Print bundle environment + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + - name: "Honeycomb: Record Setup Environment time" + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' + echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + - name: Run Static & Syntax Tests + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + buildevents cmd $TRACE_ID $STEP_ID 'static_syntax_checks' -- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + + - name: Setup Spec Test Matrix + id: get-matrix + run: | + if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then + buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 + else + echo "::set-output name=spec_matrix::{}" + fi + - name: "Honeycomb: Record Setup Test Matrix time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' + Spec: + name: "Spec Tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})" + needs: + - setup_matrix + if: ${{ needs.setup_matrix.outputs.spec_matrix != '{}' }} + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.setup_matrix.outputs.spec_matrix)}} + + env: + BUILDEVENT_FILE: '../buildevents.txt' + PUPPET_GEM_VERSION: ${{ matrix.puppet_version }} + FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' + + steps: + - run: | + echo "SANITIZED_PUPPET_VERSION=$(echo '${{ matrix.puppet_version }}' | sed 's/~> //g')" >> $GITHUB_ENV + + - run: | + echo 'puppet_version=${{ env.SANITIZED_PUPPET_VERSION }}' >> $BUILDEVENT_FILE + - name: "Honeycomb: Start first step" + run: | + echo "STEP_ID=${{ env.SANITIZED_PUPPET_VERSION }}-spec" >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + matrix-key: ${{ env.SANITIZED_PUPPET_VERSION }} + - name: Checkout Source + uses: actions/checkout@v2 + + - name: "Activate Ruby ${{ matrix.ruby_version }}" + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby_version}} + bundler-cache: true + + - name: Print bundle environment + run: | + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + + - name: Run parallel_spec tests + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake parallel_spec Puppet ${{ matrix.puppet_version }}, Ruby ${{ matrix.ruby_version }}' -- bundle exec rake parallel_spec diff --git a/.gitignore b/.gitignore index 2767022c..988dcbbe 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml diff --git a/.pdkignore b/.pdkignore index e6215cd0..c538bea8 100644 --- a/.pdkignore +++ b/.pdkignore @@ -25,13 +25,16 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml /appveyor.yml +/.editorconfig /.fixtures.yml /Gemfile /.gitattributes /.gitignore /.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec @@ -40,3 +43,5 @@ /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ diff --git a/.rubocop.yml b/.rubocop.yml index 5307849e..8f782e74 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,12 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.4' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,16 +18,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/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. @@ -36,14 +29,13 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb 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,7 +64,7 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma @@ -87,26 +79,170 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/InsecureProtocolSource: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Layout/EmptyComment: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -119,19 +255,265 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/CurrentPathExpectation: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/Capybara/VisibilityMatcher: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false Style/AsciiComments: Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NilLambda: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0aaaef2b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +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="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" - stage: static - - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.5 - stage: spec - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.7 - stage: spec - - - env: PUPPET_GEM_VERSION="~> 7.0" CHECK=parallel_spec - rvm: 2.7.2 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy -branches: - only: - - master - - /^v\d/ -notifications: - email: false diff --git a/Gemfile b/Gemfile index 0d3a975d..775a8aa8 100644 --- a/Gemfile +++ b/Gemfile @@ -17,23 +17,19 @@ 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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + 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] 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 "nokogiri", require: false, platforms: [:ruby] - gem "serverspec", require: false, platforms: [:ruby] + gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "nokogiri", require: false, platforms: [:ruby] + gem "serverspec", require: false, platforms: [:ruby] end puppet_version = ENV['PUPPET_GEM_VERSION'] @@ -50,16 +46,6 @@ gems['puppet'] = location_for(puppet_version) gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - gems.each do |gem_name, gem_params| gem gem_name, *gem_params end diff --git a/Rakefile b/Rakefile index cb7ed0cc..0f8754eb 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'bundler' 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' @@ -42,6 +43,7 @@ end PuppetLint.configuration.send('disable_relative') + if Bundler.rubygems.find_name('github_changelog_generator').any? GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? @@ -52,7 +54,7 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." config.add_pr_wo_labels = true config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", @@ -60,11 +62,11 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end @@ -72,16 +74,15 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/metadata.json b/metadata.json index 123f6890..d4d86cc6 100644 --- a/metadata.json +++ b/metadata.json @@ -82,7 +82,7 @@ } ], "description": "Module for installing/configuring PuppetDB", - "pdk-version": "1.18.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.18.0", - "template-ref": "tags/1.18.0-0-g095317c" + "pdk-version": "2.3.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#2.4.0", + "template-ref": "tags/2.4.0-0-gfa6b6d2" } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3778cac..07db7342 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -42,6 +46,19 @@ end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) + end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{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 end From f72d3d18c7a28fb42627fcb6b86197a0274f7c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 9 Feb 2022 08:46:54 -1000 Subject: [PATCH 03/23] Pet rubocop --- lib/puppet/util/puppetdb_validator.rb | 2 +- spec/acceptance/basic_spec.rb | 2 +- spec/spec_helper_acceptance.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/puppet/util/puppetdb_validator.rb b/lib/puppet/util/puppetdb_validator.rb index 8cd360d0..5cb966b7 100644 --- a/lib/puppet/util/puppetdb_validator.rb +++ b/lib/puppet/util/puppetdb_validator.rb @@ -63,6 +63,6 @@ def attempt_connection end rescue StandardError => e log_error(e.message) - return false + false end end diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index a17cb9c9..73b561cf 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -7,7 +7,7 @@ # No point diagnosing any more if the module wasn't copied properly shell('ls /etc/puppetlabs/code/modules/puppetdb') do |r| r.exit_code.should be_zero - r.stdout.should =~ %r{metadata\.json} + r.stdout.should include('metadata.json') r.stderr.should == '' end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 0b734325..7306fab6 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -60,7 +60,7 @@ def build_url(platform) end hosts.each do |host| - if host['platform'] =~ %r{debian} + if %r{debian}.match?(host['platform']) on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' end # install_puppet @@ -81,7 +81,7 @@ def build_url(platform) relver = Regexp.last_match(1) on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm" on host, 'yum install -y puppetserver' - elsif host['platform'] =~ %r{(ubuntu|debian)} + elsif %r{(ubuntu|debian)}.match?(host['platform']) unless host.check_for_package 'curl' on host, 'apt-get install -y curl' end @@ -121,7 +121,7 @@ def build_url(platform) 'puppet7' end install_puppet_agent_on(hosts, opts) unless ENV['BEAKER_provision'] == 'no' -install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i +install_ca_certs unless %r{pe}i.match?(ENV['PUPPET_INSTALL_TYPE']) install_module_on(hosts) install_module_dependencies_on(hosts) @@ -129,7 +129,7 @@ def build_url(platform) # Readable test descriptions c.formatter = :documentation hosts.each do |host| - if host[:platform] =~ %r{el-7-x86_64} && host[:hypervisor] =~ %r{docker} + if host[:platform].include('el-7-x86_64') && host[:hypervisor].include('docker') on(host, "sed -i '/nodocs/d' /etc/yum.conf") end end From 3e25635301c2ae9b90839c14ca42e218f8ffe638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 9 Feb 2022 09:52:47 -1000 Subject: [PATCH 04/23] Modernize/Fix CI --- spec/unit/util/puppetdb_validator_spec.rb | 69 +++++++++-------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/spec/unit/util/puppetdb_validator_spec.rb b/spec/unit/util/puppetdb_validator_spec.rb index c96cd801..47355f5a 100644 --- a/spec/unit/util/puppetdb_validator_spec.rb +++ b/spec/unit/util/puppetdb_validator_spec.rb @@ -8,51 +8,34 @@ url = '/pdb/meta/v1/version' if Puppet::PUPPETVERSION.to_f < 7 - conn_ok = stub - conn_ok.stubs(:get).with(url, 'Accept' => 'application/json').returns(nethttpok) - conn_ok.stubs(:read_timeout=).with(2) - conn_ok.stubs(:open_timeout=).with(2) + conn_ok = double + allow(conn_ok).to receive(:get).with(url, 'Accept' => 'application/json').and_return(nethttpok) + allow(conn_ok).to receive(:read_timeout=).with(2) + allow(conn_ok).to receive(:open_timeout=).with(2) - conn_not_found = stub - conn_not_found.stubs(:get).with('/pdb/meta/v1/version', 'Accept' => 'application/json').returns(notfound) + conn_not_found = double + allow(conn_not_found).to receive(:get).with('/pdb/meta/v1/version', 'Accept' => 'application/json').and_return(notfound) - Puppet::Network::HttpPool.stubs(:http_instance).raises('Unknown host') - Puppet::Network::HttpPool.stubs(:http_instance).with('mypuppetdb.com', 8080, true).raises('Connection refused') - Puppet::Network::HttpPool.stubs(:http_instance).with('mypuppetdb.com', 8080, false).returns(conn_ok) - Puppet::Network::HttpPool.stubs(:http_instance).with('mypuppetdb.com', 8081, true).returns(conn_ok) - Puppet::Network::HttpPool.stubs(:http_instance).with('wrongserver.com', 8081, true).returns(conn_not_found) + allow(Puppet::Network::HttpPool).to receive(:http_instance).and_raise('Unknown host') + allow(Puppet::Network::HttpPool).to receive(:http_instance).with('mypuppetdb.com', 8080, true).and_raise('Connection refused') + allow(Puppet::Network::HttpPool).to receive(:http_instance).with('mypuppetdb.com', 8080, false).and_return(conn_ok) + allow(Puppet::Network::HttpPool).to receive(:http_instance).with('mypuppetdb.com', 8081, true).and_return(conn_ok) + allow(Puppet::Network::HttpPool).to receive(:http_instance).with('wrongserver.com', 8081, true).and_return(conn_not_found) else - http = stub - Puppet::HTTP::Client.stubs(:new).returns(http) + http = double + allow(Puppet::HTTP::Client).to receive(:new).and_return(http) - http.stubs(:get).with { |uri, _opts| - uri.hostname == 'mypuppetdb.com' && - uri.port == 8080 && - uri.scheme == 'https' - }.raises Puppet::HTTP::HTTPError, 'Connection refused' + allow(http).to receive(:get) do |uri, _opts| + raise(Puppet::HTTP::HTTPError, 'Connection refused') if uri.hostname == 'mypuppetdb.com' && uri.port == 8080 && uri.scheme == 'https' + raise Puppet::HTTP::ResponseError, Puppet::HTTP::ResponseNetHTTP.new(url, notfound) if uri.hostname == 'wrongserver.com' && uri.port == 8081 && uri.scheme == 'https' + raise Puppet::HTTP::HTTPError, 'Unknown host' if uri.hostname == 'non-existing.com' && uri.scheme == 'https' - http.stubs(:get).with { |uri, _opts| - uri.hostname == 'mypuppetdb.com' && - uri.port == 8080 && - uri.scheme == 'http' - }.returns(Puppet::HTTP::ResponseNetHTTP.new(url, nethttpok)) - - http.stubs(:get).with { |uri, _opts| - uri.hostname == 'mypuppetdb.com' && - uri.port == 8081 && - uri.scheme == 'https' - }.returns(Puppet::HTTP::ResponseNetHTTP.new(url, nethttpok)) - - http.stubs(:get).with { |uri, _opts| - uri.hostname == 'wrongserver.com' && - uri.port == 8081 && - uri.scheme == 'https' - }.raises Puppet::HTTP::ResponseError, Puppet::HTTP::ResponseNetHTTP.new(url, notfound) - - http.stubs(:get).with { |uri, _opts| - uri.hostname == 'non-existing.com' && - uri.scheme == 'https' - }.raises Puppet::HTTP::HTTPError, 'Unknown host' + if uri.hostname == 'mypuppetdb.com' && uri.port == 8080 && uri.scheme == 'http' + Puppet::HTTP::ResponseNetHTTP.new(url, nethttpok) + elsif uri.hostname == 'mypuppetdb.com' && uri.port == 8081 && uri.scheme == 'https' + Puppet::HTTP::ResponseNetHTTP.new(url, nethttpok) + end + end end end @@ -70,7 +53,7 @@ puppetdb_server = 'mypuppetdb.com' puppetdb_port = 8080 validator = Puppet::Util::PuppetdbValidator.new(puppetdb_server, puppetdb_port) - Puppet.expects(:notice).with("Unable to connect to puppetdb server (https://#{puppetdb_server}:#{puppetdb_port}): Connection refused") + expect(Puppet).to receive(:notice).with("Unable to connect to puppetdb server (https://#{puppetdb_server}:#{puppetdb_port}): Connection refused") expect(validator.attempt_connection).to be false end @@ -78,7 +61,7 @@ puppetdb_server = 'wrongserver.com' puppetdb_port = 8081 validator = Puppet::Util::PuppetdbValidator.new(puppetdb_server, puppetdb_port) - Puppet.expects(:notice).with("Unable to connect to puppetdb server (https://#{puppetdb_server}:#{puppetdb_port}): [404] Not found") + expect(Puppet).to receive(:notice).with("Unable to connect to puppetdb server (https://#{puppetdb_server}:#{puppetdb_port}): [404] Not found") expect(validator.attempt_connection).to be false end @@ -86,7 +69,7 @@ puppetdb_server = 'non-existing.com' puppetdb_port = nil validator = Puppet::Util::PuppetdbValidator.new(puppetdb_server, puppetdb_port) - Puppet.expects(:notice).with("Unable to connect to puppetdb server (https://#{puppetdb_server}:#{puppetdb_port}): Unknown host") + expect(Puppet).to receive(:notice).with("Unable to connect to puppetdb server (https://#{puppetdb_server}:#{puppetdb_port}): Unknown host") expect(validator.attempt_connection).to be false end end From cd74f492d2e2e3dfb32337efd83b2072f11aed98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Fri, 11 Feb 2022 14:01:34 -1000 Subject: [PATCH 05/23] Fix acceptance tests to work with Litmus --- spec/acceptance/basic_spec.rb | 21 +++-- spec/spec_helper_acceptance.rb | 138 +-------------------------------- 2 files changed, 20 insertions(+), 139 deletions(-) diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 73b561cf..806e118a 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -1,17 +1,28 @@ -require 'beaker-puppet' -require 'beaker-pe' require 'spec_helper_acceptance' describe 'basic tests:' do it 'make sure we have copied the module across' do # No point diagnosing any more if the module wasn't copied properly - shell('ls /etc/puppetlabs/code/modules/puppetdb') do |r| + run_shell('ls /etc/puppetlabs/code/modules/puppetdb') do |r| r.exit_code.should be_zero r.stdout.should include('metadata.json') r.stderr.should == '' end end + describe 'setup puppetserver' do + pp = <<-EOS + package { 'puppetserver': ensure => installed, } -> + exec { '/opt/puppetlabs/bin/puppetserver ca setup': creates => '/etc/puppetlabs/puppetserver/ca/ca_crt.pem', } + service { 'puppetserver': ensure => running, enable => true, } + EOS + + it 'make sure it runs without error' do + apply_manifest(pp, catch_errors: true) + apply_manifest(pp, catch_changes: true) + end + end + describe 'single node setup' do pp = <<-EOS # Single node setup @@ -72,7 +83,7 @@ class { 'puppetdb::master::config': apply_manifest(pp, catch_errors: true) apply_manifest(pp, catch_changes: true) - shell('cat /etc/puppetlabs/puppet/puppet.conf') do |r| + run_shell('cat /etc/puppetlabs/puppet/puppet.conf') do |r| expect(r.stdout).to match(%r{^reports\s*=\s*([^,]+,)*puppetdb(,[^,]+)*$}) end end @@ -91,7 +102,7 @@ class { 'puppetdb::master::config': apply_manifest(pp, catch_errors: true) apply_manifest(pp, catch_changes: true) - shell('psql "postgresql://puppetdb-read:puppetdb-read@localhost/puppetdb" -c "create table tables(id int)" || true') do |r| + run_shell('psql "postgresql://puppetdb-read:puppetdb-read@localhost/puppetdb" -c "create table tables(id int)" || true') do |r| expect(r.stderr).to match(%r{^ERROR: permission denied for schema public.*}) end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 7306fab6..73a02388 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,136 +1,6 @@ -require 'beaker-rspec' -require 'beaker-puppet' -require 'beaker/puppet_install_helper' -require 'beaker/module_install_helper' +# frozen_string_literal: true -def use_puppet4? - (ENV['PUPPET_INSTALL_VERSION'] =~ %r{^2016}) ? true : false -end +require 'puppet_litmus' +PuppetLitmus.configure! -def use_puppet5? - (ENV['BEAKER_PUPPET_COLLECTION'] =~ %r{^puppet5}) ? true : false -end - -def use_puppet6? - (ENV['BEAKER_PUPPET_COLLECTION'] =~ %r{^puppet6}) ? true : false -end - -def use_puppet7? - (ENV['BEAKER_PUPPET_COLLECTION'] =~ %r{^puppet7}) ? true : false -end - -def build_url(platform) - if use_puppet4? - url4 = 'http://%{mngr}.puppetlabs.com/puppetlabs-release-pc1%{plat}' - case platform - when 'el' then url4 % { mngr: 'yum', plat: '-el-' } - when 'fedora' then url4 % { mngr: 'yum', plat: '-fedora-' } - when 'debian', 'ubuntu' then url4 % { mngr: 'apt', plat: '-' } - else - raise "build_url() called with unsupported platform '#{platform}'" - end - elsif use_puppet5? - url5 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet5-release%{plat}' - case platform - when 'el' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-el-' } - when 'fedora' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-fedora-' } - when 'debian', 'ubuntu' then url5 % { mngr: 'apt', dir: '', plat: '-' } - else - raise "build_url() called with unsupported platform '#{platform}'" - end - elsif use_puppet6? - url6 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet6-release%{plat}' - case platform - when 'el' then url6 % { mngr: 'yum', dir: 'puppet6/', plat: '-el-' } - when 'fedora' then url6 % { mngr: 'yum', dir: 'puppet6/', plat: '-fedora-' } - when 'debian', 'ubuntu' then url6 % { mngr: 'apt', dir: '', plat: '-' } - else - raise "build_url() called with unsupported platform '#{platform}'" - end - else - url7 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet7-release%{plat}' - case platform - when 'el' then url7 % { mngr: 'yum', dir: 'puppet7/', plat: '-el-' } - when 'fedora' then url7 % { mngr: 'yum', dir: 'puppet7/', plat: '-fedora-' } - when 'debian', 'ubuntu' then url7 % { mngr: 'apt', dir: '', plat: '-' } - else - raise "build_url() called with unsupported platform '#{platform}'" - end - end -end - -hosts.each do |host| - if %r{debian}.match?(host['platform']) - on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' - end - # install_puppet - if host['platform'] =~ %r{el-(5|6|7|8)} - relver = Regexp.last_match(1) - on host, "rpm -ivh #{build_url('el')}#{relver}.noarch.rpm" - on host, 'yum install -y puppetserver' - on host, '/opt/puppetlabs/bin/puppetserver ca setup' - - # TODO: we should probably be using the relatively new postgresql - # module settings manage_dnf_module on el8 when we are managing the postgresql - # database - if relver == '8' - on host, 'dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm' - on host, 'dnf -qy module disable postgresql' - end - elsif host['platform'] =~ %r{fedora-(\d+)} - relver = Regexp.last_match(1) - on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm" - on host, 'yum install -y puppetserver' - elsif %r{(ubuntu|debian)}.match?(host['platform']) - unless host.check_for_package 'curl' - on host, 'apt-get install -y curl' - end - # For openjdk8 - if host['platform'].version == '8' && !use_puppet4? - create_remote_file(host, - '/etc/apt/sources.list.d/jessie-backports.list', - 'deb https://artifactory.delivery.puppetlabs.net/artifactory/debian_archive__remote/ jessie-backports main') - on host, 'apt-get -y -m update' - install_package(host, 'openjdk-8-jre-headless') - end - on host, 'apt-get install apt-transport-https --assume-yes' - on host, "curl -O #{build_url('debian')}$(lsb_release -c -s).deb" - if use_puppet4? - on host, 'dpkg -i puppetlabs-release-pc1-$(lsb_release -c -s).deb' - elsif use_puppet5? - on host, 'dpkg -i puppet5-release-$(lsb_release -c -s).deb' - elsif use_puppet6? - on host, 'dpkg -i puppet6-release-$(lsb_release -c -s).deb' - else - on host, 'dpkg -i puppet7-release-$(lsb_release -c -s).deb' - end - on host, 'apt-get -y -m update' - on host, 'apt-get install -y puppetserver' - on host, '/opt/puppetlabs/bin/puppetserver ca setup' - else - raise "install_puppet() called for unsupported platform '#{host['platform']}' on '#{host.name}'" - end -end - -opts = { puppet_agent_version: 'latest' } -opts[:puppet_collection] = if use_puppet5? - 'puppet5' - elsif use_puppet6? - 'puppet6' - elsif use_puppet7? - 'puppet7' - end -install_puppet_agent_on(hosts, opts) unless ENV['BEAKER_provision'] == 'no' -install_ca_certs unless %r{pe}i.match?(ENV['PUPPET_INSTALL_TYPE']) -install_module_on(hosts) -install_module_dependencies_on(hosts) - -RSpec.configure do |c| - # Readable test descriptions - c.formatter = :documentation - hosts.each do |host| - if host[:platform].include('el-7-x86_64') && host[:hypervisor].include('docker') - on(host, "sed -i '/nodocs/d' /etc/yum.conf") - end - end -end +require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) From 8eabcccf2241934be73eb6dbcd50ebbc9126274f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sat, 12 Feb 2022 17:32:10 -1000 Subject: [PATCH 06/23] Fix installation path of puppet modules --- spec/acceptance/basic_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 806e118a..615db3a7 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -3,7 +3,7 @@ describe 'basic tests:' do it 'make sure we have copied the module across' do # No point diagnosing any more if the module wasn't copied properly - run_shell('ls /etc/puppetlabs/code/modules/puppetdb') do |r| + run_shell('ls /etc/puppetlabs/code/environments/production/modules/puppetdb') do |r| r.exit_code.should be_zero r.stdout.should include('metadata.json') r.stderr.should == '' From aeecff2f65917e36f2d4db49f111f8784826e922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sat, 12 Feb 2022 17:18:48 -1000 Subject: [PATCH 07/23] Ignore messages from ls(1) on stderr We are interested in the list of all installed modules, we do not care about messages on stderr like: ``` bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.UTF-8) ``` --- spec/acceptance/basic_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 615db3a7..dcd63321 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -6,7 +6,6 @@ run_shell('ls /etc/puppetlabs/code/environments/production/modules/puppetdb') do |r| r.exit_code.should be_zero r.stdout.should include('metadata.json') - r.stderr.should == '' end end From ae31048826cb22fb3e7807a70e089117df09757d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sat, 12 Feb 2022 17:17:39 -1000 Subject: [PATCH 08/23] Conditionaly include postgresql::server::contrib We need the contrib packages only with older versions of PostgreSQL. While here include this class when it is needed instead of using a resource to avoid conflicts when another module wants to do this. --- manifests/database/postgresql.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index 62da6464..eddc10f2 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -60,7 +60,9 @@ if $manage_database { # get the pg contrib to use pg_trgm extension - class { '::postgresql::server::contrib': } + if (versioncmp($postgres_version, '10') < 0) { + include postgresql::server::contrib + } postgresql::server::extension { 'pg_trgm': database => $database_name, From 00c4580c8326464aed0820eee8ea201799a572fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sat, 12 Feb 2022 17:19:48 -1000 Subject: [PATCH 09/23] Mark broken tests as pending PostgreSQL is configured to use snakeoil certificates, but PuppetDB expect to use the Puppet certificates to authenticate with needs more code that we currently have in the tests. --- spec/acceptance/basic_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index dcd63321..318b7db6 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -43,6 +43,7 @@ class { 'puppetdb': postgresql_ssl_on => true, EOS it 'make sure it runs without error' do + pending('By default postgresql use snakeoil certs and puppetdb puppetserver ones') apply_manifest(ssl_config, catch_errors: true) apply_manifest(ssl_config, catch_changes: true) end @@ -62,6 +63,7 @@ class { 'puppetdb': postgresql_ssl_on => true, } EOS it 'make sure it starts with wrong password' do + pending('By default postgresql use snakeoil certs and puppetdb puppetserver ones') apply_manifest(change_password, catch_errors: true) apply_manifest(change_password, catch_changes: true) end From c6587028d6c04350e304dff4452c171eea85f76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 27 Oct 2022 11:31:14 -1000 Subject: [PATCH 10/23] Add missing dependency the provision module was not found in /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/spec/fixtures/modules, please amend the .fixtures.yml file /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/puppet_litmus-0.34.3/lib/puppet_litmus/rake_helper.rb:121:in `provision' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/puppet_litmus-0.34.3/lib/puppet_litmus/rake_tasks.rb:81:in `block (2 levels) in ' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rake.rb:21:in `block in execute' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/client.rb:65:in `start_span' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rake.rb:16:in `execute' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `' /opt/hostedtoolcache/Ruby/2.7.6/x64/bin/bundle:23:in `load' /opt/hostedtoolcache/Ruby/2.7.6/x64/bin/bundle:23:in `
' --- .fixtures.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 34bf88cd..d8f068fe 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -10,6 +10,15 @@ fixtures: file_concat: 'https://github.com/electrical/puppet-lib-file_concat.git' systemd: 'https://github.com/camptocamp/puppet-systemd.git' cron: 'https://github.com/voxpupuli/puppet-cron.git' - cron_core: 'https://github.com/puppetlabs/puppetlabs-cron_core.git' - yumrepo_core: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core.git' - augeas_core: 'https://github.com/puppetlabs/puppetlabs-augeas_core.git' + provision: 'https://github.com/puppetlabs/provision.git' + cron_core: + repo: https://github.com/puppetlabs/puppetlabs-cron_core.git + puppet_version: ">= 6.0.0" + yumrepo_core: + repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git + puppet_version: ">= 6.0.0" + augeas_core: + repo: https://github.com/puppetlabs/puppetlabs-augeas_core.git + puppet_version: ">= 6.0.0" + symlinks: + puppetdb: '#{source_dir}' From 8a09ec375175119a6d96df01ebab66b940b9675f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 27 Oct 2022 11:36:26 -1000 Subject: [PATCH 11/23] Add missing dependency puppet_agent was not found in /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/spec/fixtures/modules, please amend the .fixtures.yml file /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/puppet_litmus-0.34.3/lib/puppet_litmus/rake_helper.rb:221:in `block in install_agent' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/client.rb:65:in `start_span' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/forwardable-1.3.2/lib/forwardable.rb:238:in `start_span' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/puppet_litmus-0.34.3/lib/puppet_litmus/rake_helper.rb:210:in `install_agent' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/puppet_litmus-0.34.3/lib/puppet_litmus/rake_tasks.rb:126:in `block (2 levels) in ' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rake.rb:21:in `block in execute' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/client.rb:65:in `start_span' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/honeycomb-beeline-2.11.0/lib/honeycomb/integrations/rake.rb:16:in `execute' /home/runner/work/puppetlabs-puppetdb/puppetlabs-puppetdb/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `' /opt/hostedtoolcache/Ruby/2.7.6/x64/bin/bundle:23:in `load' /opt/hostedtoolcache/Ruby/2.7.6/x64/bin/bundle:23:in `
' --- .fixtures.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.fixtures.yml b/.fixtures.yml index d8f068fe..ff7bfb2c 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -11,6 +11,7 @@ fixtures: systemd: 'https://github.com/camptocamp/puppet-systemd.git' cron: 'https://github.com/voxpupuli/puppet-cron.git' provision: 'https://github.com/puppetlabs/provision.git' + puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' cron_core: repo: https://github.com/puppetlabs/puppetlabs-cron_core.git puppet_version: ">= 6.0.0" From 2eabf419cba4ff2e0d81317eb789aeba8d508435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 27 Oct 2022 11:40:13 -1000 Subject: [PATCH 12/23] Add missing dependency Bolt::PAL::PALError: Could not find module facts containing task file bash.sh --- .fixtures.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.fixtures.yml b/.fixtures.yml index ff7bfb2c..591090fc 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -12,6 +12,7 @@ fixtures: cron: 'https://github.com/voxpupuli/puppet-cron.git' provision: 'https://github.com/puppetlabs/provision.git' puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' + facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' cron_core: repo: https://github.com/puppetlabs/puppetlabs-cron_core.git puppet_version: ">= 6.0.0" From ab1ebc656178bba01cfcca8a4e4c3d545ab772e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 27 Oct 2022 12:15:20 -1000 Subject: [PATCH 13/23] Auto-select the default PostgreSQL version --- manifests/database/postgresql.pp | 2 +- manifests/params.pp | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index eddc10f2..e834fa40 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -60,7 +60,7 @@ if $manage_database { # get the pg contrib to use pg_trgm extension - if (versioncmp($postgres_version, '10') < 0) { + if (versioncmp($postgresql::globals::globals_version, '10') < 0) { include postgresql::server::contrib } diff --git a/manifests/params.pp b/manifests/params.pp index 456f7b4b..209e6b7b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -25,11 +25,7 @@ $manage_pg_repo = false } - if $puppetdb_version in ['latest','present'] or versioncmp($puppetdb_version, '7.0.0') >= 0 { - $postgres_version = '11' - } else { - $postgres_version = '9.6' - } + $postgres_version = undef # The remaining database settings are not used for an embedded database $database_host = 'localhost' From 0f9ab7e92152520ad8e733e2f0c0fdb5f7940f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 27 Oct 2022 12:36:09 -1000 Subject: [PATCH 14/23] Fix CI failures related to legacy facts --- spec/unit/classes/database/ssl_configuration_spec.rb | 8 +++++--- spec/unit/classes/master/config_spec.rb | 2 +- spec/unit/classes/server/command_processing_spec.rb | 4 +++- spec/unit/classes/server/database_ini_spec.rb | 9 ++++++--- spec/unit/classes/server/db_connection_uri_spec.rb | 9 ++++++--- spec/unit/classes/server/db_read_uri_spec.rb | 9 ++++++--- spec/unit/classes/server/global_ini_spec.rb | 8 ++++++-- spec/unit/classes/server/jetty_ini_spec.rb | 8 ++++++-- spec/unit/classes/server/puppetdb_ini_spec.rb | 8 ++++++-- spec/unit/classes/server/read_database_ini_spec.rb | 9 ++++++--- 10 files changed, 51 insertions(+), 23 deletions(-) diff --git a/spec/unit/classes/database/ssl_configuration_spec.rb b/spec/unit/classes/database/ssl_configuration_spec.rb index b5620df2..33ae5f6c 100644 --- a/spec/unit/classes/database/ssl_configuration_spec.rb +++ b/spec/unit/classes/database/ssl_configuration_spec.rb @@ -16,7 +16,9 @@ release: { 'full' => '7.0', 'major' => '7' }, selinux: { 'enabled' => true }, }, - fqdn: 'cheery-rime@puppet', + networking: { + fqdn: 'cheery-rime@puppet', + }, } end @@ -125,7 +127,7 @@ it 'has ident rule' do is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:database_username]} user") .with_map_name(identity_map) - .with_system_username(facts[:fqdn]) + .with_system_username(facts[:networking][:fqdn]) .with_database_username(params[:database_name]) end @@ -184,7 +186,7 @@ it 'has read ident rule' do is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:read_database_username]} user") .with_map_name(read_identity_map) - .with_system_username(facts[:fqdn]) + .with_system_username(facts[:networking][:fqdn]) .with_database_username(params[:read_database_username]) end end diff --git a/spec/unit/classes/master/config_spec.rb b/spec/unit/classes/master/config_spec.rb index 17a338ab..52a0a89c 100644 --- a/spec/unit/classes/master/config_spec.rb +++ b/spec/unit/classes/master/config_spec.rb @@ -5,7 +5,7 @@ context "on #{os}" do let(:facts) do facts.merge(puppetversion: Puppet.version, - fqdn: 'puppetdb.example.com', + networking: { fqdn: 'puppetdb.example.com' }, selinux: true) end diff --git a/spec/unit/classes/server/command_processing_spec.rb b/spec/unit/classes/server/command_processing_spec.rb index 06a9315f..edd67230 100644 --- a/spec/unit/classes/server/command_processing_spec.rb +++ b/spec/unit/classes/server/command_processing_spec.rb @@ -4,7 +4,9 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'OpenBSD', + os: { + family: 'OpenBSD', + }, puppetversion: Puppet.version, } end diff --git a/spec/unit/classes/server/database_ini_spec.rb b/spec/unit/classes/server/database_ini_spec.rb index 06f2865c..49f1f835 100644 --- a/spec/unit/classes/server/database_ini_spec.rb +++ b/spec/unit/classes/server/database_ini_spec.rb @@ -4,11 +4,14 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - operatingsystem: 'RedHat', + os: { + family: 'RedHat', + }, puppetversion: Puppet.version, operatingsystemrelease: '7.0', - fqdn: 'test.domain.local', + networking: { + fqdn: 'test.domain.local', + }, } end diff --git a/spec/unit/classes/server/db_connection_uri_spec.rb b/spec/unit/classes/server/db_connection_uri_spec.rb index 1c949e2e..6e1389cb 100644 --- a/spec/unit/classes/server/db_connection_uri_spec.rb +++ b/spec/unit/classes/server/db_connection_uri_spec.rb @@ -4,10 +4,13 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - operatingsystem: 'RedHat', + os: { + family: 'RedHat', + }, operatingsystemrelease: '7.0', - fqdn: 'test.domain.local', + networking: { + fqdn: 'test.domain.local', + }, } end diff --git a/spec/unit/classes/server/db_read_uri_spec.rb b/spec/unit/classes/server/db_read_uri_spec.rb index b7943e15..df565b76 100644 --- a/spec/unit/classes/server/db_read_uri_spec.rb +++ b/spec/unit/classes/server/db_read_uri_spec.rb @@ -4,10 +4,13 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - operatingsystem: 'RedHat', + os: { + family: 'RedHat', + }, operatingsystemrelease: '7.0', - fqdn: 'test.domain.local', + networking: { + fqdn: 'test.domain.local', + }, } end diff --git a/spec/unit/classes/server/global_ini_spec.rb b/spec/unit/classes/server/global_ini_spec.rb index 9b7b75a2..535459b3 100644 --- a/spec/unit/classes/server/global_ini_spec.rb +++ b/spec/unit/classes/server/global_ini_spec.rb @@ -4,8 +4,12 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - fqdn: 'foo.com', + os: { + family: 'RedHat', + }, + networking: { + fqdn: 'foo.com', + }, } end diff --git a/spec/unit/classes/server/jetty_ini_spec.rb b/spec/unit/classes/server/jetty_ini_spec.rb index 749d4238..a078b8df 100644 --- a/spec/unit/classes/server/jetty_ini_spec.rb +++ b/spec/unit/classes/server/jetty_ini_spec.rb @@ -4,8 +4,12 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - fqdn: 'test.domain.local', + os: { + family: 'RedHat', + }, + networking: { + fqdn: 'test.domain.local', + }, } end diff --git a/spec/unit/classes/server/puppetdb_ini_spec.rb b/spec/unit/classes/server/puppetdb_ini_spec.rb index a64fb25e..33a8016e 100644 --- a/spec/unit/classes/server/puppetdb_ini_spec.rb +++ b/spec/unit/classes/server/puppetdb_ini_spec.rb @@ -4,8 +4,12 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - fqdn: 'test.domain.local', + os: { + family: 'RedHat', + }, + networking: { + fqdn: 'test.domain.local', + }, } end diff --git a/spec/unit/classes/server/read_database_ini_spec.rb b/spec/unit/classes/server/read_database_ini_spec.rb index 502cdbcd..6b2b52cb 100644 --- a/spec/unit/classes/server/read_database_ini_spec.rb +++ b/spec/unit/classes/server/read_database_ini_spec.rb @@ -4,11 +4,14 @@ context 'on a supported platform' do let(:facts) do { - osfamily: 'RedHat', - operatingsystem: 'RedHat', + os: { + family: 'RedHat', + }, puppetversion: Puppet.version, operatingsystemrelease: '7.0', - fqdn: 'test.domain.local', + networking: { + fqdn: 'test.domain.local', + }, } end From adfe470df73dc3af44561cb8fe0a96577a9c25fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 27 Oct 2022 12:58:36 -1000 Subject: [PATCH 15/23] More CI fixes with latest posgresql module --- spec/unit/classes/database/postgresql_spec.rb | 1 + spec/unit/classes/database/ssl_configuration_spec.rb | 1 + spec/unit/classes/init_spec.rb | 2 +- spec/unit/classes/master/config_spec.rb | 2 ++ spec/unit/classes/master/puppetdb_conf_spec.rb | 1 + spec/unit/classes/master/report_processor_spec.rb | 1 + spec/unit/classes/server/command_processing_spec.rb | 1 + spec/unit/classes/server/database_ini_spec.rb | 1 + spec/unit/classes/server/db_connection_uri_spec.rb | 1 + spec/unit/classes/server/db_read_uri_spec.rb | 1 + spec/unit/classes/server/global_ini_spec.rb | 1 + spec/unit/classes/server/jetty_ini_spec.rb | 1 + spec/unit/classes/server/puppetdb_ini_spec.rb | 1 + spec/unit/classes/server/read_database_ini_spec.rb | 1 + spec/unit/classes/server_spec.rb | 1 + 15 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/unit/classes/database/postgresql_spec.rb b/spec/unit/classes/database/postgresql_spec.rb index d53066e7..efc92e69 100644 --- a/spec/unit/classes/database/postgresql_spec.rb +++ b/spec/unit/classes/database/postgresql_spec.rb @@ -16,6 +16,7 @@ release: { 'full' => '7.0', 'major' => '7' }, selinux: { 'enabled' => true }, }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/database/ssl_configuration_spec.rb b/spec/unit/classes/database/ssl_configuration_spec.rb index 33ae5f6c..c7a68423 100644 --- a/spec/unit/classes/database/ssl_configuration_spec.rb +++ b/spec/unit/classes/database/ssl_configuration_spec.rb @@ -19,6 +19,7 @@ networking: { fqdn: 'cheery-rime@puppet', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/init_spec.rb b/spec/unit/classes/init_spec.rb index d35eee37..f9532ee7 100644 --- a/spec/unit/classes/init_spec.rb +++ b/spec/unit/classes/init_spec.rb @@ -6,7 +6,7 @@ on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do - facts.merge(selinux: false) + facts.merge(selinux: false, service_provider: 'systemd') end describe 'when using default values for puppetdb class' do diff --git a/spec/unit/classes/master/config_spec.rb b/spec/unit/classes/master/config_spec.rb index 52a0a89c..72496edf 100644 --- a/spec/unit/classes/master/config_spec.rb +++ b/spec/unit/classes/master/config_spec.rb @@ -6,6 +6,7 @@ let(:facts) do facts.merge(puppetversion: Puppet.version, networking: { fqdn: 'puppetdb.example.com' }, + service_provider: 'systemd', selinux: true) end @@ -114,6 +115,7 @@ release: { 'full' => '7.0', 'major' => '7' }, selinux: { 'enabled' => true }, }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/master/puppetdb_conf_spec.rb b/spec/unit/classes/master/puppetdb_conf_spec.rb index 9444eb06..f3b65c52 100644 --- a/spec/unit/classes/master/puppetdb_conf_spec.rb +++ b/spec/unit/classes/master/puppetdb_conf_spec.rb @@ -9,6 +9,7 @@ context "on #{os}" do let(:facts) do facts.merge(puppetversion: Puppet.version, + service_provider: 'systemd', selinux: false) end diff --git a/spec/unit/classes/master/report_processor_spec.rb b/spec/unit/classes/master/report_processor_spec.rb index 9a68f82c..4473f69e 100644 --- a/spec/unit/classes/master/report_processor_spec.rb +++ b/spec/unit/classes/master/report_processor_spec.rb @@ -12,6 +12,7 @@ context "on #{os}" do let(:facts) do facts.merge(puppetversion: Puppet.version, + service_provider: 'systemd', clientcert: 'test.domain.local') end diff --git a/spec/unit/classes/server/command_processing_spec.rb b/spec/unit/classes/server/command_processing_spec.rb index edd67230..d1d4a835 100644 --- a/spec/unit/classes/server/command_processing_spec.rb +++ b/spec/unit/classes/server/command_processing_spec.rb @@ -8,6 +8,7 @@ family: 'OpenBSD', }, puppetversion: Puppet.version, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/database_ini_spec.rb b/spec/unit/classes/server/database_ini_spec.rb index 49f1f835..9df8a4e4 100644 --- a/spec/unit/classes/server/database_ini_spec.rb +++ b/spec/unit/classes/server/database_ini_spec.rb @@ -12,6 +12,7 @@ networking: { fqdn: 'test.domain.local', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/db_connection_uri_spec.rb b/spec/unit/classes/server/db_connection_uri_spec.rb index 6e1389cb..80d0bad5 100644 --- a/spec/unit/classes/server/db_connection_uri_spec.rb +++ b/spec/unit/classes/server/db_connection_uri_spec.rb @@ -11,6 +11,7 @@ networking: { fqdn: 'test.domain.local', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/db_read_uri_spec.rb b/spec/unit/classes/server/db_read_uri_spec.rb index df565b76..c9bb0992 100644 --- a/spec/unit/classes/server/db_read_uri_spec.rb +++ b/spec/unit/classes/server/db_read_uri_spec.rb @@ -11,6 +11,7 @@ networking: { fqdn: 'test.domain.local', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/global_ini_spec.rb b/spec/unit/classes/server/global_ini_spec.rb index 535459b3..ac393b50 100644 --- a/spec/unit/classes/server/global_ini_spec.rb +++ b/spec/unit/classes/server/global_ini_spec.rb @@ -10,6 +10,7 @@ networking: { fqdn: 'foo.com', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/jetty_ini_spec.rb b/spec/unit/classes/server/jetty_ini_spec.rb index a078b8df..bf54959f 100644 --- a/spec/unit/classes/server/jetty_ini_spec.rb +++ b/spec/unit/classes/server/jetty_ini_spec.rb @@ -10,6 +10,7 @@ networking: { fqdn: 'test.domain.local', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/puppetdb_ini_spec.rb b/spec/unit/classes/server/puppetdb_ini_spec.rb index 33a8016e..abcb7bd6 100644 --- a/spec/unit/classes/server/puppetdb_ini_spec.rb +++ b/spec/unit/classes/server/puppetdb_ini_spec.rb @@ -10,6 +10,7 @@ networking: { fqdn: 'test.domain.local', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server/read_database_ini_spec.rb b/spec/unit/classes/server/read_database_ini_spec.rb index 6b2b52cb..e637428a 100644 --- a/spec/unit/classes/server/read_database_ini_spec.rb +++ b/spec/unit/classes/server/read_database_ini_spec.rb @@ -12,6 +12,7 @@ networking: { fqdn: 'test.domain.local', }, + service_provider: 'systemd', } end diff --git a/spec/unit/classes/server_spec.rb b/spec/unit/classes/server_spec.rb index c3d2d315..2c48b5b0 100644 --- a/spec/unit/classes/server_spec.rb +++ b/spec/unit/classes/server_spec.rb @@ -9,6 +9,7 @@ context "on #{os}" do let(:facts) do facts.merge(puppetversion: Puppet.version, + service_provider: 'systemd', selinux: true) end From 0b8973bbe2a3744602ee769c1ff7ae0dfcff38e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sun, 8 Oct 2023 10:09:10 -1000 Subject: [PATCH 16/23] pdk update --template-ref 3.0.0 Needed some minor adjustment to `.sync.yml`. --- .github/workflows/nightly.yml | 204 ++------------------------------ .github/workflows/release.yml | 44 +------ .gitignore | 2 +- .pdkignore | 8 +- .rubocop.yml | 216 +++++++++++++++++++++++++++++++++- .sync.yml | 3 - Gemfile | 39 +++--- Rakefile | 9 +- metadata.json | 6 +- spec/default_facts.yml | 7 +- spec/spec_helper.rb | 4 +- 11 files changed, 262 insertions(+), 280 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c8fe88a5..1b06c471 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -2,203 +2,15 @@ name: "nightly" on: schedule: - - cron: '0 0 * * *' - - -env: - HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 - HONEYCOMB_DATASET: litmus tests + - cron: "0 0 * * *" + workflow_dispatch: jobs: - setup_matrix: - if: ${{ github.repository_owner == 'puppetlabs' }} - name: "Setup Test Matrix" - runs-on: ubuntu-20.04 - outputs: - matrix: ${{ steps.get-matrix.outputs.matrix }} - - steps: - - - name: "Honeycomb: Start recording" - uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 - with: - apikey: ${{ env.HONEYCOMB_WRITEKEY }} - dataset: ${{ env.HONEYCOMB_DATASET }} - job-status: ${{ job.status }} + Spec: + uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main" + secrets: "inherit" - - name: "Honeycomb: Start first step" - run: | - echo STEP_ID=setup-environment >> $GITHUB_ENV - echo STEP_START=$(date +%s) >> $GITHUB_ENV - - name: Checkout Source - uses: actions/checkout@v2 - if: ${{ github.repository_owner == 'puppetlabs' }} - - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - if: ${{ github.repository_owner == 'puppetlabs' }} - with: - ruby-version: "2.7" - bundler-cache: true - - - name: Print bundle environment - if: ${{ github.repository_owner == 'puppetlabs' }} - run: | - echo ::group::bundler environment - buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env - echo ::endgroup:: - - - name: "Honeycomb: Record Setup Environment time" - if: ${{ github.repository_owner == 'puppetlabs' }} - run: | - buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' - echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV - echo STEP_START=$(date +%s) >> $GITHUB_ENV - - name: Setup Acceptance Test Matrix - id: get-matrix - if: ${{ github.repository_owner == 'puppetlabs' }} - run: | - if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then - buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 - else - echo "::set-output name=matrix::{}" - fi - - - name: "Honeycomb: Record Setup Test Matrix time" - if: ${{ always() }} - run: | - buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' Acceptance: - name: "${{matrix.platforms.label}}, ${{matrix.collection}}" - needs: - - setup_matrix - - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} - - env: - BUILDEVENT_FILE: '../buildevents.txt' - - steps: - - run: | - echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE - echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE - echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE - - - - name: "Honeycomb: Start recording" - uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 - with: - apikey: ${{ env.HONEYCOMB_WRITEKEY }} - dataset: ${{ env.HONEYCOMB_DATASET }} - job-status: ${{ job.status }} - matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }} - - - name: "Honeycomb: start first step" - run: | - echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV - echo STEP_START=$(date +%s) >> $GITHUB_ENV - - - name: Checkout Source - uses: actions/checkout@v2 - - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.7" - bundler-cache: true - - - name: Print bundle environment - run: | - echo ::group::bundler environment - buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env - echo ::endgroup:: - - - name: "Honeycomb: Record Setup Environment time" - if: ${{ always() }} - run: | - buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' - echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV - echo STEP_START=$(date +%s) >> $GITHUB_ENV - - - name: Provision test environment - run: | - buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' - echo ::group::=== REQUEST === - cat request.json || true - echo - echo ::endgroup:: - echo ::group::=== INVENTORY === - if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; - then - FILE='spec/fixtures/litmus_inventory.yaml' - elif [ -f 'inventory.yaml' ]; - then - FILE='inventory.yaml' - fi - sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true - echo ::endgroup:: - - - name: Install agent - run: | - buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - - - name: Install module - run: | - buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' - - - name: "Honeycomb: Record deployment times" - if: ${{ always() }} - run: | - echo ::group::honeycomb step - buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' - echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV - echo STEP_START=$(date +%s) >> $GITHUB_ENV - echo ::endgroup:: - - - name: Run acceptance tests - run: | - buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' - - - name: "Honeycomb: Record acceptance testing times" - if: ${{ always() }} - run: | - buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' - echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV - echo STEP_START=$(date +%s) >> $GITHUB_ENV - - - name: Remove test environment - if: ${{ always() }} - continue-on-error: true - run: | - if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then - buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' - echo ::group::=== REQUEST === - cat request.json || true - echo - echo ::endgroup:: - fi - - - name: "Honeycomb: Record removal times" - if: ${{ always() }} - run: | - buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' - - slack-workflow-status: - if: ${{ github.repository_owner == 'puppetlabs' }} - name: Post Workflow Status To Slack - needs: - - Acceptance - runs-on: ubuntu-20.04 - steps: - - name: Slack Workflow Notification - uses: puppetlabs/Gamesight-slack-workflow-status@pdk-templates-v1 - with: - # Required Input - repo_token: ${{ secrets.GITHUB_TOKEN }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} - # Optional Input - channel: '#team-ia-bots' - name: 'GABot' + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1509f6e9..0b7b8a05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,44 +4,6 @@ on: workflow_dispatch: jobs: - create-github-release: - name: Deploy GitHub Release - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.ref }} - clean: true - fetch-depth: 0 - - name: Get Version - id: gv - run: | - echo "::set-output name=ver::$(jq --raw-output .version metadata.json)" - - name: Create Release - uses: actions/create-release@v1 - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: "v${{ steps.gv.outputs.ver }}" - draft: false - prerelease: false - - deploy-forge: - name: Deploy to Forge - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.ref }} - clean: true - - name: "PDK Build" - uses: docker://puppet/pdk:nightly - with: - args: 'build' - - name: "Push to Forge" - uses: docker://puppet/pdk:nightly - with: - args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force' + release: + uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" + secrets: "inherit" diff --git a/.gitignore b/.gitignore index 988dcbbe..3f155121 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt diff --git a/.pdkignore b/.pdkignore index c538bea8..584438f9 100644 --- a/.pdkignore +++ b/.pdkignore @@ -16,7 +16,7 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt @@ -26,20 +26,16 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml -/appveyor.yml -/.editorconfig /.fixtures.yml /Gemfile /.gitattributes /.gitignore -/.gitlab-ci.yml /.pdkignore /.puppet-lint.rc /Rakefile /rakelib/ /.rspec -/.rubocop.yml -/.travis.yml +/..yml /.yardopts /spec/ /.vscode/ diff --git a/.rubocop.yml b/.rubocop.yml index 8f782e74..5be1f9fa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ require: - rubocop-rspec AllCops: DisplayCopNames: true - TargetRubyVersion: '2.4' + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: @@ -111,8 +111,14 @@ Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true +Bundler/GemFilename: + Enabled: false Bundler/InsecureProtocolSource: Enabled: false +Capybara/CurrentPathExpectation: + Enabled: false +Capybara/VisibilityMatcher: + Enabled: false Gemspec/DuplicatedAssignment: Enabled: false Gemspec/OrderedDependencies: @@ -287,11 +293,9 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Capybara/CurrentPathExpectation: - Enabled: false RSpec/Capybara/FeatureMethods: Enabled: false -RSpec/Capybara/VisibilityMatcher: +RSpec/ContainExactly: Enabled: false RSpec/ContextMethod: Enabled: false @@ -331,6 +335,8 @@ RSpec/LeakyConstantDeclaration: Enabled: false RSpec/LetBeforeExamples: Enabled: false +RSpec/MatchArray: + Enabled: false RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: @@ -373,8 +379,6 @@ Style/AccessModifierDeclarations: Enabled: false Style/AccessorGrouping: Enabled: false -Style/AsciiComments: - Enabled: false Style/BisectedAttrAccessor: Enabled: false Style/CaseLikeIf: @@ -485,35 +489,235 @@ Style/TrailingMethodEndStatement: Enabled: false Style/UnpackFirst: Enabled: false +Capybara/MatchStyle: + Enabled: false +Capybara/NegationMatcher: + Enabled: false +Capybara/SpecificActions: + Enabled: false +Capybara/SpecificFinders: + Enabled: false +Capybara/SpecificMatcher: + Enabled: false +Gemspec/DeprecatedAttributeAssignment: + Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false +Gemspec/RequireMFA: + Enabled: false +Layout/LineContinuationLeadingSpace: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false +Layout/LineEndStringConcatenationIndentation: + Enabled: false +Layout/SpaceBeforeBrackets: + Enabled: false +Lint/AmbiguousAssignment: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false +Lint/AmbiguousRange: + Enabled: false +Lint/ConstantOverwrittenInRescue: + Enabled: false +Lint/DeprecatedConstants: + Enabled: false Lint/DuplicateBranch: Enabled: false +Lint/DuplicateMagicComment: + Enabled: false Lint/DuplicateRegexpCharacterClassElement: Enabled: false Lint/EmptyBlock: Enabled: false Lint/EmptyClass: Enabled: false +Lint/EmptyInPattern: + Enabled: false +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false +Lint/LambdaWithoutLiteralBlock: + Enabled: false Lint/NoReturnInBeginEndBlocks: Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/NumberedParameterAssignment: + Enabled: false +Lint/OrAssignmentToConstant: + Enabled: false +Lint/RedundantDirGlobSort: + Enabled: false +Lint/RefinementImportMethods: + Enabled: false +Lint/RequireRangeParentheses: + Enabled: false +Lint/RequireRelativeSelfPath: + Enabled: false +Lint/SymbolConversion: + Enabled: false Lint/ToEnumArguments: Enabled: false +Lint/TripleQuotes: + Enabled: false Lint/UnexpectedBlockArity: Enabled: false Lint/UnmodifiedReduceAccumulator: Enabled: false +Lint/UselessRescue: + Enabled: false +Lint/UselessRuby2Keywords: + Enabled: false +Metrics/CollectionLiteralLength: + Enabled: false +Naming/BlockForwarding: + Enabled: false Performance/CollectionLiteralInLoop: Enabled: false +Performance/ConcurrentMonotonicTime: + Enabled: false +Performance/MapCompact: + Enabled: false +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSplitRegexpArgument: + Enabled: false +Performance/StringIdentifierArgument: + Enabled: false +RSpec/BeEq: + Enabled: false +RSpec/BeNil: + Enabled: false +RSpec/ChangeByZero: + Enabled: false +RSpec/ClassCheck: + Enabled: false +RSpec/DuplicatedMetadata: + Enabled: false +RSpec/ExcessiveDocstringSpacing: + Enabled: false +RSpec/FactoryBot/ConsistentParenthesesStyle: + Enabled: false +RSpec/FactoryBot/FactoryNameStyle: + Enabled: false +RSpec/FactoryBot/SyntaxMethods: + Enabled: false +RSpec/IdenticalEqualityAssertion: + Enabled: false +RSpec/NoExpectationExample: + Enabled: false +RSpec/PendingWithoutReason: + Enabled: false +RSpec/Rails/AvoidSetupHook: + Enabled: false +RSpec/Rails/HaveHttpStatus: + Enabled: false +RSpec/Rails/InferredSpecType: + Enabled: false +RSpec/Rails/MinitestAssertions: + Enabled: false +RSpec/Rails/TravelAround: + Enabled: false +RSpec/RedundantAround: + Enabled: false +RSpec/SkipBlockInsideExample: + Enabled: false +RSpec/SortMetadata: + Enabled: false +RSpec/SubjectDeclaration: + Enabled: false +RSpec/VerifiedDoubleReference: + Enabled: false +Security/CompoundHash: + Enabled: false +Security/IoMethods: + Enabled: false Style/ArgumentsForwarding: Enabled: false +Style/ArrayIntersect: + Enabled: false Style/CollectionCompact: Enabled: false +Style/ComparableClamp: + Enabled: false +Style/ConcatArrayLiterals: + Enabled: false +Style/DirEmpty: + Enabled: false Style/DocumentDynamicEvalDefinition: Enabled: false +Style/EmptyHeredoc: + Enabled: false +Style/EndlessMethod: + Enabled: false +Style/EnvHome: + Enabled: false +Style/FetchEnvVar: + Enabled: false +Style/FileEmpty: + Enabled: false +Style/FileRead: + Enabled: false +Style/FileWrite: + Enabled: false +Style/HashConversion: + Enabled: false +Style/HashExcept: + Enabled: false +Style/IfWithBooleanLiteralBranches: + Enabled: false +Style/InPatternThen: + Enabled: false +Style/MagicCommentFormat: + Enabled: false +Style/MapCompactWithConditionalBlock: + Enabled: false +Style/MapToHash: + Enabled: false +Style/MapToSet: + Enabled: false +Style/MinMaxComparison: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false Style/NegatedIfElseCondition: Enabled: false +Style/NestedFileDirname: + Enabled: false Style/NilLambda: Enabled: false +Style/NumberedParameters: + Enabled: false +Style/NumberedParametersLimit: + Enabled: false +Style/ObjectThen: + Enabled: false +Style/OpenStructUse: + Enabled: false +Style/OperatorMethodCall: + Enabled: false +Style/QuotedSymbols: + Enabled: false Style/RedundantArgument: Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantDoubleSplatHashBraces: + Enabled: false +Style/RedundantEach: + Enabled: false +Style/RedundantHeredocDelimiterQuotes: + Enabled: false +Style/RedundantInitialize: + Enabled: false +Style/RedundantSelfAssignmentBranch: + Enabled: false +Style/RedundantStringEscape: + Enabled: false +Style/SelectByRegexp: + Enabled: false +Style/StringChars: + Enabled: false Style/SwapValues: Enabled: false diff --git a/.sync.yml b/.sync.yml index 22edd120..a2140292 100644 --- a/.sync.yml +++ b/.sync.yml @@ -8,8 +8,6 @@ Gemfile: ':system_tests': - gem: 'nokogiri' platforms: ruby - - gem: 'serverspec' - platforms: ruby spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true @@ -18,7 +16,6 @@ spec/spec_helper.rb: .github/workflows/nightly.yml: unmanaged: false .github/workflows/spec.yml: - checks: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop' unmanaged: false .github/workflows/release.yml: unmanaged: false diff --git a/Gemfile b/Gemfile index 775a8aa8..21af2ec8 100644 --- a/Gemfile +++ b/Gemfile @@ -13,23 +13,34 @@ def location_for(place_or_version, fake_version = nil) end end -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - group :development do - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] - 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 "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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false + gem "facterdb", '~> 1.18', require: false + gem "metadata-json-lint", '~> 3.0', require: false + gem "puppetlabs_spec_helper", '~> 6.0', require: false + gem "rspec-puppet-facts", '~> 2.0', require: false + gem "codecov", '~> 0.2', require: false + gem "dependency_checker", '~> 1.0.0', require: false + gem "parallel_tests", '= 3.12.1', require: false + gem "pry", '~> 0.10', require: false + gem "simplecov-console", '~> 0.5', require: false + gem "puppet-debugger", '~> 1.0', require: false + gem "rubocop", '= 1.48.1', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false + gem "puppet-strings", '~> 4.0', require: false + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "nokogiri", require: false, platforms: [:ruby] - gem "serverspec", require: false, platforms: [:ruby] + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "serverspec", '~> 2.41', require: false + gem "nokogiri", require: false, platforms: [:ruby] end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 0f8754eb..74415a96 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,11 @@ # frozen_string_literal: true require 'bundler' -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? +require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -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? +require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator' +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' def changelog_user return unless Rake.application.top_level_tasks.include? "changelog" @@ -44,7 +43,7 @@ end PuppetLint.configuration.send('disable_relative') -if Bundler.rubygems.find_name('github_changelog_generator').any? +if Gem.loaded_specs.key? 'github_changelog_generator' GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? config.user = "#{changelog_user}" diff --git a/metadata.json b/metadata.json index d4d86cc6..4d43e87e 100644 --- a/metadata.json +++ b/metadata.json @@ -82,7 +82,7 @@ } ], "description": "Module for installing/configuring PuppetDB", - "pdk-version": "2.3.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#2.4.0", - "template-ref": "tags/2.4.0-0-gfa6b6d2" + "pdk-version": "3.0.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#3.0.0", + "template-ref": "tags/3.0.0-0-g5bfc1c0" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index f777abfc..3346c394 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -2,7 +2,8 @@ # # Facts specified here will override the values provided by rspec-puppet-facts. --- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 07db7342..6820cebe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,8 +25,8 @@ 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), permitted_classes: [], permitted_symbols: [], aliases: true)) + rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end From 68d8c64b0d62c58f95441e711509829abd9e6fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sun, 8 Oct 2023 10:16:15 -1000 Subject: [PATCH 17/23] bundle exec puppet-lint manifests --fix --- manifests/database/default_read_grant.pp | 8 ++++---- manifests/database/postgresql.pp | 12 +++++------- manifests/database/postgresql_ssl_rules.pp | 4 ++-- manifests/database/ssl_configuration.pp | 8 ++++---- manifests/globals.pp | 4 +--- manifests/init.pp | 14 ++++++-------- manifests/master/config.pp | 7 ++----- manifests/master/puppetdb_conf.pp | 3 +-- manifests/master/report_processor.pp | 1 - manifests/master/routes.pp | 9 ++++----- manifests/master/storeconfigs.pp | 1 - manifests/params.pp | 2 +- manifests/server.pp | 21 ++++++++++----------- manifests/server/command_processing.pp | 1 - manifests/server/database.pp | 8 ++------ manifests/server/global.pp | 1 - manifests/server/jetty.pp | 3 --- manifests/server/puppetdb.pp | 3 +-- manifests/server/read_database.pp | 14 ++++++-------- manifests/server/validate_db.pp | 1 - manifests/server/validate_read_db.pp | 1 - 21 files changed, 49 insertions(+), 77 deletions(-) diff --git a/manifests/database/default_read_grant.pp b/manifests/database/default_read_grant.pp index 80d798b1..fea87f96 100644 --- a/manifests/database/default_read_grant.pp +++ b/manifests/database/default_read_grant.pp @@ -1,12 +1,12 @@ # Private class. Grant read permissions to $database_read_only_username by default, for new tables created by # $database_username. -define puppetdb::database::default_read_grant( +define puppetdb::database::default_read_grant ( String $database_name, String $schema, String $database_username, String $database_read_only_username, ) { - postgresql_psql {"grant default select permission for ${database_read_only_username}": + postgresql_psql { "grant default select permission for ${database_read_only_username}": db => $database_name, command => "ALTER DEFAULT PRIVILEGES FOR USER \"${database_username}\" @@ -23,7 +23,7 @@ AND nspname = '${schema}'", } - postgresql_psql {"grant default usage permission for ${database_read_only_username}": + postgresql_psql { "grant default usage permission for ${database_read_only_username}": db => $database_name, command => "ALTER DEFAULT PRIVILEGES FOR USER \"${database_username}\" @@ -40,7 +40,7 @@ AND nspname = '${schema}'", } - postgresql_psql {"grant default execute permission for ${database_read_only_username}": + postgresql_psql { "grant default execute permission for ${database_read_only_username}": db => $database_name, command => "ALTER DEFAULT PRIVILEGES FOR USER \"${database_username}\" diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index e834fa40..7a6c833f 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -19,14 +19,13 @@ $read_database_password = $puppetdb::params::read_database_password, $read_database_host = $puppetdb::params::read_database_host ) inherits puppetdb::params { - if $manage_server { - class { '::postgresql::globals': + class { 'postgresql::globals': manage_package_repo => $manage_package_repo, version => $postgres_version, } # get the pg server up and running - class { '::postgresql::server': + class { 'postgresql::server': ip_mask_allow_all_users => '0.0.0.0/0', listen_addresses => $listen_addresses, port => scanf($database_port, '%i')[0], @@ -35,7 +34,7 @@ # We need to create the ssl connection for the read user, when # manage_database is set to true, or when read_database_host is defined. # Otherwise we don't create it. - if $manage_database or $read_database_host != undef{ + if $manage_database or $read_database_host != undef { $create_read_user_rule = true } else { $create_read_user_rule = false @@ -52,13 +51,12 @@ postgresql_ssl_key_path => $postgresql_ssl_key_path, postgresql_ssl_cert_path => $postgresql_ssl_cert_path, postgresql_ssl_ca_cert_path => $postgresql_ssl_ca_cert_path, - create_read_user_rule => $create_read_user_rule + create_read_user_rule => $create_read_user_rule, } } # Only install pg_trgm extension, if database it is actually managed by the module if $manage_database { - # get the pg contrib to use pg_trgm extension if (versioncmp($postgresql::globals::globals_version, '10') < 0) { include postgresql::server::contrib @@ -99,7 +97,7 @@ read_database_username => $read_database_username, database_name => $database_name, password_hash => postgresql::postgresql_password($read_database_username, $read_database_password), - database_owner => $database_username + database_owner => $database_username, } -> postgresql_psql { "grant ${read_database_username} role to ${database_username}": diff --git a/manifests/database/postgresql_ssl_rules.pp b/manifests/database/postgresql_ssl_rules.pp index 56b48395..a217d612 100644 --- a/manifests/database/postgresql_ssl_rules.pp +++ b/manifests/database/postgresql_ssl_rules.pp @@ -13,7 +13,7 @@ address => '0.0.0.0/0', auth_method => 'cert', order => 0, - auth_option => "map=${identity_map_key} clientcert=1" + auth_option => "map=${identity_map_key} clientcert=1", } postgresql::server::pg_hba_rule { "Allow certificate mapped connections to ${database_name} as ${database_username} (ipv6)": @@ -23,7 +23,7 @@ address => '::0/0', auth_method => 'cert', order => 0, - auth_option => "map=${identity_map_key} clientcert=1" + auth_option => "map=${identity_map_key} clientcert=1", } postgresql::server::pg_ident_rule { "Map the SSL certificate of the server as a ${database_username} user": diff --git a/manifests/database/ssl_configuration.pp b/manifests/database/ssl_configuration.pp index 0d2473c6..a5c085e5 100644 --- a/manifests/database/ssl_configuration.pp +++ b/manifests/database/ssl_configuration.pp @@ -31,25 +31,25 @@ postgresql::server::config_entry { 'ssl': ensure => present, value => 'on', - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } postgresql::server::config_entry { 'ssl_cert_file': ensure => present, value => "${postgresql::server::datadir}/server.crt", - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } postgresql::server::config_entry { 'ssl_key_file': ensure => present, value => "${postgresql::server::datadir}/server.key", - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } postgresql::server::config_entry { 'ssl_ca_file': ensure => present, value => $postgresql_ssl_ca_cert_path, - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } puppetdb::database::postgresql_ssl_rules { "Configure postgresql ssl rules for ${database_username}": diff --git a/manifests/globals.pp b/manifests/globals.pp index 413339aa..6e088eb6 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -2,10 +2,8 @@ class puppetdb::globals ( $version = 'present', $database = 'postgres', - ) { - +) { if !(fact('os.family') in ['RedHat', 'Suse', 'Archlinux', 'Debian', 'OpenBSD', 'FreeBSD']) { fail("${module_name} does not support your osfamily ${fact('os.family')}") } - } diff --git a/manifests/init.pp b/manifests/init.pp index c999441d..b0978d02 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -91,8 +91,7 @@ Integer[1] $dlo_max_age = $puppetdb::params::dlo_max_age, Optional[Stdlib::Absolutepath] $java_bin = $puppetdb::params::java_bin, ) inherits puppetdb::params { - - class { '::puppetdb::server': + class { 'puppetdb::server': listen_address => $listen_address, listen_port => $listen_port, disable_cleartext => $disable_cleartext, @@ -176,14 +175,13 @@ } if ($database == 'postgres') { - $database_before = str2bool($database_validate) ? { - false => Class['::puppetdb::server'], - default => [Class['::puppetdb::server'], - Class['::puppetdb::server::validate_db']], + false => Class['puppetdb::server'], + default => [Class['puppetdb::server'], + Class['puppetdb::server::validate_db']], } - class { '::puppetdb::database::postgresql': + class { 'puppetdb::database::postgresql': listen_addresses => $database_listen_address, database_name => $database_name, puppetdb_server => $puppetdb_server, @@ -201,7 +199,7 @@ read_database_username => $read_database_username, read_database_password => $read_database_password, read_database_host => $read_database_host, - before => $database_before + before => $database_before, } } } diff --git a/manifests/master/config.pp b/manifests/master/config.pp index 7463ed3e..eb9fb1d9 100644 --- a/manifests/master/config.pp +++ b/manifests/master/config.pp @@ -2,14 +2,14 @@ class puppetdb::master::config ( $puppetdb_server = fact('networking.fqdn'), $puppetdb_port = defined(Class['puppetdb']) ? { - true => $::puppetdb::disable_ssl ? { + true => $puppetdb::disable_ssl ? { true => 8080, default => 8081, }, default => 8081, }, $puppetdb_disable_ssl = defined(Class['puppetdb']) ? { - true => $::puppetdb::disable_ssl, + true => $puppetdb::disable_ssl, default => false, }, $masterless = $puppetdb::params::masterless, @@ -30,7 +30,6 @@ $test_url = $puppetdb::params::test_url, $restart_puppet = true, ) inherits puppetdb::params { - # **WARNING**: Ugly hack to work around a yum bug with metadata parsing. This # should not be copied, replicated or even looked at. In short, never rename # your packages... @@ -66,7 +65,6 @@ } if ($strict_validation) { - # Validate the puppetdb connection. If we can't connect to puppetdb then we # *must* not perform the other configuration steps, or else @@ -192,5 +190,4 @@ Class['puppetdb::master::report_processor'] ~> Service[$puppet_service_name] } } - } diff --git a/manifests/master/puppetdb_conf.pp b/manifests/master/puppetdb_conf.pp index a3dd72fc..3cf8d706 100644 --- a/manifests/master/puppetdb_conf.pp +++ b/manifests/master/puppetdb_conf.pp @@ -12,8 +12,7 @@ /(puppetdb-terminus)/ => true, default => false, }, - ) inherits puppetdb::params { - +) inherits puppetdb::params { Ini_setting { ensure => present, section => 'main', diff --git a/manifests/master/report_processor.pp b/manifests/master/report_processor.pp index f97130bd..4002d596 100644 --- a/manifests/master/report_processor.pp +++ b/manifests/master/report_processor.pp @@ -5,7 +5,6 @@ $masterless = $puppetdb::params::masterless, $enable = false ) inherits puppetdb::params { - if $masterless { $puppet_conf_section = 'main' } else { diff --git a/manifests/master/routes.pp b/manifests/master/routes.pp index fcdda80a..87435b06 100644 --- a/manifests/master/routes.pp +++ b/manifests/master/routes.pp @@ -5,7 +5,6 @@ $masterless = $puppetdb::params::masterless, $routes = undef, ) inherits puppetdb::params { - if $masterless { $routes_real = { 'apply' => { @@ -16,8 +15,8 @@ 'facts' => { 'terminus' => 'facter', 'cache' => 'puppetdb_apply', - } - } + }, + }, } } elsif $routes { $routes_real = $routes @@ -32,8 +31,8 @@ 'facts' => { 'terminus' => 'puppetdb', 'cache' => $default_fact_cache, - } - } + }, + }, } } diff --git a/manifests/master/storeconfigs.pp b/manifests/master/storeconfigs.pp index cb46cc09..a547e517 100644 --- a/manifests/master/storeconfigs.pp +++ b/manifests/master/storeconfigs.pp @@ -5,7 +5,6 @@ $masterless = $puppetdb::params::masterless, $enable = true, ) inherits puppetdb::params { - if $masterless { $puppet_conf_section = 'main' } else { diff --git a/manifests/params.pp b/manifests/params.pp index 209e6b7b..02ceb957 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -204,7 +204,7 @@ $certificate_whitelist_file = "${etcdir}/certificate-whitelist" # the default is free access for now - $certificate_whitelist = [ ] + $certificate_whitelist = [] # change to this to only allow access by the puppet master by default: #$certificate_whitelist = [ $::servername ] diff --git a/manifests/server.pp b/manifests/server.pp index b9def8af..6ec90c88 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -81,7 +81,6 @@ Integer[1] $dlo_max_age = $puppetdb::params::dlo_max_age, Optional[Stdlib::Absolutepath] $java_bin = $puppetdb::params::java_bin, ) inherits puppetdb::params { - # Apply necessary suffix if zero is specified. # Can we drop this in the next major release? if $node_ttl == '0' { @@ -263,21 +262,21 @@ if $postgresql_ssl_on { exec { $ssl_key_pk8_path: - path => [ '/opt/puppetlabs/puppet/bin', $facts['path'] ], + path => ['/opt/puppetlabs/puppet/bin', $facts['path']], command => "openssl pkcs8 -topk8 -inform PEM -outform DER -in ${ssl_key_path} -out ${ssl_key_pk8_path} -nocrypt", # Generate a .pk8 key if one doesn't exist or is older than the .pem input. # NOTE: bash file time checks, like -ot, can't always discern sub-second # differences. onlyif => "test ! -e '${ssl_key_pk8_path}' -o '${ssl_key_pk8_path}' -ot '${ssl_key_path}'", - before => File[$ssl_key_pk8_path] + before => File[$ssl_key_pk8_path], } file { $ssl_key_pk8_path: - ensure => present, + ensure => file, owner => $puppetdb_user, group => $puppetdb_group, mode => '0600', - notify => Service[$puppetdb_service] + notify => Service[$puppetdb_service], } } @@ -324,7 +323,7 @@ setting => 'JAVA_ARGS', require => Package[$puppetdb_package], notify => Service[$puppetdb_service], - })) + })) } else { ini_setting { 'java_args': ensure => present, @@ -357,14 +356,14 @@ # https://puppet.com/docs/puppetdb/5.2/maintain_and_tune.html#clean-up-the-dead-letter-office systemd::unit_file { 'puppetdb-dlo-cleanup.service': content => epp("${module_name}/puppetdb-DLO-cleanup.service.epp", { - 'puppetdb_user' => $puppetdb_user, - 'puppetdb_group' => $puppetdb_group, - 'vardir' => $vardir, - 'dlo_max_age' => $dlo_max_age + 'puppetdb_user' => $puppetdb_user, + 'puppetdb_group' => $puppetdb_group, + 'vardir' => $vardir, + 'dlo_max_age' => $dlo_max_age }), } -> systemd::unit_file { 'puppetdb-dlo-cleanup.timer': - content => epp("${module_name}/puppetdb-DLO-cleanup.timer.epp", {'cleanup_timer_interval' => $cleanup_timer_interval }), + content => epp("${module_name}/puppetdb-DLO-cleanup.timer.epp", { 'cleanup_timer_interval' => $cleanup_timer_interval }), enable => true, active => true, } diff --git a/manifests/server/command_processing.pp b/manifests/server/command_processing.pp index 6d05e562..7a3cd2a3 100644 --- a/manifests/server/command_processing.pp +++ b/manifests/server/command_processing.pp @@ -6,7 +6,6 @@ $temp_usage = $puppetdb::params::temp_usage, $confdir = $puppetdb::params::confdir, ) inherits puppetdb::params { - $config_ini = "${confdir}/config.ini" # Set the defaults diff --git a/manifests/server/database.pp b/manifests/server/database.pp index 12dff9ff..d541a1e4 100644 --- a/manifests/server/database.pp +++ b/manifests/server/database.pp @@ -30,7 +30,6 @@ $ssl_key_pk8_path = $puppetdb::params::ssl_key_pk8_path, $ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path ) inherits puppetdb::params { - if str2bool($database_validate) { # Validate the database connection. If we can't connect, we want to fail # and skip the rest of the configuration, so that we don't leave puppetdb @@ -69,15 +68,13 @@ path => $database_ini, ensure => present, section => 'database', - require => $ini_setting_require + require => $ini_setting_require, } if $database == 'embedded' { - $classname = 'org.hsqldb.jdbcDriver' $subprotocol = 'hsqldb' $subname = "file:${database_embedded_path};hsqldb.tx=mvcc;sql.syntax_pgs=true" - } elsif $database == 'postgres' { $classname = 'org.postgresql.Driver' $subprotocol = 'postgresql' @@ -91,8 +88,7 @@ $subname_default = "//${database_host}:${database_port}/${database_name}${database_suffix}" - if $postgresql_ssl_on and !empty($jdbc_ssl_properties) - { + if $postgresql_ssl_on and !empty($jdbc_ssl_properties) { fail("Variables 'postgresql_ssl_on' and 'jdbc_ssl_properties' can not be used at the same time!") } diff --git a/manifests/server/global.pp b/manifests/server/global.pp index f03f281f..874601a8 100644 --- a/manifests/server/global.pp +++ b/manifests/server/global.pp @@ -4,7 +4,6 @@ $confdir = $puppetdb::params::confdir, $puppetdb_group = $puppetdb::params::puppetdb_group, ) inherits puppetdb::params { - $config_ini = "${confdir}/config.ini" file { $config_ini: diff --git a/manifests/server/jetty.pp b/manifests/server/jetty.pp index ea050faf..bb155ec3 100644 --- a/manifests/server/jetty.pp +++ b/manifests/server/jetty.pp @@ -17,7 +17,6 @@ $puppetdb_user = $puppetdb::params::puppetdb_user, $puppetdb_group = $puppetdb::params::puppetdb_group, ) inherits puppetdb::params { - $jetty_ini = "${confdir}/jetty.ini" file { $jetty_ini: @@ -70,7 +69,6 @@ } if $ssl_protocols { - ini_setting { 'puppetdb_sslprotocols': ensure => $ssl_setting_ensure, setting => 'ssl-protocols', @@ -79,7 +77,6 @@ } if $cipher_suites { - ini_setting { 'puppetdb_cipher-suites': ensure => $ssl_setting_ensure, setting => 'cipher-suites', diff --git a/manifests/server/puppetdb.pp b/manifests/server/puppetdb.pp index 54fa4d2d..b77e48a9 100644 --- a/manifests/server/puppetdb.pp +++ b/manifests/server/puppetdb.pp @@ -7,7 +7,6 @@ $puppetdb_user = $puppetdb::params::puppetdb_user, $puppetdb_group = $puppetdb::params::puppetdb_group, ) inherits puppetdb::params { - $puppetdb_ini = "${confdir}/puppetdb.ini" file { $puppetdb_ini: @@ -31,7 +30,7 @@ } # accept connections only from puppet master - ini_setting {'puppetdb-connections-from-master-only': + ini_setting { 'puppetdb-connections-from-master-only': ensure => $certificate_whitelist_setting_ensure, section => 'puppetdb', setting => 'certificate-whitelist', diff --git a/manifests/server/read_database.pp b/manifests/server/read_database.pp index 688a74fe..e3407b7d 100644 --- a/manifests/server/read_database.pp +++ b/manifests/server/read_database.pp @@ -22,7 +22,6 @@ $ssl_key_pk8_path = $puppetdb::params::ssl_key_pk8_path, $ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path ) inherits puppetdb::params { - if $read_database_host != undef { if str2bool($database_validate) { # Validate the database connection. If we can't connect, we want to fail @@ -78,18 +77,17 @@ $subname_default = "//${read_database_host}:${read_database_port}/${read_database_name}${database_suffix}" - if $postgresql_ssl_on and !empty($jdbc_ssl_properties) - { + if $postgresql_ssl_on and !empty($jdbc_ssl_properties) { fail("Variables 'postgresql_ssl_on' and 'jdbc_ssl_properties' can not be used at the same time!") } if $postgresql_ssl_on { $subname = @("EOT"/L) - ${subname_default}?\ - ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&\ - sslmode=verify-full&sslrootcert=${ssl_ca_cert_path}&\ - sslkey=${ssl_key_pk8_path}&sslcert=${ssl_cert_path}\ - | EOT + ${subname_default}?\ + ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&\ + sslmode=verify-full&sslrootcert=${ssl_ca_cert_path}&\ + sslkey=${ssl_key_pk8_path}&sslcert=${ssl_cert_path}\ + | EOT } else { $subname = $subname_default } diff --git a/manifests/server/validate_db.pp b/manifests/server/validate_db.pp index cf2e5b41..faa06410 100644 --- a/manifests/server/validate_db.pp +++ b/manifests/server/validate_db.pp @@ -8,7 +8,6 @@ $database_name = $puppetdb::params::database_name, $jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties, ) inherits puppetdb::params { - # We don't need any validation for the embedded database, presumably. if ( $database == 'postgres' and diff --git a/manifests/server/validate_read_db.pp b/manifests/server/validate_read_db.pp index d857676d..bbf19986 100644 --- a/manifests/server/validate_read_db.pp +++ b/manifests/server/validate_read_db.pp @@ -8,7 +8,6 @@ $database_name = $puppetdb::params::database_name, $jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties, ) inherits puppetdb::params { - # Currently we only support postgres if ( $database == 'postgres' and From 0af3a80bc7c9781bb9e43b135abd16ee3fa007f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sun, 8 Oct 2023 10:18:34 -1000 Subject: [PATCH 18/23] Disable out-of-scope puppet-lint checks For now we want to have running CI. We do not care about the module being fully documented. --- .puppet-lint.rc | 4 ++++ .sync.yml | 7 +++++++ Rakefile | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece0..b4372aaf 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,5 @@ --relative +--no-parameter_types-check +--no-parameter_documentation-check +--no-documentation-check +--no-140chars-check diff --git a/.sync.yml b/.sync.yml index a2140292..ae3782ab 100644 --- a/.sync.yml +++ b/.sync.yml @@ -8,6 +8,13 @@ Gemfile: ':system_tests': - gem: 'nokogiri' platforms: ruby +Rakefile: + default_disabled_lint_checks: + - relative + - parameter_types + - parameter_documentation + - documentation + - 140chars spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true diff --git a/Rakefile b/Rakefile index 74415a96..1763bb6a 100644 --- a/Rakefile +++ b/Rakefile @@ -41,6 +41,10 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.send('disable_parameter_types') +PuppetLint.configuration.send('disable_parameter_documentation') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_140chars') if Gem.loaded_specs.key? 'github_changelog_generator' From b8a52bc5b4bf87a07cc9b47d746abc57f2b4cfcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sun, 8 Oct 2023 18:34:02 -1000 Subject: [PATCH 19/23] Remove local facts overrides They break adding facts from a context. --- .sync.yml | 2 ++ spec/default_facts.yml | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 spec/default_facts.yml diff --git a/.sync.yml b/.sync.yml index ae3782ab..e2afdd0c 100644 --- a/.sync.yml +++ b/.sync.yml @@ -15,6 +15,8 @@ Rakefile: - parameter_documentation - documentation - 140chars +spec/default_facts.yml: + unmanaged: true spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index 3346c394..00000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -networking: - ip: "172.16.254.254" - ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" - mac: "AA:AA:AA:AA:AA:AA" -is_pe: false From cb14e5d70cfca2539a8bf458228d7955db96a153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 9 Oct 2023 08:21:01 -1000 Subject: [PATCH 20/23] Match the ensure value of the manifest This was changed in 68d8c64b0d62c58f95441e711509829abd9e6fd3 to fix puppet lint issues, but as the test suite was not run it passed through. --- spec/unit/classes/server_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/classes/server_spec.rb b/spec/unit/classes/server_spec.rb index 2c48b5b0..6ffbf4e3 100644 --- a/spec/unit/classes/server_spec.rb +++ b/spec/unit/classes/server_spec.rb @@ -202,7 +202,7 @@ it 'contains file private.pk8' do is_expected.to contain_file('/etc/puppetlabs/puppetdb/ssl/private.pk8') .with( - ensure: 'present', + ensure: 'file', owner: 'puppetdb', group: 'puppetdb', mode: '0600', From 62550d84b0a1971398e180ae3f2bfb264ce4eed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 9 Oct 2023 08:24:17 -1000 Subject: [PATCH 21/23] Match owner / mode of the manifest This was changed in 010bf136c78ff84c54903322505aaca6af3d13f8 to match best practice, but as the test suite was not run it passed through. --- spec/unit/classes/server/global_ini_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/classes/server/global_ini_spec.rb b/spec/unit/classes/server/global_ini_spec.rb index ac393b50..4101852b 100644 --- a/spec/unit/classes/server/global_ini_spec.rb +++ b/spec/unit/classes/server/global_ini_spec.rb @@ -31,9 +31,9 @@ is_expected.to contain_file('/etc/puppetlabs/puppetdb/conf.d/config.ini') .with( 'ensure' => 'file', - 'owner' => 'puppetdb', + 'owner' => 'root', 'group' => 'puppetdb', - 'mode' => '0600', + 'mode' => '0640', ) } end From e62e37dd53a9463d65e397e6ff2e1d0d88ff789c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 9 Oct 2023 08:30:29 -1000 Subject: [PATCH 22/23] Add path to the custom facts The systemd module use this to run `systemctl daemon-reload`. Set an arbitrary value to avoid: > Validation of Exec[systemd-postgresql.service-systemctl-daemon-reload] failed: 'systemctl' is not qualified and no path was specified. Please qualify the command or specify a path. --- spec/unit/classes/database/ssl_configuration_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/unit/classes/database/ssl_configuration_spec.rb b/spec/unit/classes/database/ssl_configuration_spec.rb index c7a68423..1ee8cc7a 100644 --- a/spec/unit/classes/database/ssl_configuration_spec.rb +++ b/spec/unit/classes/database/ssl_configuration_spec.rb @@ -10,6 +10,7 @@ operatingsystemrelease: '7.0', kernel: 'Linux', selinux: true, + path: '/usr/bin:/bin', os: { family: 'RedHat', name: 'RedHat', From 2b1feae08de8a5f46cc092ceb539aca8933a4fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 9 Oct 2023 08:45:51 -1000 Subject: [PATCH 23/23] Drop Ubuntu 16.04 (EOL) Ubuntu reached EOL a few years ago. The module rely on modules that drop support for this legacy version of Ubuntu e.g. the puppetlabs-postgresql module removed support 6+ months ago. Drop support for Ubuntu. --- metadata.json | 1 - 1 file changed, 1 deletion(-) diff --git a/metadata.json b/metadata.json index 4d43e87e..a1b8b3f4 100644 --- a/metadata.json +++ b/metadata.json @@ -69,7 +69,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "16.04", "18.04", "20.04" ]