diff --git a/.fixtures.yml b/.fixtures.yml index b25e8c459..50a7a3848 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,8 +1,10 @@ fixtures: repositories: facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' - puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' + puppet_agent: + repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' + ref: 4.4.0 provision: 'https://github.com/puppetlabs/provision.git' symlinks: stdlib: "#{source_dir}" - test: "#{source_dir}/spec/fixtures/test" \ No newline at end of file + test: "#{source_dir}/spec/fixtures/test" diff --git a/.github/workflows/auto_release.yml b/.github/workflows/auto_release.yml index f4aed440e..ca677186e 100644 --- a/.github/workflows/auto_release.yml +++ b/.github/workflows/auto_release.yml @@ -3,88 +3,8 @@ 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' + release_prep: + name: "Release Prep" + uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main" + secrets: "inherit" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..a5738adb8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: "ci" + +on: + pull_request: + branches: + - "main" + workflow_dispatch: + +jobs: + Spec: + uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main" + secrets: "inherit" + + Acceptance: + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml new file mode 100644 index 000000000..b4100a5af --- /dev/null +++ b/.github/workflows/mend.yml @@ -0,0 +1,15 @@ +name: "mend" + +on: + pull_request: + branches: + - "main" + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + + mend: + uses: "puppetlabs/cat-github-actions/.github/workflows/mend_ruby.yml@main" + secrets: "inherit" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 42816e7de..a28cd2db0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -2,203 +2,16 @@ 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' + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" - 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-cat-bots' - name: 'GABot' diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml index fd310e656..7e4dd83a8 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -2,84 +2,43 @@ 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 + - name: Activate Ruby 2.5 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 + 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 != '{}' }} + name: "${{matrix.platforms.label}}, " runs-on: ubuntu-20.04 strategy: fail-fast: false - matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} + matrix: + platforms: + - label: Stretch + provider: provision::docker + image: litmusimage/debian:9 + - label: Buster + provider: provision::docker + image: litmusimage/debian:10 + collection: + - puppet5 env: BUILDEVENT_FILE: '../buildevents.txt' @@ -89,19 +48,7 @@ jobs: 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 @@ -114,18 +61,12 @@ jobs: - name: Print bundle environment run: | echo ::group::bundler environment - buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- 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 }}]' + bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' echo ::group::=== REQUEST === cat request.json || true echo @@ -142,44 +83,22 @@ jobs: 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 }}]' + run: 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:: + run: bundle exec rake 'litmus:install_module' + - 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 + run: bundle exec rake 'litmus:acceptance:parallel' + - 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' + 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 index 1509f6e91..82caec76a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,44 +4,7 @@ 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: + name: "Release" + uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" + secrets: "inherit" diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index 6c1ae10d8..ffec2292a 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -1,91 +1,44 @@ name: "Spec Tests" -on: - schedule: - - cron: '0 0 * * *' - workflow_dispatch: - pull_request: - - -env: - HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 - HONEYCOMB_DATASET: litmus tests +on: [pull_request] 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 + - name: Activate Ruby 2.5 uses: ruby/setup-ruby@v1 - if: ${{ github.repository_owner == 'puppetlabs' }} with: - ruby-version: "2.7" + ruby-version: "2.5" 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 + 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)}} + matrix: + include: + - puppet_version: '~> 5.5.0' + ruby_version: '2.5' + facter_version: '~> 2.0' env: BUILDEVENT_FILE: '../buildevents.txt' PUPPET_GEM_VERSION: ${{ matrix.puppet_version }} - FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' + FACTER_GEM_VERSION: ${{ matrix.facter_version }} steps: - run: | @@ -93,18 +46,7 @@ jobs: - 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 @@ -117,10 +59,8 @@ jobs: - name: Print bundle environment run: | echo ::group::bundler environment - buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- 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 + run: bundle exec rake parallel_spec diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 26d7e5b1f..000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Audit aging issues/PRs - -on: - schedule: - - cron: "30 1 * * *" - -jobs: - audit: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-issue-stale: 90 - days-before-pr-stale: 60 - days-before-pr-close: 7 - stale-issue-message: | - Hello! 👋 - - This issue has been open for a while and has had no recent activity. We've labelled it with `attention-needed` so that we can get a clear view of which issues need our attention. - - If you are waiting on a response from us we will try and address your comments on a future Community Day. - - Alternatively, if it is no longer relevant to you please close the issue with a comment. - stale-issue-label: 'attention-needed' - stale-pr-message: | - Hello! 👋 - - This pull request has been open for a while and has had no recent activity. We've labelled it with `attention-needed` so that we can get a clear view of which PRs need our attention. - - If you are waiting on a response from us we will try and address your comments on a future Community Day. - - Alternatively, if it is no longer relevant to you please close the PR with a comment. - - Please note that if a pull request receives no update for 7 after it has been labelled, it will be closed. We are always happy to re-open pull request if they have been closed in error. - stale-pr-label: 'attention-needed' diff --git a/.sync.yml b/.sync.yml index 8b32d1b38..5f384051b 100644 --- a/.sync.yml +++ b/.sync.yml @@ -11,6 +11,7 @@ Gemfile: optional: ":development": - gem: github_changelog_generator + version: '= 1.15.2' spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true @@ -18,14 +19,11 @@ spec/spec_helper.rb: unmanaged: false .gitpod.yml: unmanaged: false -.github/workflows/nightly.yml: - unmanaged: false -.github/workflows/pr_test.yml: - unmanaged: false .github/workflows/auto_release.yml: unmanaged: false -.github/workflows/spec.yml: - checks: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop' +.github/workflows/ci.yml: + unmanaged: false +.github/workflows/nightly.yml: unmanaged: false .github/workflows/release.yml: unmanaged: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ffc7f7b..e7671f18e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,30 @@ All 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). +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). + +## [v8.6.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v8.6.0) - 2023-04-24 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v8.5.0...v8.6.0) + +### Added + +- Stdlib::Http::Method: Add new type for http methods [#1299](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1299) ([b4ldr](https://github.com/b4ldr)) +- Add `stdlib::sha256` [#1289](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1289) ([jcpunk](https://github.com/jcpunk)) +- Add `stdlib::crc32` [#1288](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1288) ([jcpunk](https://github.com/jcpunk)) +- Add Stdlib::Ensure::Package type [#1281](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1281) ([arjenz](https://github.com/arjenz)) + +### Fixed + +- (PUP-11752) Fix fqdn_rand_string_spec.rb test [#1308](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1308) ([alexjfisher](https://github.com/alexjfisher)) +- Make ensure_packages work with `ensure => present` [#1300](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1300) ([alexjfisher](https://github.com/alexjfisher)) +- Safely handle a missing root user [#1295](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1295) ([ekohl](https://github.com/ekohl)) +- stdlib::ensure: update function to support the generic case [#1286](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1286) ([b4ldr](https://github.com/b4ldr)) +- Drop Puppet < 3.6 support in package_provider fact [#1280](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1280) ([ekohl](https://github.com/ekohl)) +- Correct bcrypt salt regex [#1279](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1279) ([sabo](https://github.com/sabo)) +- Determine root_home without shelling out [#1278](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1278) ([ekohl](https://github.com/ekohl)) +- (CONT-173) - Updating deprecated facter instances [#1277](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1277) ([jordanbreen28](https://github.com/jordanbreen28)) + ## [v8.5.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v8.5.0) (2022-10-13) [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v8.4.0...v8.5.0) diff --git a/CODEOWNERS b/CODEOWNERS index a5d109e99..e68528ed9 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,3 @@ # Setting ownership to the modules team -* @puppetlabs/modules +# include Trusted Contributors +* @puppetlabs/modules @alexjfisher @b4ldr @bastelfreak @ekohl @smortex diff --git a/Gemfile b/Gemfile index 26dd2db9c..deb1895ab 100644 --- a/Gemfile +++ b/Gemfile @@ -13,28 +13,23 @@ 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('.') +puppet_module_posix_version = if Gem::Requirement.create('~> 2.5.0').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + '0.0' + else + '1.0' + end + group :development do - gem "json", '~> 2.0', require: false - gem "voxpupuli-puppet-lint-plugins", '~> 3.0', require: false - gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '>= 2.0.2', '< 4.0.0', require: false - gem "puppetlabs_spec_helper", '>= 3.0.0', '< 5.0.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false - gem "dependency_checker", '~> 0.2', require: false - gem "parallel_tests", '~> 3.4', 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.6.1', require: false - gem "rubocop-performance", '= 1.9.1', require: false - gem "rubocop-rspec", '= 2.0.1', require: false - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "github_changelog_generator", require: false + 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}", "~> #{puppet_module_posix_version}", require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", "~> #{puppet_module_posix_version}", require: false, platforms: [:ruby] end group :system_tests do - gem "puppet_litmus", '< 1.0.0', require: false, platforms: [:ruby] - gem "serverspec", '~> 2.41', require: false + gem "puppet-module-posix-system-r#{minor_version}", "~> #{puppet_module_posix_version}", require: false, platforms: [:ruby] end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/REFERENCE.md b/REFERENCE.md index 92111e563..c6f9b3f2e 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -7,8 +7,8 @@ ### Classes * [`stdlib`](#stdlib): This module manages stdlib. -* [`stdlib::manage`](#stdlibmanage): A simple place to define trivial resources -* [`stdlib::stages`](#stdlibstages): This class manages a standard set of run stages for Puppet. It is managed by +* [`stdlib::manage`](#stdlib--manage): A simple place to define trivial resources +* [`stdlib::stages`](#stdlib--stages): This class manages a standard set of run stages for Puppet. It is managed by the stdlib class, and should not be declared independently. ### Resource types @@ -173,15 +173,17 @@ the provided regular expression. * [`sort`](#sort): Sorts strings and arrays lexically. * [`sprintf_hash`](#sprintf_hash): Uses sprintf with named references. * [`squeeze`](#squeeze): Returns a new string where runs of the same character that occur in this set are replaced by a single character. -* [`stdlib::deferrable_epp`](#stdlibdeferrable_epp): This function returns either a rendered template or a deferred function to render at runtime. If any of the values in the variables hash are -* [`stdlib::end_with`](#stdlibend_with): Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String. -* [`stdlib::ensure`](#stdlibensure): function to cast ensure parameter to resource specific value -* [`stdlib::extname`](#stdlibextname): Returns the Extension (the Portion of Filename in Path starting from the +* [`stdlib::crc32`](#stdlib--crc32): Run a CRC32 calculation against a given value. +* [`stdlib::deferrable_epp`](#stdlib--deferrable_epp): This function returns either a rendered template or a deferred function to render at runtime. If any of the values in the variables hash are +* [`stdlib::end_with`](#stdlib--end_with): Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String. +* [`stdlib::ensure`](#stdlib--ensure): function to cast ensure parameter to resource specific value +* [`stdlib::extname`](#stdlib--extname): Returns the Extension (the Portion of Filename in Path starting from the last Period). -* [`stdlib::ip_in_range`](#stdlibip_in_range): Returns true if the ipaddress is within the given CIDRs -* [`stdlib::start_with`](#stdlibstart_with): Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. -* [`stdlib::str2resource`](#stdlibstr2resource): This converts a string to a puppet resource. -* [`stdlib::xml_encode`](#stdlibxml_encode): Encode strings for XML files +* [`stdlib::ip_in_range`](#stdlib--ip_in_range): Returns true if the ipaddress is within the given CIDRs +* [`stdlib::sha256`](#stdlib--sha256): Run a SHA256 calculation against a given value. +* [`stdlib::start_with`](#stdlib--start_with): Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. +* [`stdlib::str2resource`](#stdlib--str2resource): This converts a string to a puppet resource. +* [`stdlib::xml_encode`](#stdlib--xml_encode): Encode strings for XML files * [`str2bool`](#str2bool): This converts a string to a boolean. * [`str2saltedpbkdf2`](#str2saltedpbkdf2): Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+ * [`str2saltedsha512`](#str2saltedsha512): This converts a string to a salted-SHA512 password hash (which is used for @@ -258,64 +260,67 @@ OpenSSL. ### Data types -* [`Stdlib::Absolutepath`](#stdlibabsolutepath): A strict absolutepath type -* [`Stdlib::Base32`](#stdlibbase32): Type to match base32 String -* [`Stdlib::Base64`](#stdlibbase64): Type to match base64 String -* [`Stdlib::Compat::Absolute_path`](#stdlibcompatabsolute_path): Emulate the is_absolute_path and validate_absolute_path functions -* [`Stdlib::Compat::Array`](#stdlibcompatarray): Emulate the is_array and validate_array functions -* [`Stdlib::Compat::Bool`](#stdlibcompatbool): Emulate the is_bool and validate_bool functions -* [`Stdlib::Compat::Float`](#stdlibcompatfloat): Emulate the is_float function -* [`Stdlib::Compat::Hash`](#stdlibcompathash): Emulate the is_hash and validate_hash functions -* [`Stdlib::Compat::Integer`](#stdlibcompatinteger): Emulate the is_integer and validate_integer functions -* [`Stdlib::Compat::Ip_address`](#stdlibcompatip_address): Validate an IP address -* [`Stdlib::Compat::Ipv4`](#stdlibcompatipv4): Emulate the validate_ipv4_address and is_ipv4_address functions -* [`Stdlib::Compat::Ipv6`](#stdlibcompatipv6): Validate an IPv6 address -* [`Stdlib::Compat::Numeric`](#stdlibcompatnumeric): Emulate the is_numeric and validate_numeric functions -* [`Stdlib::Compat::String`](#stdlibcompatstring): Emulate the is_string and validate_string functions -* [`Stdlib::CreateResources`](#stdlibcreateresources): A type description used for the create_resources function -* [`Stdlib::Datasize`](#stdlibdatasize): Validate the size of data -* [`Stdlib::Email`](#stdlibemail): Validate an e-mail address -* [`Stdlib::Ensure::File`](#stdlibensurefile): Validate the value of the ensure parameter for a file -* [`Stdlib::Ensure::File::Directory`](#stdlibensurefiledirectory): Validate the ensure parameter of a "directory" file resource -* [`Stdlib::Ensure::File::File`](#stdlibensurefilefile): Validate the ensure parameter of a "file" file resource -* [`Stdlib::Ensure::File::Link`](#stdlibensurefilelink): Validate the ensure parameter of a "link" file resource -* [`Stdlib::Ensure::Service`](#stdlibensureservice): Validate the value of the ensure parameter of a service resource -* [`Stdlib::Filemode`](#stdlibfilemode): Validate a file mode -* [`Stdlib::Filesource`](#stdlibfilesource): Validate the source parameter on file types -* [`Stdlib::Fqdn`](#stdlibfqdn): Validate a Fully Qualified Domain Name -* [`Stdlib::HTTPSUrl`](#stdlibhttpsurl): Validate a HTTPS URL -* [`Stdlib::HTTPUrl`](#stdlibhttpurl): Validate a HTTP(S) URL -* [`Stdlib::Host`](#stdlibhost): Validate a host (FQDN or IP address) -* [`Stdlib::HttpStatus`](#stdlibhttpstatus): Validate a HTTP status code -* [`Stdlib::IP::Address`](#stdlibipaddress): Validate an IP address -* [`Stdlib::IP::Address::Nosubnet`](#stdlibipaddressnosubnet): Validate an IP address without subnet -* [`Stdlib::IP::Address::V4`](#stdlibipaddressv4): Validate an IPv4 address -* [`Stdlib::IP::Address::V4::CIDR`](#stdlibipaddressv4cidr): lint:ignore:140chars -* [`Stdlib::IP::Address::V4::Nosubnet`](#stdlibipaddressv4nosubnet): lint:ignore:140chars -* [`Stdlib::IP::Address::V6`](#stdlibipaddressv6): Validate an IPv6 address -* [`Stdlib::IP::Address::V6::Alternative`](#stdlibipaddressv6alternative): lint:ignore:140chars -* [`Stdlib::IP::Address::V6::CIDR`](#stdlibipaddressv6cidr): lint:ignore:140chars -* [`Stdlib::IP::Address::V6::Compressed`](#stdlibipaddressv6compressed): Validate a compressed IPv6 address -* [`Stdlib::IP::Address::V6::Full`](#stdlibipaddressv6full): Validate a full IPv6 address -* [`Stdlib::IP::Address::V6::Nosubnet`](#stdlibipaddressv6nosubnet): Validate an IPv6 address without subnet -* [`Stdlib::IP::Address::V6::Nosubnet::Alternative`](#stdlibipaddressv6nosubnetalternative): lint:ignore:140chars -* [`Stdlib::IP::Address::V6::Nosubnet::Compressed`](#stdlibipaddressv6nosubnetcompressed): Validate compressed IPv6 address without subnet -* [`Stdlib::IP::Address::V6::Nosubnet::Full`](#stdlibipaddressv6nosubnetfull): Validate full IPv6 address without subnet -* [`Stdlib::MAC`](#stdlibmac): A type for a MAC address -* [`Stdlib::ObjectStore`](#stdlibobjectstore): Validate an ObjectStore -* [`Stdlib::ObjectStore::GSUri`](#stdlibobjectstoregsuri): Validate a Google Cloud object store URI -* [`Stdlib::ObjectStore::S3Uri`](#stdlibobjectstores3uri): Validate an Amazon Web Services S3 object store URI -* [`Stdlib::Port`](#stdlibport): Validate a port number -* [`Stdlib::Port::Dynamic`](#stdlibportdynamic): Validate a dynamic port number -* [`Stdlib::Port::Ephemeral`](#stdlibportephemeral): Validate an ephemeral port number -* [`Stdlib::Port::Privileged`](#stdlibportprivileged): Validate a priviliged port number -* [`Stdlib::Port::Registered`](#stdlibportregistered): Validate a registered port number -* [`Stdlib::Port::Unprivileged`](#stdlibportunprivileged): Validate an unprivileged port number -* [`Stdlib::Port::User`](#stdlibportuser): Validate a port number usable by a user -* [`Stdlib::Syslogfacility`](#stdlibsyslogfacility): Validate a syslog facility -* [`Stdlib::Unixpath`](#stdlibunixpath): Validate a UNIX path -* [`Stdlib::Windowspath`](#stdlibwindowspath): Validate a Windows path -* [`Stdlib::Yes_no`](#stdlibyes_no): Validate a yes / no value +* [`Stdlib::Absolutepath`](#Stdlib--Absolutepath): A strict absolutepath type +* [`Stdlib::Base32`](#Stdlib--Base32): Type to match base32 String +* [`Stdlib::Base64`](#Stdlib--Base64): Type to match base64 String +* [`Stdlib::Compat::Absolute_path`](#Stdlib--Compat--Absolute_path): Emulate the is_absolute_path and validate_absolute_path functions +* [`Stdlib::Compat::Array`](#Stdlib--Compat--Array): Emulate the is_array and validate_array functions +* [`Stdlib::Compat::Bool`](#Stdlib--Compat--Bool): Emulate the is_bool and validate_bool functions +* [`Stdlib::Compat::Float`](#Stdlib--Compat--Float): Emulate the is_float function +* [`Stdlib::Compat::Hash`](#Stdlib--Compat--Hash): Emulate the is_hash and validate_hash functions +* [`Stdlib::Compat::Integer`](#Stdlib--Compat--Integer): Emulate the is_integer and validate_integer functions +* [`Stdlib::Compat::Ip_address`](#Stdlib--Compat--Ip_address): Validate an IP address +* [`Stdlib::Compat::Ipv4`](#Stdlib--Compat--Ipv4): Emulate the validate_ipv4_address and is_ipv4_address functions +* [`Stdlib::Compat::Ipv6`](#Stdlib--Compat--Ipv6): Validate an IPv6 address +* [`Stdlib::Compat::Numeric`](#Stdlib--Compat--Numeric): Emulate the is_numeric and validate_numeric functions +* [`Stdlib::Compat::String`](#Stdlib--Compat--String): Emulate the is_string and validate_string functions +* [`Stdlib::CreateResources`](#Stdlib--CreateResources): A type description used for the create_resources function +* [`Stdlib::Datasize`](#Stdlib--Datasize): Validate the size of data +* [`Stdlib::Email`](#Stdlib--Email): Validate an e-mail address +* [`Stdlib::Ensure::File`](#Stdlib--Ensure--File): Validate the value of the ensure parameter for a file +* [`Stdlib::Ensure::File::Directory`](#Stdlib--Ensure--File--Directory): Validate the ensure parameter of a "directory" file resource +* [`Stdlib::Ensure::File::File`](#Stdlib--Ensure--File--File): Validate the ensure parameter of a "file" file resource +* [`Stdlib::Ensure::File::Link`](#Stdlib--Ensure--File--Link): Validate the ensure parameter of a "link" file resource +* [`Stdlib::Ensure::Package`](#Stdlib--Ensure--Package): Validate the value of the ensure parameter for a package +* [`Stdlib::Ensure::Service`](#Stdlib--Ensure--Service): Validate the value of the ensure parameter of a service resource +* [`Stdlib::Filemode`](#Stdlib--Filemode): Validate a file mode +* [`Stdlib::Filesource`](#Stdlib--Filesource): Validate the source parameter on file types +* [`Stdlib::Fqdn`](#Stdlib--Fqdn): Validate a Fully Qualified Domain Name +* [`Stdlib::HTTPSUrl`](#Stdlib--HTTPSUrl): Validate a HTTPS URL +* [`Stdlib::HTTPUrl`](#Stdlib--HTTPUrl): Validate a HTTP(S) URL +* [`Stdlib::Host`](#Stdlib--Host): Validate a host (FQDN or IP address) +* [`Stdlib::Http::Method`](#Stdlib--Http--Method): Valid HTTP method verbs +* [`Stdlib::Http::Status`](#Stdlib--Http--Status): A valid HTTP status code per RFC9110 +* [`Stdlib::HttpStatus`](#Stdlib--HttpStatus): Validate a HTTP status code +* [`Stdlib::IP::Address`](#Stdlib--IP--Address): Validate an IP address +* [`Stdlib::IP::Address::Nosubnet`](#Stdlib--IP--Address--Nosubnet): Validate an IP address without subnet +* [`Stdlib::IP::Address::V4`](#Stdlib--IP--Address--V4): Validate an IPv4 address +* [`Stdlib::IP::Address::V4::CIDR`](#Stdlib--IP--Address--V4--CIDR): lint:ignore:140chars +* [`Stdlib::IP::Address::V4::Nosubnet`](#Stdlib--IP--Address--V4--Nosubnet): lint:ignore:140chars +* [`Stdlib::IP::Address::V6`](#Stdlib--IP--Address--V6): Validate an IPv6 address +* [`Stdlib::IP::Address::V6::Alternative`](#Stdlib--IP--Address--V6--Alternative): lint:ignore:140chars +* [`Stdlib::IP::Address::V6::CIDR`](#Stdlib--IP--Address--V6--CIDR): lint:ignore:140chars +* [`Stdlib::IP::Address::V6::Compressed`](#Stdlib--IP--Address--V6--Compressed): Validate a compressed IPv6 address +* [`Stdlib::IP::Address::V6::Full`](#Stdlib--IP--Address--V6--Full): Validate a full IPv6 address +* [`Stdlib::IP::Address::V6::Nosubnet`](#Stdlib--IP--Address--V6--Nosubnet): Validate an IPv6 address without subnet +* [`Stdlib::IP::Address::V6::Nosubnet::Alternative`](#Stdlib--IP--Address--V6--Nosubnet--Alternative): lint:ignore:140chars +* [`Stdlib::IP::Address::V6::Nosubnet::Compressed`](#Stdlib--IP--Address--V6--Nosubnet--Compressed): Validate compressed IPv6 address without subnet +* [`Stdlib::IP::Address::V6::Nosubnet::Full`](#Stdlib--IP--Address--V6--Nosubnet--Full): Validate full IPv6 address without subnet +* [`Stdlib::MAC`](#Stdlib--MAC): A type for a MAC address +* [`Stdlib::ObjectStore`](#Stdlib--ObjectStore): Validate an ObjectStore +* [`Stdlib::ObjectStore::GSUri`](#Stdlib--ObjectStore--GSUri): Validate a Google Cloud object store URI +* [`Stdlib::ObjectStore::S3Uri`](#Stdlib--ObjectStore--S3Uri): Validate an Amazon Web Services S3 object store URI +* [`Stdlib::Port`](#Stdlib--Port): Validate a port number +* [`Stdlib::Port::Dynamic`](#Stdlib--Port--Dynamic): Validate a dynamic port number +* [`Stdlib::Port::Ephemeral`](#Stdlib--Port--Ephemeral): Validate an ephemeral port number +* [`Stdlib::Port::Privileged`](#Stdlib--Port--Privileged): Validate a priviliged port number +* [`Stdlib::Port::Registered`](#Stdlib--Port--Registered): Validate a registered port number +* [`Stdlib::Port::Unprivileged`](#Stdlib--Port--Unprivileged): Validate an unprivileged port number +* [`Stdlib::Port::User`](#Stdlib--Port--User): Validate a port number usable by a user +* [`Stdlib::Syslogfacility`](#Stdlib--Syslogfacility): Validate a syslog facility +* [`Stdlib::Unixpath`](#Stdlib--Unixpath): Validate a UNIX path +* [`Stdlib::Windowspath`](#Stdlib--Windowspath): Validate a Windows path +* [`Stdlib::Yes_no`](#Stdlib--Yes_no): Validate a yes / no value ## Classes @@ -327,7 +332,7 @@ declared in order to use the standardized run stages. Declares all other classes in the stdlib module. Currently, this consists of stdlib::stages and stdlib::manage. -### `stdlib::manage` +### `stdlib::manage` Sometimes your systems require a single simple resource. It can feel unnecessary to create a module for a single @@ -379,9 +384,9 @@ stdlib::manage::create_resources: The following parameters are available in the `stdlib::manage` class: -* [`create_resources`](#create_resources) +* [`create_resources`](#-stdlib--manage--create_resources) -##### `create_resources` +##### `create_resources` Data type: `Hash[String, Hash]` @@ -390,7 +395,7 @@ NOTE: functions, such as `template` or `epp`, are not evaluated. Default value: `{}` -### `stdlib::stages` +### `stdlib::stages` Declares various run-stages for deploying infrastructure, language runtimes, and application layers. @@ -460,9 +465,9 @@ class { 'mcollective': } -> class { 'ntp': } The following parameters are available in the `anchor` type. -* [`name`](#name) +* [`name`](#-anchor--name) -##### `name` +##### `name` namevar @@ -584,93 +589,93 @@ The line to be appended to the file or used to replace matches found by the matc The following parameters are available in the `file_line` type. -* [`after`](#after) -* [`append_on_no_match`](#append_on_no_match) -* [`encoding`](#encoding) -* [`match`](#match) -* [`match_for_absence`](#match_for_absence) -* [`multiple`](#multiple) -* [`name`](#name) -* [`path`](#path) -* [`provider`](#provider) -* [`replace`](#replace) -* [`replace_all_matches_not_matching_line`](#replace_all_matches_not_matching_line) +* [`after`](#-file_line--after) +* [`append_on_no_match`](#-file_line--append_on_no_match) +* [`encoding`](#-file_line--encoding) +* [`match`](#-file_line--match) +* [`match_for_absence`](#-file_line--match_for_absence) +* [`multiple`](#-file_line--multiple) +* [`name`](#-file_line--name) +* [`path`](#-file_line--path) +* [`provider`](#-file_line--provider) +* [`replace`](#-file_line--replace) +* [`replace_all_matches_not_matching_line`](#-file_line--replace_all_matches_not_matching_line) -##### `after` +##### `after` An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place) This is also takes a regex. -##### `append_on_no_match` +##### `append_on_no_match` -Valid values: ``true``, ``false`` +Valid values: `true`, `false` If true, append line if match is not found. If false, do not append line if a match is not found -Default value: ``true`` +Default value: `true` -##### `encoding` +##### `encoding` For files that are not UTF-8 encoded, specify encoding such as iso-8859-1 Default value: `UTF-8` -##### `match` +##### `match` An optional ruby regular expression to run against existing lines in the file. If a match is found, we replace that line rather than adding a new line. A regex comparison is performed against the line value and if it does not match an exception will be raised. -##### `match_for_absence` +##### `match_for_absence` -Valid values: ``true``, ``false`` +Valid values: `true`, `false` An optional value to determine if match should be applied when ensure => absent. If set to true and match is set, the line that matches match will be deleted. If set to false (the default), match is ignored when ensure => absent. When `ensure => present`, match_for_absence is ignored. -Default value: ``false`` +Default value: `false` -##### `multiple` +##### `multiple` -Valid values: ``true``, ``false`` +Valid values: `true`, `false` An optional value to determine if match can change multiple lines. If set to false, an exception will be raised if more than one line matches -##### `name` +##### `name` namevar An arbitrary name used as the identity of the resource. -##### `path` +##### `path` The file Puppet will ensure contains the line specified by the line parameter. -##### `provider` +##### `provider` The specific backend to use for this `file_line` resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform. -##### `replace` +##### `replace` -Valid values: ``true``, ``false`` +Valid values: `true`, `false` If true, replace line that matches. If false, do not write line if a match is found -Default value: ``true`` +Default value: `true` -##### `replace_all_matches_not_matching_line` +##### `replace_all_matches_not_matching_line` -Valid values: ``true``, ``false`` +Valid values: `true`, `false` Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, regardless of whether the specified line is already present in the file. -Default value: ``false`` +Default value: `false` ## Functions @@ -4190,7 +4195,9 @@ hash types are: |bcrypt-x |2x |bug compatible | |bcrypt-y |2y |historic alias for 2b| -The third argument to this function is the salt to use. +The third argument to this function is the salt to use. For bcrypt-type hashes, +the first two characters of the salt represent a strength parameter, with a value +between 4 and 31 inclusive. > *Note:*: this uses the Puppet Server's implementation of crypt(3). If your environment contains several different operating systems, ensure that they @@ -4215,7 +4222,9 @@ hash types are: |bcrypt-x |2x |bug compatible | |bcrypt-y |2y |historic alias for 2b| -The third argument to this function is the salt to use. +The third argument to this function is the salt to use. For bcrypt-type hashes, +the first two characters of the salt represent a strength parameter, with a value +between 4 and 31 inclusive. > *Note:*: this uses the Puppet Server's implementation of crypt(3). If your environment contains several different operating systems, ensure that they @@ -4662,7 +4671,67 @@ The squeeze function. Returns: `Any` a new string where runs of the same character that occur in this set are replaced by a single character. -### `stdlib::deferrable_epp` +### `stdlib::crc32` + +Type: Ruby 4.x API + +Run a CRC32 calculation against a given value. + +#### Examples + +##### Check a simple string value + +```puppet +stdlib::crc32('my string') == '18fbd270' +``` + +##### Check a Sensitive datatype + +```puppet +stdlib::crc32(sensitive('my string')) == '18fbd270' +``` + +##### Check a number + +```puppet +stdlib::crc32(100.0) == 'a3fd429a' +stdlib::crc32(100.00000) == 'a3fd429a' +``` + +#### `stdlib::crc32(Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]] $my_data)` + +Run a CRC32 calculation against a given value. + +Returns: `String` String + +##### Examples + +###### Check a simple string value + +```puppet +stdlib::crc32('my string') == '18fbd270' +``` + +###### Check a Sensitive datatype + +```puppet +stdlib::crc32(sensitive('my string')) == '18fbd270' +``` + +###### Check a number + +```puppet +stdlib::crc32(100.0) == 'a3fd429a' +stdlib::crc32(100.00000) == 'a3fd429a' +``` + +##### `my_data` + +Data type: `Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]]` + +The ScalarData to evaluate + +### `stdlib::deferrable_epp` Type: Puppet Language @@ -4696,7 +4765,7 @@ Data type: `Hash` -### `stdlib::end_with` +### `stdlib::end_with` Type: Ruby 4.x API @@ -4740,13 +4809,13 @@ Data type: `Variant[String[1],Array[String[1], 1]]` The suffixes to check -### `stdlib::ensure` +### `stdlib::ensure` Type: Puppet Language function to cast ensure parameter to resource specific value -#### `stdlib::ensure(Variant[Boolean, Enum['present', 'absent']] $ensure, Enum['directory', 'link', 'mounted', 'service', 'file', 'package'] $resource)` +#### `stdlib::ensure(Variant[Boolean, Enum['present', 'absent']] $ensure, Optional[Enum['directory', 'link', 'mounted', 'service', 'file', 'package']] $resource = undef)` The stdlib::ensure function. @@ -4760,11 +4829,11 @@ Data type: `Variant[Boolean, Enum['present', 'absent']]` ##### `resource` -Data type: `Enum['directory', 'link', 'mounted', 'service', 'file', 'package']` +Data type: `Optional[Enum['directory', 'link', 'mounted', 'service', 'file', 'package']]` -### `stdlib::extname` +### `stdlib::extname` Type: Ruby 4.x API @@ -4812,7 +4881,7 @@ Data type: `String` The Filename -### `stdlib::ip_in_range` +### `stdlib::ip_in_range` Type: Ruby 4.x API @@ -4853,7 +4922,67 @@ Data type: `Variant[String, Array]` One CIDR or an array of CIDRs defining the range(s) to check against -### `stdlib::start_with` +### `stdlib::sha256` + +Type: Ruby 4.x API + +Run a SHA256 calculation against a given value. + +#### Examples + +##### Check a simple string value + +```puppet +stdlib::sha256('my string') == '2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5' +``` + +##### Check a Sensitive datatype + +```puppet +stdlib::sha256(sensitive('my string')) == '2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5' +``` + +##### Check a number + +```puppet +stdlib::sha256(100.0) == '43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0' +stdlib::sha256(100.00000) == '43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0' +``` + +#### `stdlib::sha256(Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]] $my_data)` + +Run a SHA256 calculation against a given value. + +Returns: `String` String + +##### Examples + +###### Check a simple string value + +```puppet +stdlib::sha256('my string') == '2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5' +``` + +###### Check a Sensitive datatype + +```puppet +stdlib::sha256(sensitive('my string')) == '2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5' +``` + +###### Check a number + +```puppet +stdlib::sha256(100.0) == '43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0' +stdlib::sha256(100.00000) == '43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0' +``` + +##### `my_data` + +Data type: `Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]]` + +The ScalarData to evaluate + +### `stdlib::start_with` Type: Ruby 4.x API @@ -4897,7 +5026,7 @@ Data type: `Variant[String[1],Array[String[1], 1]]` The prefixes to check. -### `stdlib::str2resource` +### `stdlib::str2resource` Type: Ruby 4.x API @@ -4947,7 +5076,7 @@ Data type: `String` The string to lookup as a resource -### `stdlib::xml_encode` +### `stdlib::xml_encode` Type: Ruby 4.x API @@ -5408,7 +5537,10 @@ value `true` or `false` ##### `opts` -Data type: `Optional[Struct[{ +Data type: + +```puppet +Optional[Struct[{ indent => Optional[String], space => Optional[String], space_before => Optional[String], @@ -5416,7 +5548,8 @@ object_nl => Optional[String], array_nl => Optional[String], allow_nan => Optional[Boolean], max_nesting => Optional[Integer[-1,default]], -}]]` +}]] +``` hash-map of settings passed to JSON.pretty_generate, see https://ruby-doc.org/stdlib-2.0.0/libdoc/json/rdoc/JSON.html#method-i-generate. @@ -7403,70 +7536,46 @@ Would result in: ["1", "4"], ["2", "5"], ["3", "6"] ## Data types -### `Stdlib::Absolutepath` +### `Stdlib::Absolutepath` A strict absolutepath type -Alias of +Alias of `Variant[Stdlib::Windowspath, Stdlib::Unixpath]` -```puppet -Variant[Stdlib::Windowspath, Stdlib::Unixpath] -``` - -### `Stdlib::Base32` +### `Stdlib::Base32` Type to match base32 String -Alias of - -```puppet -Pattern[/\A[a-z2-7]+={,6}\z/, /\A[A-Z2-7]+={,6}\z/] -``` +Alias of `Pattern[/\A[a-z2-7]+={,6}\z/, /\A[A-Z2-7]+={,6}\z/]` -### `Stdlib::Base64` +### `Stdlib::Base64` Type to match base64 String -Alias of - -```puppet -Pattern[/\A[a-zA-Z0-9\/\+]+={,2}\z/] -``` +Alias of `Pattern[/\A[a-zA-Z0-9\/\+]+={,2}\z/]` -### `Stdlib::Compat::Absolute_path` +### `Stdlib::Compat::Absolute_path` The first pattern is originally from is_absolute_path, which had it from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path? slash = '[\\\\/]' name = '[^\\\\/]+' %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i, -Alias of - -```puppet -Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]] -``` +Alias of `Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]]` -### `Stdlib::Compat::Array` +### `Stdlib::Compat::Array` Emulate the is_array and validate_array functions -Alias of - -```puppet -Array[Any] -``` +Alias of `Array[Any]` -### `Stdlib::Compat::Bool` +### `Stdlib::Compat::Bool` Emulate the is_bool and validate_bool functions -Alias of +Alias of `Boolean` -```puppet -Boolean -``` - -### `Stdlib::Compat::Float` +### `Stdlib::Compat::Float` The regex is what's currently used in is_float To keep your development moving forward, you can also add a deprecation warning using the Integer type: @@ -7486,23 +7595,15 @@ class example(Stdlib::Compat::Float $value) { This allows you to find all places where a consumers of your code call it with unexpected values. -Alias of - -```puppet -Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]] -``` +Alias of `Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]]` -### `Stdlib::Compat::Hash` +### `Stdlib::Compat::Hash` Emulate the is_hash and validate_hash functions -Alias of +Alias of `Hash[Any, Any]` -```puppet -Hash[Any, Any] -``` - -### `Stdlib::Compat::Integer` +### `Stdlib::Compat::Integer` The regex is what's currently used in is_integer validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function. @@ -7526,43 +7627,27 @@ class example(Stdlib::Compat::Integer $value) { This allows you to find all places where a consumers of your code call it with unexpected values. -Alias of +Alias of `Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]]` -```puppet -Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]] -``` - -### `Stdlib::Compat::Ip_address` +### `Stdlib::Compat::Ip_address` Validate an IP address -Alias of - -```puppet -Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6] -``` +Alias of `Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]` -### `Stdlib::Compat::Ipv4` +### `Stdlib::Compat::Ipv4` Emulate the validate_ipv4_address and is_ipv4_address functions -Alias of - -```puppet -Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/] -``` +Alias of `Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/]` -### `Stdlib::Compat::Ipv6` +### `Stdlib::Compat::Ipv6` Validate an IPv6 address -Alias of +Alias of `Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/]` -```puppet -Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/] -``` - -### `Stdlib::Compat::Numeric` +### `Stdlib::Compat::Numeric` The regex is what's currently used in is_numeric validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function. @@ -7586,23 +7671,15 @@ class example(Stdlib::Compat::Numeric $value) { This allows you to find all places where a consumers of your code call it with unexpected values. -Alias of - -```puppet -Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]] -``` +Alias of `Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]]` -### `Stdlib::Compat::String` +### `Stdlib::Compat::String` Emulate the is_string and validate_string functions -Alias of - -```puppet -Optional[String] -``` +Alias of `Optional[String]` -### `Stdlib::CreateResources` +### `Stdlib::CreateResources` A type description used for the create_resources function @@ -7626,95 +7703,65 @@ class myclass ( } ``` -Alias of +Alias of `Hash[String[1], Hash[String[1], Any]]` -```puppet -Hash[String[1], Hash[String[1], Any]] -``` - -### `Stdlib::Datasize` +### `Stdlib::Datasize` Validate the size of data -Alias of - -```puppet -Pattern[/^\d+(?i:[kmgt]b?|b)$/] -``` +Alias of `Pattern[/^\d+(?i:[kmgt]b?|b)$/]` -### `Stdlib::Email` +### `Stdlib::Email` https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address lint:ignore:140chars -Alias of +Alias of `Pattern[/\A[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/]` -```puppet -Pattern[/\A[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/] -``` - -### `Stdlib::Ensure::File` +### `Stdlib::Ensure::File` Validate the value of the ensure parameter for a file -Alias of +Alias of `Enum['present', 'file', 'directory', 'link', 'absent']` -```puppet -Enum['present', 'file', 'directory', 'link', 'absent'] -``` - -### `Stdlib::Ensure::File::Directory` +### `Stdlib::Ensure::File::Directory` Validate the ensure parameter of a "directory" file resource -Alias of +Alias of `Enum['directory', 'absent']` -```puppet -Enum['directory', 'absent'] -``` - -### `Stdlib::Ensure::File::File` +### `Stdlib::Ensure::File::File` Validate the ensure parameter of a "file" file resource -Alias of +Alias of `Enum['file', 'absent']` -```puppet -Enum['file', 'absent'] -``` - -### `Stdlib::Ensure::File::Link` +### `Stdlib::Ensure::File::Link` Validate the ensure parameter of a "link" file resource -Alias of +Alias of `Enum['link', 'absent']` -```puppet -Enum['link', 'absent'] -``` +### `Stdlib::Ensure::Package` -### `Stdlib::Ensure::Service` +Validate the value of the ensure parameter for a package -Validate the value of the ensure parameter of a service resource +Alias of `Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]]` -Alias of +### `Stdlib::Ensure::Service` -```puppet -Enum['stopped', 'running'] -``` +Validate the value of the ensure parameter of a service resource -### `Stdlib::Filemode` +Alias of `Enum['stopped', 'running']` + +### `Stdlib::Filemode` See `man chmod.1` for the regular expression for symbolic mode lint:ignore:140chars -Alias of - -```puppet -Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/] -``` +Alias of `Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/]` -### `Stdlib::Filesource` +### `Stdlib::Filesource` Validate the source parameter on file types @@ -7727,343 +7774,228 @@ Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[ ]] ``` -### `Stdlib::Fqdn` +### `Stdlib::Fqdn` Validate a Fully Qualified Domain Name -Alias of +Alias of `Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/]` -```puppet -Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/] -``` - -### `Stdlib::HTTPSUrl` +### `Stdlib::HTTPSUrl` Validate a HTTPS URL -Alias of +Alias of `Pattern[/(?i:\Ahttps:\/\/.*\z)/]` -```puppet -Pattern[/(?i:\Ahttps:\/\/.*\z)/] -``` - -### `Stdlib::HTTPUrl` +### `Stdlib::HTTPUrl` Validate a HTTP(S) URL -Alias of - -```puppet -Pattern[/(?i:\Ahttps?:\/\/.*\z)/] -``` +Alias of `Pattern[/(?i:\Ahttps?:\/\/.*\z)/]` -### `Stdlib::Host` +### `Stdlib::Host` Validate a host (FQDN or IP address) -Alias of +Alias of `Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]` -```puppet -Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address] -``` +### `Stdlib::Http::Method` -### `Stdlib::HttpStatus` +Valid HTTP method verbs -Validate a HTTP status code +* **See also** + * https://www.iana.org/assignments/http-methods/http-methods.xhtml -Alias of +Alias of `Enum['ACL', 'BASELINE-CONTROL', 'BIND', 'CHECKIN', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LABEL', 'LINK', 'LOCK', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MKREDIRECTREF', 'MKWORKSPACE', 'MOVE', 'OPTIONS', 'ORDERPATCH', 'PATCH', 'POST', 'PRI', 'PROPFIND', 'PROPPATCH', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'TRACE', 'UNBIND', 'UNCHECKOUT', 'UNLINK', 'UNLOCK', 'UPDATE', 'UPDATEREDIRECTREF', 'VERSION-CONTROL']` -```puppet -Integer[100, 599] -``` +### `Stdlib::Http::Status` -### `Stdlib::IP::Address` +A valid HTTP status code per RFC9110 -Validate an IP address +* **See also** + * https://httpwg.org/specs/rfc9110.html#overview.of.status.codes -Alias of +Alias of `Integer[100, 599]` -```puppet -Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6] -``` +### `Stdlib::HttpStatus` -### `Stdlib::IP::Address::Nosubnet` +Validate a HTTP status code -Validate an IP address without subnet +* **See also** + * Stdlib::Http::Status -Alias of +Alias of `Stdlib::Http::Status` -```puppet -Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet] -``` +### `Stdlib::IP::Address` -### `Stdlib::IP::Address::V4` +Validate an IP address -Validate an IPv4 address +Alias of `Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6]` -Alias of +### `Stdlib::IP::Address::Nosubnet` -```puppet -Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet] -``` +Validate an IP address without subnet -### `Stdlib::IP::Address::V4::CIDR` +Alias of `Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet]` -lint:ignore:140chars +### `Stdlib::IP::Address::V4` -Alias of +Validate an IPv4 address -```puppet -Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/] -``` +Alias of `Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet]` -### `Stdlib::IP::Address::V4::Nosubnet` +### `Stdlib::IP::Address::V4::CIDR` lint:ignore:140chars -Alias of +Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/]` -```puppet -Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/] -``` +### `Stdlib::IP::Address::V4::Nosubnet` -### `Stdlib::IP::Address::V6` +lint:ignore:140chars -Validate an IPv6 address +Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]` -Alias of +### `Stdlib::IP::Address::V6` -```puppet -Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet] -``` +Validate an IPv6 address -### `Stdlib::IP::Address::V6::Alternative` +Alias of `Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet]` -lint:ignore:140chars +### `Stdlib::IP::Address::V6::Alternative` -Alias of +lint:ignore:140chars -```puppet -Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/] -``` +Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` -### `Stdlib::IP::Address::V6::CIDR` +### `Stdlib::IP::Address::V6::CIDR` lint:ignore:140chars -Alias of +Alias of `Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/]` -```puppet -Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/] -``` - -### `Stdlib::IP::Address::V6::Compressed` +### `Stdlib::IP::Address::V6::Compressed` Validate a compressed IPv6 address -Alias of +Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` -```puppet -Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/] -``` - -### `Stdlib::IP::Address::V6::Full` +### `Stdlib::IP::Address::V6::Full` Validate a full IPv6 address -Alias of - -```puppet -Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/] -``` +Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` -### `Stdlib::IP::Address::V6::Nosubnet` +### `Stdlib::IP::Address::V6::Nosubnet` Validate an IPv6 address without subnet -Alias of - -```puppet -Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative] -``` +Alias of `Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative]` -### `Stdlib::IP::Address::V6::Nosubnet::Alternative` +### `Stdlib::IP::Address::V6::Nosubnet::Alternative` lint:ignore:140chars -Alias of - -```puppet -Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/] -``` +Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]` -### `Stdlib::IP::Address::V6::Nosubnet::Compressed` +### `Stdlib::IP::Address::V6::Nosubnet::Compressed` Validate compressed IPv6 address without subnet -Alias of +Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, /\A([[:xdigit:]]{1,4}:){7}:\z/]` -```puppet -Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, /\A([[:xdigit:]]{1,4}:){7}:\z/] -``` - -### `Stdlib::IP::Address::V6::Nosubnet::Full` +### `Stdlib::IP::Address::V6::Nosubnet::Full` Validate full IPv6 address without subnet -Alias of - -```puppet -Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/] -``` +Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/]` -### `Stdlib::MAC` +### `Stdlib::MAC` A type for a MAC address -Alias of +Alias of `Pattern[/\A([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})\z/, /\A([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})\z/]` -```puppet -Pattern[/\A([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})\z/, /\A([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})\z/] -``` - -### `Stdlib::ObjectStore` +### `Stdlib::ObjectStore` Validate an ObjectStore -Alias of - -```puppet -Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri] -``` +Alias of `Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri]` -### `Stdlib::ObjectStore::GSUri` +### `Stdlib::ObjectStore::GSUri` Validate a Google Cloud object store URI -Alias of - -```puppet -Pattern[/\Ags:\/\/.*\z/] -``` +Alias of `Pattern[/\Ags:\/\/.*\z/]` -### `Stdlib::ObjectStore::S3Uri` +### `Stdlib::ObjectStore::S3Uri` Validate an Amazon Web Services S3 object store URI -Alias of +Alias of `Pattern[/\As3:\/\/.*\z/]` -```puppet -Pattern[/\As3:\/\/.*\z/] -``` - -### `Stdlib::Port` +### `Stdlib::Port` Validate a port number -Alias of +Alias of `Integer[0, 65535]` -```puppet -Integer[0, 65535] -``` - -### `Stdlib::Port::Dynamic` +### `Stdlib::Port::Dynamic` Validate a dynamic port number -Alias of - -```puppet -Integer[49152, 65535] -``` +Alias of `Integer[49152, 65535]` -### `Stdlib::Port::Ephemeral` +### `Stdlib::Port::Ephemeral` Validate an ephemeral port number -Alias of - -```puppet -Stdlib::Port::Dynamic -``` +Alias of `Stdlib::Port::Dynamic` -### `Stdlib::Port::Privileged` +### `Stdlib::Port::Privileged` Validate a priviliged port number -Alias of - -```puppet -Integer[1, 1023] -``` +Alias of `Integer[1, 1023]` -### `Stdlib::Port::Registered` +### `Stdlib::Port::Registered` Validate a registered port number -Alias of - -```puppet -Stdlib::Port::User -``` +Alias of `Stdlib::Port::User` -### `Stdlib::Port::Unprivileged` +### `Stdlib::Port::Unprivileged` Validate an unprivileged port number -Alias of +Alias of `Integer[1024, 65535]` -```puppet -Integer[1024, 65535] -``` - -### `Stdlib::Port::User` +### `Stdlib::Port::User` Validate a port number usable by a user -Alias of +Alias of `Integer[1024, 49151]` -```puppet -Integer[1024, 49151] -``` - -### `Stdlib::Syslogfacility` +### `Stdlib::Syslogfacility` Validate a syslog facility -Alias of - -```puppet -Enum['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7'] -``` +Alias of `Enum['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7']` -### `Stdlib::Unixpath` +### `Stdlib::Unixpath` this regex rejects any path component that does not start with "/" or is NUL -Alias of +Alias of `Pattern[/\A\/([^\n\/\0]+\/*)*\z/]` -```puppet -Pattern[/\A\/([^\n\/\0]+\/*)*\z/] -``` - -### `Stdlib::Windowspath` +### `Stdlib::Windowspath` Validate a Windows path -Alias of - -```puppet -Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/] -``` +Alias of `Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/]` -### `Stdlib::Yes_no` +### `Stdlib::Yes_no` Validate a yes / no value -Alias of - -```puppet -Pattern[/\A(?i:(yes|no))\z/] -``` +Alias of `Pattern[/\A(?i:(yes|no))\z/]` diff --git a/functions/ensure.pp b/functions/ensure.pp index b4ea17b2c..9b63d44e5 100644 --- a/functions/ensure.pp +++ b/functions/ensure.pp @@ -3,7 +3,7 @@ # @return [String] function stdlib::ensure( Variant[Boolean, Enum['present', 'absent']] $ensure, - Enum['directory', 'link', 'mounted', 'service', 'file', 'package'] $resource, + Optional[Enum['directory', 'link', 'mounted', 'service', 'file', 'package']] $resource = undef, ) >> String { $_ensure = $ensure ? { Boolean => $ensure.bool2str('present', 'absent'), @@ -22,6 +22,7 @@ function stdlib::ensure( default => 'stopped', } } + undef: { $_ensure } default: { $_ensure ? { 'present' => $resource, diff --git a/lib/facter/root_home.rb b/lib/facter/root_home.rb index 0e1764254..c44d64a7b 100644 --- a/lib/facter/root_home.rb +++ b/lib/facter/root_home.rb @@ -6,6 +6,6 @@ rescue LoadError # Unavailable on platforms like Windows else - Etc.getpwnam('root').dir + Etc.getpwnam('root')&.dir end end diff --git a/lib/puppet/functions/ensure_packages.rb b/lib/puppet/functions/ensure_packages.rb index 5cfbd5a37..321667c67 100644 --- a/lib/puppet/functions/ensure_packages.rb +++ b/lib/puppet/functions/ensure_packages.rb @@ -6,34 +6,56 @@ # third argument to the ensure_resource() function. Puppet::Functions.create_function(:ensure_packages, Puppet::Functions::InternalFunction) do # @param packages - # The packages to ensure are installed. If it's a Hash it will be passed to `ensure_resource` + # The packages to ensure are installed. # @param default_attributes # Default attributes to be passed to the `ensure_resource()` function # @return [Undef] Returns nothing. dispatch :ensure_packages do scope_param - param 'Variant[String[1], Array[String[1]], Hash[String[1], Any]]', :packages + param 'Variant[String[1], Array[String[1]]]', :packages optional_param 'Hash', :default_attributes return_type 'Undef' end - def ensure_packages(scope, packages, default_attributes = nil) - if default_attributes + # @param packages + # The packages to ensure are installed. The keys are packages and values are the attributes specific to that package. + # @param default_attributes + # Default attributes. Package specific attributes from the `packages` parameter will take precedence. + # @return [Undef] Returns nothing. + dispatch :ensure_packages_hash do + scope_param + param 'Hash[String[1], Any]', :packages + optional_param 'Hash', :default_attributes + return_type 'Undef' + end + + def ensure_packages(scope, packages, default_attributes = {}) + Array(packages).each do |package_name| defaults = { 'ensure' => 'installed' }.merge(default_attributes) - if defaults['ensure'] == 'present' - defaults['ensure'] = 'installed' - end - else - defaults = { 'ensure' => 'installed' } + + # `present` and `installed` are aliases for the `ensure` attribute. If `ensure` is set to either of these values replace + # with `installed` by default but `present` if this package is already in the catalog with `ensure => present` + defaults['ensure'] = default_ensure(package_name) if ['present', 'installed'].include?(defaults['ensure']) + + scope.call_function('ensure_resource', ['package', package_name, defaults]) end + nil + end - if packages.is_a?(Hash) - scope.call_function('ensure_resources', ['package', packages.dup, defaults]) - else - Array(packages).each do |package_name| - scope.call_function('ensure_resource', ['package', package_name, defaults]) - end + def ensure_packages_hash(scope, packages, default_attributes = {}) + packages.each do |package, attributes| + ensure_packages(scope, package, default_attributes.merge(attributes)) end nil end + + private + + def default_ensure(package_name) + if call_function('defined_with_params', "Package[#{package_name}]", { 'ensure' => 'present' }) + 'present' + else + 'installed' + end + end end diff --git a/lib/puppet/functions/stdlib/crc32.rb b/lib/puppet/functions/stdlib/crc32.rb new file mode 100644 index 000000000..36b2a6ca7 --- /dev/null +++ b/lib/puppet/functions/stdlib/crc32.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'zlib' +# @note +# The CRC32 algorithm can easily generate collisions, +# but may be useful for generating sharding, describing +# secrets, or seeding nonce values. +# +# @summary +# Run a CRC32 calculation against a given value. +Puppet::Functions.create_function(:'stdlib::crc32') do + # @param my_data The ScalarData to evaluate + # @example Check a simple string value + # stdlib::crc32('my string') == '18fbd270' + # @example Check a Sensitive datatype + # stdlib::crc32(sensitive('my string')) == '18fbd270' + # @example Check a number + # stdlib::crc32(100.0) == 'a3fd429a' + # stdlib::crc32(100.00000) == 'a3fd429a' + # @return String + dispatch :crc32 do + param 'Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]]', :my_data + return_type 'String' + end + + def crc32(my_data) + Zlib.crc32(my_data.unwrap.to_s).to_s(16).downcase + rescue + Zlib.crc32(my_data.to_s).to_s(16).downcase + end +end diff --git a/lib/puppet/functions/stdlib/sha256.rb b/lib/puppet/functions/stdlib/sha256.rb new file mode 100644 index 000000000..4b9b6c24a --- /dev/null +++ b/lib/puppet/functions/stdlib/sha256.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'digest' +# @summary +# Run a SHA256 calculation against a given value. +Puppet::Functions.create_function(:'stdlib::sha256') do + # @param my_data The ScalarData to evaluate + # @example Check a simple string value + # stdlib::sha256('my string') == '2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5' + # @example Check a Sensitive datatype + # stdlib::sha256(sensitive('my string')) == '2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5' + # @example Check a number + # stdlib::sha256(100.0) == '43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0' + # stdlib::sha256(100.00000) == '43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0' + # @return String + dispatch :sha256 do + param 'Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]]', :my_data + return_type 'String' + end + + def sha256(my_data) + Digest::SHA256.hexdigest(my_data.unwrap.to_s) + rescue + Digest::SHA256.hexdigest(my_data.to_s) + end +end diff --git a/metadata.json b/metadata.json index 98f6317e7..f5687f33a 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "8.5.0", + "version": "8.6.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", @@ -100,11 +100,11 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.0.0 < 8.0.0" + "version_requirement": ">= 5.5.10 < 8.0.0" } ], "description": "Standard Library for Puppet Modules", "pdk-version": "2.5.0", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "tags/2.6.0-0-gd0490b9" + "template-ref": "2.7.1-0-g9a16c87" } diff --git a/provision.yaml b/provision.yaml index 26913e472..b9b4ed732 100644 --- a/provision.yaml +++ b/provision.yaml @@ -15,6 +15,12 @@ travis_deb: - litmusimage/debian:8 - litmusimage/debian:9 - litmusimage/debian:10 +travis_ub_5: + provisioner: docker + images: + - litmusimage/ubuntu:14.04 + - litmusimage/ubuntu:16.04 + - litmusimage/ubuntu:18.04 travis_ub_6: provisioner: docker images: @@ -32,6 +38,36 @@ travis_el8: provisioner: docker images: - litmusimage/centos:8 +release_checks_5: + provisioner: abs + images: + - redhat-6-x86_64 + - redhat-7-x86_64 + - redhat-8-x86_64 + - centos-6-x86_64 + - centos-7-x86_64 + - centos-8-x86_64 + - oracle-5-x86_64 + - oracle-6-x86_64 + - oracle-7-x86_64 + - scientific-6-x86_64 + - scientific-7-x86_64 + - debian-8-x86_64 + - debian-9-x86_64 + - debian-10-x86_64 + - sles-12-x86_64 + - ubuntu-1404-x86_64 + - ubuntu-1604-x86_64 + - ubuntu-1804-x86_64 + - win-2008-x86_64 + - win-2008r2-x86_64 + - win-2012-x86_64 + - win-2012r2-x86_64 + - win-2016-x86_64 + - win-2019-x86_64 + - win-7-x86_64 + - win-81-x86_64 + - win-10-pro-x86_64 release_checks_6: provisioner: abs images: diff --git a/spec/functions/crc32_spec.rb b/spec/functions/crc32_spec.rb new file mode 100644 index 000000000..ed82ae2fc --- /dev/null +++ b/spec/functions/crc32_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'stdlib::crc32' do + context 'when default' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{stdlib::crc32}) } + end + + context 'when testing a simple string' do + it { is_expected.to run.with_params('abc').and_return('352441c2') } + it { is_expected.to run.with_params('acb').and_return('5b384015') } + it { is_expected.to run.with_params('my string').and_return('18fbd270') } + it { is_expected.to run.with_params('0').and_return('f4dbdf21') } + end + + context 'when testing a sensitive string' do + it { is_expected.to run.with_params(sensitive('my string')).and_return('18fbd270') } + end + + context 'when testing an integer' do + it { is_expected.to run.with_params(0).and_return('f4dbdf21') } + it { is_expected.to run.with_params(100).and_return('237750ea') } + it { is_expected.to run.with_params(sensitive(100)).and_return('237750ea') } + end + + context 'when testing a float' do + it { is_expected.to run.with_params(200.3).and_return('7d5469f0') } + + # .0 isn't always converted into an integer, but should have rational truncation + it { is_expected.to run.with_params(100.0).and_return('a3fd429a') } + it { is_expected.to run.with_params(sensitive(100.0000)).and_return('a3fd429a') } + end + + context 'when testing a bool' do + it { is_expected.to run.with_params(true).and_return('fdfc4c8d') } + it { is_expected.to run.with_params(false).and_return('2bcd6830') } + end + + context 'when testing a binary' do + it { is_expected.to run.with_params("\xFE\xED\xBE\xEF").and_return('ac3481a4') } + end +end diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 346e13685..326857bbd 100644 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -32,6 +32,14 @@ subject.execute({ 'foo' => { 'provider' => 'rpm' }, 'bar' => { 'provider' => 'gem' } }, 'ensure' => 'present') subject.execute('パッケージ' => { 'ensure' => 'absent' }) subject.execute('ρǻ¢κầģẻ' => { 'ensure' => 'absent' }) + subject.execute( + { + 'package_one' => {}, + 'package_two' => {}, + 'package_three' => { 'provider' => 'puppetserver_gem' }, + }, + { 'provider' => 'puppet_gem' }, + ) end # this lambda is required due to strangeness within rspec-puppet's expectation handling @@ -42,6 +50,14 @@ it { expect(-> { catalogue }).to contain_package('パッケージ').with('ensure' => 'absent') } it { expect(-> { catalogue }).to contain_package('ρǻ¢κầģẻ').with('ensure' => 'absent') } end + + describe 'default attributes' do + it 'package specific attributes take precedence' do + expect(-> { catalogue }).to contain_package('package_one').with('provider' => 'puppet_gem') + expect(-> { catalogue }).to contain_package('package_two').with('provider' => 'puppet_gem') + expect(-> { catalogue }).to contain_package('package_three').with('provider' => 'puppetserver_gem') + end + end end context 'when given a catalog with "package { puppet: ensure => installed }"' do @@ -54,4 +70,26 @@ it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('installed') } end end + + context 'when given a catalog with "package { puppet: ensure => present }"' do + let(:pre_condition) { 'package { puppet: ensure => present }' } + + describe 'after running ensure_package("puppet", { "ensure" => "present" })' do + before(:each) { subject.execute('puppet', 'ensure' => 'present') } + + it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') } + end + + describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do + before(:each) { subject.execute('puppet', 'ensure' => 'installed') } + + it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') } + end + + describe 'after running ensure_package(["puppet"])' do + before(:each) { subject.execute(['puppet']) } + + it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') } + end + end end diff --git a/spec/functions/fqdn_rand_string_spec.rb b/spec/functions/fqdn_rand_string_spec.rb index 1102b87f8..9eed4ad04 100644 --- a/spec/functions/fqdn_rand_string_spec.rb +++ b/spec/functions/fqdn_rand_string_spec.rb @@ -57,7 +57,11 @@ def fqdn_rand_string(max, args = {}) # workaround not being able to use let(:facts) because some tests need # multiple different hostnames in one context - allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host) + if Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('7.23.0') + allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host) + else + allow(scope).to receive(:lookupvar).with('facts', {}).and_return({ 'networking' => { 'fqdn' => host } }) + end function_args = [max] if args.key?(:charset) || !extra.empty? diff --git a/spec/functions/sha256_spec.rb b/spec/functions/sha256_spec.rb new file mode 100644 index 000000000..423fb0095 --- /dev/null +++ b/spec/functions/sha256_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'stdlib::sha256' do + context 'when default' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{stdlib::sha256}) } + end + + context 'when testing a simple string' do + it { is_expected.to run.with_params('abc').and_return('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad') } + it { is_expected.to run.with_params('acb').and_return('8e9766083b3bfc2003f791c9853941b0ea035d16379bfec16b72d376e272fa57') } + it { is_expected.to run.with_params('my string').and_return('2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5') } + it { is_expected.to run.with_params('0').and_return('5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9') } + end + + context 'when testing a sensitive string' do + it { is_expected.to run.with_params(sensitive('my string')).and_return('2f7e2089add0288a309abd71ffcc3b3567e2d4215e20e6ed3b74d6042f7ef8e5') } + end + + context 'when testing an integer' do + it { is_expected.to run.with_params(0).and_return('5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9') } + it { is_expected.to run.with_params(100).and_return('ad57366865126e55649ecb23ae1d48887544976efea46a48eb5d85a6eeb4d306') } + it { is_expected.to run.with_params(sensitive(100)).and_return('ad57366865126e55649ecb23ae1d48887544976efea46a48eb5d85a6eeb4d306') } + end + + context 'when testing a float' do + it { is_expected.to run.with_params(200.3).and_return('441adfa0dd670f4193e4b6e4e373bd7fd3861ee53c834c562b825af79bf7dc98') } + + # .0 isn't always converted into an integer, but should have rational truncation + it { is_expected.to run.with_params(100.0).and_return('43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0') } + it { is_expected.to run.with_params(sensitive(100.0000)).and_return('43b87f618caab482ebe4976c92bcd6ad308b48055f1c27b4c574f3e31d7683e0') } + end + + context 'when testing a bool' do + it { is_expected.to run.with_params(true).and_return('b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b') } + it { is_expected.to run.with_params(false).and_return('fcbcf165908dd18a9e49f7ff27810176db8e9f63b4352213741664245224f8aa') } + end + + context 'when testing a binary' do + it { is_expected.to run.with_params("\xFE\xED\xBE\xEF").and_return('bf6b255a261ddde9ea66060dcb239e06d321ad37755d2a97a5846f5144b779b4') } + end +end diff --git a/spec/functions/stdlib_ensure_spec.rb b/spec/functions/stdlib_ensure_spec.rb index 2c296c3ec..f4e5f7935 100644 --- a/spec/functions/stdlib_ensure_spec.rb +++ b/spec/functions/stdlib_ensure_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' describe 'stdlib::ensure' do + context 'work without resource' do + it { is_expected.to run.with_params(true).and_return('present') } + it { is_expected.to run.with_params(false).and_return('absent') } + end context 'work with service resource' do it { is_expected.to run.with_params('present', 'service').and_return('running') } it { is_expected.to run.with_params(true, 'service').and_return('running') } diff --git a/spec/type_aliases/ensure_package_spec.rb b/spec/type_aliases/ensure_package_spec.rb new file mode 100644 index 000000000..a907747e2 --- /dev/null +++ b/spec/type_aliases/ensure_package_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Stdlib::Ensure::Package' do + describe 'valid handling' do + [ + 'present', + 'absent', + 'purged', + 'disabled', + 'installed', + 'latest', + '1', + '1.1', + '>=6.0', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + describe 'No complex types can match' do + context 'Garbage inputs, no complex or non string types can match' do + [ + 1, + 1.1, + [1.1], + '', + { 'foo' => 'bar' }, + {}, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/http__method_spec.rb b/spec/type_aliases/http__method_spec.rb new file mode 100644 index 000000000..e80d02027 --- /dev/null +++ b/spec/type_aliases/http__method_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'Stdlib::Http::Method' do + describe 'valid HTTP Methods' do + [ + 'HEAD', + 'GET', + 'PUT', + 'DELETE', + 'TRACE', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid path handling' do + context 'garbage inputs' do + [ + nil, + [nil], + [nil, nil], + { 'foo' => 'bar' }, + {}, + '', + 'https', + '199', + 600, + 1_000, + 'Ok', + 'get', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/http__status_spec.rb b/spec/type_aliases/http__status_spec.rb new file mode 100644 index 000000000..123612fc3 --- /dev/null +++ b/spec/type_aliases/http__status_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe 'Stdlib::Http::Status' do + describe 'valid HTTP Status' do + [ + 200, + 302, + 404, + 418, + 503, + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid path handling' do + context 'garbage inputs' do + [ + nil, + [nil], + [nil, nil], + { 'foo' => 'bar' }, + {}, + '', + 'https', + '199', + 600, + 1_000, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/types/ensure/package.pp b/types/ensure/package.pp new file mode 100644 index 000000000..3f6ad47c7 --- /dev/null +++ b/types/ensure/package.pp @@ -0,0 +1,2 @@ +# @summary Validate the value of the ensure parameter for a package +type Stdlib::Ensure::Package = Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] diff --git a/types/http/method.pp b/types/http/method.pp new file mode 100644 index 000000000..3b50ff0b8 --- /dev/null +++ b/types/http/method.pp @@ -0,0 +1,43 @@ +# @summary Valid HTTP method verbs +# @see https://www.iana.org/assignments/http-methods/http-methods.xhtml +type Stdlib::Http::Method = Enum[ + 'ACL', + 'BASELINE-CONTROL', + 'BIND', + 'CHECKIN', + 'CHECKOUT', + 'CONNECT', + 'COPY', + 'DELETE', + 'GET', + 'HEAD', + 'LABEL', + 'LINK', + 'LOCK', + 'MERGE', + 'MKACTIVITY', + 'MKCALENDAR', + 'MKCOL', + 'MKREDIRECTREF', + 'MKWORKSPACE', + 'MOVE', + 'OPTIONS', + 'ORDERPATCH', + 'PATCH', + 'POST', + 'PRI', + 'PROPFIND', + 'PROPPATCH', + 'PUT', + 'REBIND', + 'REPORT', + 'SEARCH', + 'TRACE', + 'UNBIND', + 'UNCHECKOUT', + 'UNLINK', + 'UNLOCK', + 'UPDATE', + 'UPDATEREDIRECTREF', + 'VERSION-CONTROL', +] diff --git a/types/http/status.pp b/types/http/status.pp new file mode 100644 index 000000000..08a23fdc7 --- /dev/null +++ b/types/http/status.pp @@ -0,0 +1,3 @@ +# @summary A valid HTTP status code per RFC9110 +# @see https://httpwg.org/specs/rfc9110.html#overview.of.status.codes +type Stdlib::Http::Status = Integer[100, 599] diff --git a/types/httpstatus.pp b/types/httpstatus.pp index 4199d8acf..1a73221eb 100644 --- a/types/httpstatus.pp +++ b/types/httpstatus.pp @@ -1,2 +1,4 @@ # @summary Validate a HTTP status code -type Stdlib::HttpStatus = Integer[100, 599] +# @deprecated Use Stdlib::Http::Status +# @see Stdlib::Http::Status +type Stdlib::HttpStatus = Stdlib::Http::Status