puppetlabs-inifile-5.4.00040755000000000000000000000000014316557456012207 5ustar00puppetlabs-inifile-5.4.0/.github0040755000000000000000000000000014316557456013547 5ustar00puppetlabs-inifile-5.4.0/.github/workflows0040755000000000000000000000000014316557456015604 5ustar00puppetlabs-inifile-5.4.0/.github/workflows/auto_release.yml0100644000175100001710000000701414316557455021103 0ustar00name: "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' puppetlabs-inifile-5.4.0/.github/workflows/labeller.yml0100644000175100001710000000065614316557455020222 0ustar00name: community-labeller on: issues: types: - opened pull_request_target: types: - opened jobs: label: runs-on: ubuntu-latest steps: - uses: puppetlabs/community-labeller@v0 name: Label issues or pull requests with: label_name: community label_color: '5319e7' org_membership: puppetlabs token: ${{ secrets.IAC_COMMUNITY_LABELER }} puppetlabs-inifile-5.4.0/.github/workflows/nightly.yml0100644000175100001710000001556514316557455020123 0ustar00name: "nightly" on: schedule: - cron: '0 0 * * *' env: HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 HONEYCOMB_DATASET: litmus tests jobs: setup_matrix: if: ${{ github.repository_owner == 'puppetlabs' }} name: "Setup Test Matrix" runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.get-matrix.outputs.matrix }} steps: - name: "Honeycomb: Start recording" uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} - name: "Honeycomb: Start first step" run: | echo STEP_ID=setup-environment >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Checkout Source uses: actions/checkout@v2 if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: ruby-version: "2.7" bundler-cache: true - name: Print bundle environment if: ${{ github.repository_owner == 'puppetlabs' }} run: | echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Setup Environment time" if: ${{ github.repository_owner == 'puppetlabs' }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Setup Acceptance Test Matrix id: get-matrix if: ${{ github.repository_owner == 'puppetlabs' }} run: | if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 else echo "::set-output name=matrix::{}" fi - name: "Honeycomb: Record Setup Test Matrix time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' Acceptance: name: "${{matrix.platforms.label}}, ${{matrix.collection}}" needs: - setup_matrix runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} env: BUILDEVENT_FILE: '../buildevents.txt' steps: - run: | echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE - name: "Honeycomb: Start recording" uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }} - name: "Honeycomb: start first step" run: | echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Checkout Source uses: actions/checkout@v2 - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 with: ruby-version: "2.7" bundler-cache: true - name: Print bundle environment run: | echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Setup Environment time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Provision test environment run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: echo ::group::=== INVENTORY === if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; then FILE='spec/fixtures/litmus_inventory.yaml' elif [ -f 'inventory.yaml' ]; then FILE='inventory.yaml' fi sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true echo ::endgroup:: - name: Install agent run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - name: Install module run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' - name: "Honeycomb: Record deployment times" if: ${{ always() }} run: | echo ::group::honeycomb step buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV echo ::endgroup:: - name: Run acceptance tests run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' - name: "Honeycomb: Record acceptance testing times" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Remove test environment if: ${{ always() }} continue-on-error: true run: | if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: fi - name: "Honeycomb: Record removal times" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' slack-workflow-status: if: ${{ github.repository_owner == 'puppetlabs' }} name: Post Workflow Status To Slack needs: - Acceptance runs-on: ubuntu-20.04 steps: - name: Slack Workflow Notification uses: puppetlabs/Gamesight-slack-workflow-status@pdk-templates-v1 with: # Required Input repo_token: ${{ secrets.GITHUB_TOKEN }} slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} # Optional Input channel: '#team-cat-bots' name: 'GABot' puppetlabs-inifile-5.4.0/.github/workflows/pr_test.yml0100644000175100001710000001463114316557455020116 0ustar00name: "PR Testing" on: [pull_request] env: HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 HONEYCOMB_DATASET: litmus tests jobs: setup_matrix: name: "Setup Test Matrix" runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.get-matrix.outputs.matrix }} steps: - name: "Honeycomb: Start recording" uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} - name: "Honeycomb: Start first step" run: | echo STEP_ID=setup-environment >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Checkout Source uses: actions/checkout@v2 if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: ruby-version: "2.7" bundler-cache: true - name: Print bundle environment if: ${{ github.repository_owner == 'puppetlabs' }} run: | echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Setup Environment time" if: ${{ github.repository_owner == 'puppetlabs' }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Run validation steps run: | bundle exec rake validate if: ${{ github.repository_owner == 'puppetlabs' }} - name: Setup Acceptance Test Matrix id: get-matrix run: | if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 else echo "::set-output name=matrix::{}" fi - name: "Honeycomb: Record Setup Test Matrix time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' Acceptance: name: "${{matrix.platforms.label}}, ${{matrix.collection}}" needs: - setup_matrix if: ${{ needs.setup_matrix.outputs.matrix != '{}' }} runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} env: BUILDEVENT_FILE: '../buildevents.txt' steps: - run: | echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE - name: "Honeycomb: Start recording" uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }} - name: "Honeycomb: start first step" run: | echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Checkout Source uses: actions/checkout@v2 - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 with: ruby-version: "2.7" bundler-cache: true - name: Print bundle environment run: | echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Setup Environment time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Provision test environment run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: echo ::group::=== INVENTORY === if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; then FILE='spec/fixtures/litmus_inventory.yaml' elif [ -f 'inventory.yaml' ]; then FILE='inventory.yaml' fi sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true echo ::endgroup:: - name: Install agent run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - name: Install module run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' - name: "Honeycomb: Record deployment times" if: ${{ always() }} run: | echo ::group::honeycomb step buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV echo ::endgroup:: - name: Run acceptance tests run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' - name: "Honeycomb: Record acceptance testing times" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Remove test environment if: ${{ always() }} continue-on-error: true run: | if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: fi - name: "Honeycomb: Record removal times" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' puppetlabs-inifile-5.4.0/.github/workflows/release.yml0100644000175100001710000000227314316557455020055 0ustar00name: "Publish module" on: workflow_dispatch: jobs: create-github-release: name: Deploy GitHub Release runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 with: ref: ${{ github.ref }} clean: true fetch-depth: 0 - name: Get Version id: gv run: | echo "::set-output name=ver::$(jq --raw-output .version metadata.json)" - name: Create Release uses: actions/create-release@v1 id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: "v${{ steps.gv.outputs.ver }}" draft: false prerelease: false deploy-forge: name: Deploy to Forge runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 with: ref: ${{ github.ref }} clean: true - name: "PDK Build" uses: docker://puppet/pdk:nightly with: args: 'build' - name: "Push to Forge" uses: docker://puppet/pdk:nightly with: args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force' puppetlabs-inifile-5.4.0/.github/workflows/spec.yml0100644000175100001710000001054714316557455017372 0ustar00name: "Spec Tests" on: schedule: - cron: '0 0 * * *' workflow_dispatch: pull_request: env: HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 HONEYCOMB_DATASET: litmus tests jobs: setup_matrix: name: "Setup Test Matrix" runs-on: ubuntu-20.04 outputs: spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }} steps: - name: "Honeycomb: Start recording" uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} - name: "Honeycomb: Start first step" run: | echo STEP_ID=setup-environment >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Checkout Source uses: actions/checkout@v2 if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: ruby-version: "2.7" bundler-cache: true - name: Print bundle environment if: ${{ github.repository_owner == 'puppetlabs' }} run: | echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Setup Environment time" if: ${{ github.repository_owner == 'puppetlabs' }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment' echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Run Static & Syntax Tests if: ${{ github.repository_owner == 'puppetlabs' }} run: | buildevents cmd $TRACE_ID $STEP_ID 'static_syntax_checks' -- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - name: Setup Spec Test Matrix id: get-matrix run: | if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata_v2 else echo "::set-output name=spec_matrix::{}" fi - name: "Honeycomb: Record Setup Test Matrix time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' Spec: name: "Spec Tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})" needs: - setup_matrix if: ${{ needs.setup_matrix.outputs.spec_matrix != '{}' }} runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: ${{fromJson(needs.setup_matrix.outputs.spec_matrix)}} env: BUILDEVENT_FILE: '../buildevents.txt' PUPPET_GEM_VERSION: ${{ matrix.puppet_version }} FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' steps: - run: | echo "SANITIZED_PUPPET_VERSION=$(echo '${{ matrix.puppet_version }}' | sed 's/~> //g')" >> $GITHUB_ENV - run: | echo 'puppet_version=${{ env.SANITIZED_PUPPET_VERSION }}' >> $BUILDEVENT_FILE - name: "Honeycomb: Start first step" run: | echo "STEP_ID=${{ env.SANITIZED_PUPPET_VERSION }}-spec" >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: "Honeycomb: Start recording" uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} matrix-key: ${{ env.SANITIZED_PUPPET_VERSION }} - name: Checkout Source uses: actions/checkout@v2 - name: "Activate Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby_version}} bundler-cache: true - name: Print bundle environment run: | echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: Run parallel_spec tests run: | buildevents cmd $TRACE_ID $STEP_ID 'rake parallel_spec Puppet ${{ matrix.puppet_version }}, Ruby ${{ matrix.ruby_version }}' -- bundle exec rake parallel_spec puppetlabs-inifile-5.4.0/.github/workflows/stale.yml0100644000175100001710000000277014316557455017547 0ustar00name: 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' puppetlabs-inifile-5.4.0/.gitpod.Dockerfile0100644000175100001710000000227514316557455015654 0ustar00FROM gitpod/workspace-full RUN sudo wget https://apt.puppet.com/puppet-tools-release-bionic.deb && \ wget https://apt.puppetlabs.com/puppet6-release-bionic.deb && \ sudo dpkg -i puppet6-release-bionic.deb && \ sudo dpkg -i puppet-tools-release-bionic.deb && \ sudo apt-get update && \ sudo apt-get install -y pdk zsh puppet-agent && \ sudo apt-get clean && \ sudo rm -rf /var/lib/apt/lists/* RUN sudo usermod -s $(which zsh) gitpod && \ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ echo "plugins=(git gitignore github gem pip bundler python ruby docker docker-compose)" >> /home/gitpod/.zshrc && \ echo 'PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin"' >> /home/gitpod/.zshrc && \ sudo /opt/puppetlabs/puppet/bin/gem install puppet-debugger hub -N && \ mkdir -p /home/gitpod/.config/puppet && \ /opt/puppetlabs/puppet/bin/ruby -r yaml -e "puts ({'disabled' => true}).to_yaml" > /home/gitpod/.config/puppet/analytics.yml RUN rm -f puppet6-release-bionic.deb puppet-tools-release-bionic.deb ENTRYPOINT /usr/bin/zsh puppetlabs-inifile-5.4.0/.gitpod.yml0100644000175100001710000000023014316557455014373 0ustar00image: file: .gitpod.Dockerfile tasks: - init: pdk bundle install vscode: extensions: - puppet.puppet-vscode@1.2.0:f5iEPbmOj6FoFTOV6q8LTg== puppetlabs-inifile-5.4.0/CHANGELOG.md0100644000175100001710000005236614316557455014136 0ustar00# Change log 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). ## [v5.4.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v5.4.0) (2022-10-03) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v5.3.0...v5.4.0) ### Added - pdksync - \(GH-cat-11\) Certify Support for Ubuntu 22.04 [\#484](https://github.com/puppetlabs/puppetlabs-inifile/pull/484) ([david22swan](https://github.com/david22swan)) - pdksync - \(GH-cat-12\) Add Support for Redhat 9 [\#480](https://github.com/puppetlabs/puppetlabs-inifile/pull/480) ([david22swan](https://github.com/david22swan)) ### Fixed - \(MAINT\) Drop support for Solaris 10, Windows Server 2008 R2, and AIX 5.3 and 6.1 [\#485](https://github.com/puppetlabs/puppetlabs-inifile/pull/485) ([jordanbreen28](https://github.com/jordanbreen28)) - Fix broken idempotency with empty sections [\#483](https://github.com/puppetlabs/puppetlabs-inifile/pull/483) ([kajinamit](https://github.com/kajinamit)) ## [v5.3.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v5.3.0) (2022-05-23) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v5.2.0...v5.3.0) ### Added - pdksync - \(FM-8922\) - Add Support for Windows 2022 [\#468](https://github.com/puppetlabs/puppetlabs-inifile/pull/468) ([david22swan](https://github.com/david22swan)) - pdksync - \(IAC-1753\) - Add Support for AlmaLinux 8 [\#463](https://github.com/puppetlabs/puppetlabs-inifile/pull/463) ([david22swan](https://github.com/david22swan)) - pdksync - \(IAC-1751\) - Add Support for Rocky 8 [\#462](https://github.com/puppetlabs/puppetlabs-inifile/pull/462) ([david22swan](https://github.com/david22swan)) - match section names containing prefix character \(normally \[\) [\#457](https://github.com/puppetlabs/puppetlabs-inifile/pull/457) ([tja523](https://github.com/tja523)) ### Fixed - pdksync - \(GH-iac-334\) Remove Support for Ubuntu 14.04/16.04 [\#471](https://github.com/puppetlabs/puppetlabs-inifile/pull/471) ([david22swan](https://github.com/david22swan)) - pdksync - \(IAC-1787\) Remove Support for CentOS 6 [\#466](https://github.com/puppetlabs/puppetlabs-inifile/pull/466) ([david22swan](https://github.com/david22swan)) - pdksync - \(IAC-1598\) - Remove Support for Debian 8 [\#461](https://github.com/puppetlabs/puppetlabs-inifile/pull/461) ([david22swan](https://github.com/david22swan)) ## [v5.2.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v5.2.0) (2021-08-26) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v5.1.0...v5.2.0) ### Added - pdksync - \(IAC-1709\) - Add Support for Debian 11 [\#458](https://github.com/puppetlabs/puppetlabs-inifile/pull/458) ([david22swan](https://github.com/david22swan)) ### Fixed - \(IAC-1741\) Allow stdlib v8.0.0 [\#459](https://github.com/puppetlabs/puppetlabs-inifile/pull/459) ([david22swan](https://github.com/david22swan)) ## [v5.1.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v5.1.0) (2021-06-28) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v5.0.1...v5.1.0) ### Added - Accept Datatype Sensitive [\#454](https://github.com/puppetlabs/puppetlabs-inifile/pull/454) ([cocker-cc](https://github.com/cocker-cc)) ## [v5.0.1](https://github.com/puppetlabs/puppetlabs-inifile/tree/v5.0.1) (2021-03-29) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v5.0.0...v5.0.1) ### Fixed - \(IAC-149\) - Removal of Unsupported Translate Module [\#442](https://github.com/puppetlabs/puppetlabs-inifile/pull/442) ([david22swan](https://github.com/david22swan)) ## [v5.0.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v5.0.0) (2021-03-02) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v4.4.0...v5.0.0) ### Changed - pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [\#432](https://github.com/puppetlabs/puppetlabs-inifile/pull/432) ([carabasdaniel](https://github.com/carabasdaniel)) ## [v4.4.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v4.4.0) (2020-12-08) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v4.3.1...v4.4.0) ### Added - \(feat\) - Add Puppet 7 support [\#422](https://github.com/puppetlabs/puppetlabs-inifile/pull/422) ([daianamezdrea](https://github.com/daianamezdrea)) ## [v4.3.1](https://github.com/puppetlabs/puppetlabs-inifile/tree/v4.3.1) (2020-11-09) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v4.3.0...v4.3.1) ### Fixed - \(IAC-992\) - Removal of inappropriate terminology [\#415](https://github.com/puppetlabs/puppetlabs-inifile/pull/415) ([david22swan](https://github.com/david22swan)) ## [v4.3.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v4.3.0) (2020-09-10) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v4.2.0...v4.3.0) ### Added - pdksync - \(IAC-973\) - Update travis/appveyor to run on new default branch `main` [\#407](https://github.com/puppetlabs/puppetlabs-inifile/pull/407) ([david22swan](https://github.com/david22swan)) - Add delete\_if\_empty parameter to the ini\_subsetting type/provider [\#405](https://github.com/puppetlabs/puppetlabs-inifile/pull/405) ([mmarod](https://github.com/mmarod)) - \(IAC-746\) - Add ubuntu 20.04 support [\#396](https://github.com/puppetlabs/puppetlabs-inifile/pull/396) ([david22swan](https://github.com/david22swan)) ## [v4.2.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v4.2.0) (2020-04-27) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v4.1.0...v4.2.0) ### Added - Finish API conversion of `create_ini_settings` [\#387](https://github.com/puppetlabs/puppetlabs-inifile/pull/387) ([alexjfisher](https://github.com/alexjfisher)) ## [v4.1.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v4.1.0) (2020-01-15) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v4.0.0...v4.1.0) ### Added - pdksync - \(FM-8581\) - Debian 10 added to travis and provision file refactored [\#374](https://github.com/puppetlabs/puppetlabs-inifile/pull/374) ([david22swan](https://github.com/david22swan)) - Puppet 4 functions [\#373](https://github.com/puppetlabs/puppetlabs-inifile/pull/373) ([binford2k](https://github.com/binford2k)) - pdksync - "MODULES-10242 Add ubuntu14 support back to the modules" [\#368](https://github.com/puppetlabs/puppetlabs-inifile/pull/368) ([sheenaajay](https://github.com/sheenaajay)) - \(FM-8689\) - Addition of Support for CentOS 8 [\#366](https://github.com/puppetlabs/puppetlabs-inifile/pull/366) ([david22swan](https://github.com/david22swan)) ## [v4.0.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v4.0.0) (2019-11-11) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v3.1.0...v4.0.0) ### Changed - pdksync - FM-8499 - remove ubuntu14 support [\#363](https://github.com/puppetlabs/puppetlabs-inifile/pull/363) ([lionce](https://github.com/lionce)) ### Added - FM-8402 add debian 10 support [\#352](https://github.com/puppetlabs/puppetlabs-inifile/pull/352) ([lionce](https://github.com/lionce)) ## [v3.1.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v3.1.0) (2019-07-31) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/v3.0.0...v3.1.0) ### Added - FM-8222 - Port Module inifile to Litmus [\#344](https://github.com/puppetlabs/puppetlabs-inifile/pull/344) ([lionce](https://github.com/lionce)) - \(FM-8154\) Add Windows Server 2019 support [\#340](https://github.com/puppetlabs/puppetlabs-inifile/pull/340) ([eimlav](https://github.com/eimlav)) - \(FM-8041\) Add RedHat 8 support [\#339](https://github.com/puppetlabs/puppetlabs-inifile/pull/339) ([eimlav](https://github.com/eimlav)) ## [v3.0.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/v3.0.0) (2019-04-22) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/2.5.0...v3.0.0) ### Changed - pdksync - \(MODULES-8444\) - Raise lower Puppet bound [\#335](https://github.com/puppetlabs/puppetlabs-inifile/pull/335) ([david22swan](https://github.com/david22swan)) ### Fixed - FM-7779 - Cleanup Inifile [\#328](https://github.com/puppetlabs/puppetlabs-inifile/pull/328) ([lionce](https://github.com/lionce)) ## [2.5.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/2.5.0) (2018-12-28) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/2.4.0...2.5.0) ### Added - \(MODULES-8142\) - Addition of support for SLES 15 [\#315](https://github.com/puppetlabs/puppetlabs-inifile/pull/315) ([david22swan](https://github.com/david22swan)) - \(MODULES-7560\) - removed spaces from the beginning or from the end of the value [\#311](https://github.com/puppetlabs/puppetlabs-inifile/pull/311) ([lionce](https://github.com/lionce)) ### Fixed - pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#320](https://github.com/puppetlabs/puppetlabs-inifile/pull/320) ([tphoney](https://github.com/tphoney)) - \(MODULES-6714\) - inifile: ensure absent not working with refreshonly = true [\#313](https://github.com/puppetlabs/puppetlabs-inifile/pull/313) ([Lavinia-Dan](https://github.com/Lavinia-Dan)) - \(FM-7483\) - update module to the latest version [\#310](https://github.com/puppetlabs/puppetlabs-inifile/pull/310) ([lionce](https://github.com/lionce)) - \(FM-7331\)-Fix japanese test [\#308](https://github.com/puppetlabs/puppetlabs-inifile/pull/308) ([lionce](https://github.com/lionce)) ## [2.4.0](https://github.com/puppetlabs/puppetlabs-inifile/tree/2.4.0) (2018-09-27) [Full Changelog](https://github.com/puppetlabs/puppetlabs-inifile/compare/2.3.0...2.4.0) ### Added - pdksync - \(FM-7392\) - Puppet 6 Testing Changes [\#300](https://github.com/puppetlabs/puppetlabs-inifile/pull/300) ([pmcmaw](https://github.com/pmcmaw)) - pdksync - \(MODULES-7658\) use beaker4 in puppet-module-gems [\#296](https://github.com/puppetlabs/puppetlabs-inifile/pull/296) ([tphoney](https://github.com/tphoney)) - \(MODULES-7552\) - Addition of support for Ubuntu 18.04 to inifile [\#292](https://github.com/puppetlabs/puppetlabs-inifile/pull/292) ([david22swan](https://github.com/david22swan)) ### Fixed - \(MODULES-7625\) - Update README Limitations section [\#293](https://github.com/puppetlabs/puppetlabs-inifile/pull/293) ([eimlav](https://github.com/eimlav)) ## 2.3.0 ### Summary This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a feature for `force_new_section_creation` and a roll up of maintenance changes. ### Added - Added `force_new_section_creation` parameter. - PDK convert and update to use pdk 1.5.0 (MODULES-6326). ### Removed - Support for Scientific Linux 5 - Support for Debian 7 ## Supported Release [2.2.2] ### Summary This is a bug fix release that corrects type autoloading. ### Fixed - Correct type autoload ([FM-6932](https://tickets.puppet.com/browse/FM-6932)). ## Supported Release [2.2.1] ### Summary This is a bug fix release for a problem with managing existing lines in Puppet > 5.4.0 ### Fixed - issue with ini_setting's :refreshonly parameter validation ([MODULES-6687](https://tickets.puppet.com/browse/MODULES-6687)) ## Supported Release [2.2.0] ### Summary This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a roll up of maintenance changes. ### Added - PDK convert inifile ([MODULES-6453](https://tickets.puppet.com/browse/MODULES-6453)). - Modulesync updates. ### Fixed - Changes to address additional Rubocop failures. - Addressing puppet-lint doc warnings. ### Removed - `gem update bundler` command in .travis.yml due to ([MODULES-6339](https://tickets.puppet.com/browse/MODULES-6339)). ## Supported Release 2.1.1 ### Summary This release is in order to implement Rubocop within the module and includes a wide array of formatting changes throughout the code and the enabling of rubocop checks to be run against all pull requests against the module. ### Changed - Rubocop checks will now be run against any PRs made towards the module. - The module has undergone a substantial reformatting in order to comply with the designated standards. ## Supported Release 2.1.0 ### Summary This is a clean release prior to the implementation of rubocop within the module. ### Added - Several Modulesync updates have been made. - Indent Character can now be set. - Support for Debian 9 has been added. ### Removed - Support for Ubuntu 1004 and 1204 has been removed. - Support for SLES 10 SP4 has been removed. - Support for Debian 6 has been removed. - Support for Solaris 12 has been removed. - Support for Windows Server 2003 R2 has been removed. ## Supported Release 2.0.0 ### Summary This is a major release that includes a few bugfixes as well as some general module updates. **This release drops Puppet 3 support** ### Changed - Moved lower Puppet version requirement to 4.7.0, MODULES-4830 ### Fixed - Fix path validation on windows MODULES-4170 - Fix headings in README - Fix for mimicking commented settings MODULES-4932 - Fix for Backwards compatible ini_file.set_value MODULES-5172 ## Supported Release 1.6.0 ### Summary This release expands functionality around sub-settings and adds the `refreshonly` parameter so the user can specify whether a resource should or should not respond to a refresh event. ### Features - `refreshonly` decide whether or not a value should be updated as part of a refresh - `insert_type` choose where the sub-setting is placed in the final string - `subsetting_key_val_separator` specify a key/value separator for sub-settings ### Bugfixes - MODULES-3145 Cast values to strings before passing to provider ## Supported Release 1.5.0 ### Summary This release adds the long-awaited `show_diff` parameter for diffing the complete file on changes (or can also just show the md5 sums). ### Features - Added `show_diff` parameter to show diffs on changes. - Remove empty ini sections when the last line in the section is removed. ### Bugfixes - Workaround `create_ini_settings()` duplicate resources puppet bug PUP-4709 ## Supported Release 1.4.3 ###Summary Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. ## 2015-09-01 - Supported Release 1.4.2 ### Summary This release adds some bugfixes. ####Bugfixes - MODULES-2212 Add use_exact_match parameter for subsettings - MODULES-1908 Munge the setting to ensure we always strip the whitespace - MODULES-2369 Support a space as a key_val_separator ## 2015-07-15 - Supported Release 1.4.1 ### Summary This release bumps the metadata for PE up. ##2015-07-07 - Supported Releases 1.4.0 ###Summary This is primarily a release which includes acceptance tests updates, but also includes some minor bug fixes and improvements ####Features - Solaris 12 Support - Acceptance testing improvements ####Bugfixes - MODULES-1599 Match only on space and tab whitespace after k/v separator ##2015-06-09 - Supported Releases 1.3.0 ###Summary This is primarily a feature release, but also includes test fixes, documentation updates and synchronization of files with modulesync. ####Features - Synchronized files using modulesync - Improved documentation - Allow changing key value separator beyond indentation - Adding the ability to change regex match for $section in inifile ####Bugfixes - pin beaker-rspec for windows testing - pin rspec gems for testing - Adds default values for section - Fixed names containing spaces ##2014-11-11 - Supported Releases 1.2.0 ###Summary This is primarily a bugfix release, but also includes documentation updates and synchronization of files with modulesync. ####Features - Synchronized files using modulesync - Improved documentation with a warning about old, manually installed inifile with PE3.3+ ####Bugfixes - Fix issue where single character settings were not being saved ##2014-09-30 - Supported Releases 1.1.4 ###Summary This release includes documentation and test updates. ##2014-07-15 - Supported Release 1.1.3 ###Summary This release merely updates metadata.json so the module can be uninstalled and upgraded via the puppet module command. ##2014-07-10 - Supported Release 1.1.2 ###Summary This is a re-packaging release. ##2014-07-07 - Release 1.1.1 ###Summary This supported bugfix release corrects the inifile section header detection regex (so you can use more characters in your section titles). ####Bugfixes - Correct section regex to allow anything other than ] - Correct `exists?` to return a boolean - Lots of test updates - Add missing CONTRIBUTING.md ##2014-06-04 - Release 1.1.0 ###Summary This is a compatibility and feature release. This release adds one new feature, the ability to control the quote character used. This allows you to do things like: ``` ini_subsetting { '-Xms': ensure => present, path => '/some/config/file', section => '', setting => 'JAVA_ARGS', quote_char => '"', subsetting => '-Xms' value => '256m', } ``` Which builds: ``` JAVA_ARGS="-Xmx256m -Xms256m" ``` ####Features - Add quote_char parameter to the ini_subsetting resource type ####Bugfixes ####Known Bugs * No known bugs ##2014-03-04 - Supported Release 1.0.3 ###Summary This is a supported release. It has only test changes. ####Features ####Bugfixes ####Known Bugs * No known bugs ##2014-02-26 - Version 1.0.2 ###Summary This release adds supported platforms to metadata.json and contains spec fixes ##2014-02-12 - Version 1.0.1 ###Summary This release is a bugfix for handling whitespace/[]'s better, and adding a bunch of tests. ####Bugfixes - Handle whitespace in sections - Handle square brances in values - Add metadata.json - Update some travis testing - Tons of beaker-rspec tests ##2013-07-16 - Version 1.0.0 ####Features - Handle empty values. - Handle whitespace in settings names (aka: server role = something) - Add mechanism for allowing ini_setting subclasses to override the formation of the namevar during .instances, to allow for ini_setting derived types that manage flat ini-file-like files and still purge them. --- ##2013-05-28 - Chris Price - 0.10.3 * Fix bug in subsetting handling for new settings (cbea5dc) ##2013-05-22 - Chris Price - 0.10.2 * Better handling of quotes for subsettings (1aa7e60) ##2013-05-21 - Chris Price - 0.10.1 * Change constants to class variables to avoid ruby warnings (6b19864) ##2013-04-10 - Erik Dalén - 0.10.1 * Style fixes (c4af8c3) ##2013-04-02 - Dan Bode - 0.10.1 * Add travisfile and Gemfile (c2052b3) ##2013-04-02 - Chris Price - 0.10.1 * Update README.markdown (ad38a08) ##2013-02-15 - Karel Brezina - 0.10.0 * Added 'ini_subsetting' custom resource type (4351d8b) ##2013-03-11 - Dan Bode - 0.10.0 * guard against nil indentation values (5f71d7f) ##2013-01-07 - Dan Bode - 0.10.0 * Add purging support to ini file (2f22483) ##2013-02-05 - James Sweeny - 0.10.0 * Fix test to use correct key_val_parameter (b1aff63) ##2012-11-06 - Chris Price - 0.10.0 * Added license file w/Apache 2.0 license (5e1d203) ##2012-11-02 - Chris Price - 0.9.0 * Version 0.9.0 released ##2012-10-26 - Chris Price - 0.9.0 * Add detection for commented versions of settings (a45ab65) ##2012-10-20 - Chris Price - 0.9.0 * Refactor to clarify implementation of `save` (f0d443f) ##2012-10-20 - Chris Price - 0.9.0 * Add example for `ensure=absent` (e517148) ##2012-10-20 - Chris Price - 0.9.0 * Better handling of whitespace lines at ends of sections (845fa70) ##2012-10-20 - Chris Price - 0.9.0 * Respect indentation / spacing for existing sections and settings (c2c26de) ##2012-10-17 - Chris Price - 0.9.0 * Minor tweaks to handling of removing settings (cda30a6) ##2012-10-10 - Dan Bode - 0.9.0 * Add support for removing lines (1106d70) ##2012-10-02 - Dan Bode - 0.9.0 * Make value a property (cbc90d3) ##2012-10-02 - Dan Bode - 0.9.0 * Make ruby provider a better parent. (1564c47) ##2012-09-29 - Reid Vandewiele - 0.9.0 * Allow values with spaces to be parsed and set (3829e20) ##2012-09-24 - Chris Price - 0.0.3 * Version 0.0.3 released ##2012-09-20 - Chris Price - 0.0.3 * Add validation for key_val_separator (e527908) ##2012-09-19 - Chris Price - 0.0.3 * Allow overriding separator string between key/val pairs (8d1fdc5) ##2012-08-20 - Chris Price - 0.0.2 * Version 0.0.2 released ##2012-08-17 - Chris Price - 0.0.2 * Add support for "global" section at beginning of file (c57dab4) [2.3.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.2.2...2.3.0 [2.2.2]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.2.1...2.2.2 [2.2.1]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.2.0...2.2.1 [2.2.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.1.1...2.2.0 \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* puppetlabs-inifile-5.4.0/CODEOWNERS0100644000175100001710000000007614316557455013707 0ustar00# Setting ownership to the modules team * @puppetlabs/modules puppetlabs-inifile-5.4.0/CONTRIBUTING.md0100644000175100001710000000032314316557455014540 0ustar00# Contributing to Puppet modules Check out our [Contributing to Supported Modules Blog Post](https://puppetlabs.github.io/iac/docs/contributing_to_a_module.html) to find all the information that you will need. puppetlabs-inifile-5.4.0/HISTORY.md0100644000175100001710000002551614316557455014005 0ustar00## 2.3.0 ### Summary This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a feature for `force_new_section_creation` and a roll up of maintenance changes. ### Added - Added `force_new_section_creation` parameter. - PDK convert and update to use pdk 1.5.0 (MODULES-6326). ### Removed - Support for Scientific Linux 5 - Support for Debian 7 ## Supported Release [2.2.2] ### Summary This is a bug fix release that corrects type autoloading. ### Fixed - Correct type autoload ([FM-6932](https://tickets.puppet.com/browse/FM-6932)). ## Supported Release [2.2.1] ### Summary This is a bug fix release for a problem with managing existing lines in Puppet > 5.4.0 ### Fixed - issue with ini_setting's :refreshonly parameter validation ([MODULES-6687](https://tickets.puppet.com/browse/MODULES-6687)) ## Supported Release [2.2.0] ### Summary This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a roll up of maintenance changes. ### Added - PDK convert inifile ([MODULES-6453](https://tickets.puppet.com/browse/MODULES-6453)). - Modulesync updates. ### Fixed - Changes to address additional Rubocop failures. - Addressing puppet-lint doc warnings. ### Removed - `gem update bundler` command in .travis.yml due to ([MODULES-6339](https://tickets.puppet.com/browse/MODULES-6339)). ## Supported Release 2.1.1 ### Summary This release is in order to implement Rubocop within the module and includes a wide array of formatting changes throughout the code and the enabling of rubocop checks to be run against all pull requests against the module. ### Changed - Rubocop checks will now be run against any PRs made towards the module. - The module has undergone a substantial reformatting in order to comply with the designated standards. ## Supported Release 2.1.0 ### Summary This is a clean release prior to the implementation of rubocop within the module. ### Added - Several Modulesync updates have been made. - Indent Character can now be set. - Support for Debian 9 has been added. ### Removed - Support for Ubuntu 1004 and 1204 has been removed. - Support for SLES 10 SP4 has been removed. - Support for Debian 6 has been removed. - Support for Solaris 12 has been removed. - Support for Windows Server 2003 R2 has been removed. ## Supported Release 2.0.0 ### Summary This is a major release that includes a few bugfixes as well as some general module updates. **This release drops Puppet 3 support** ### Changed - Moved lower Puppet version requirement to 4.7.0, MODULES-4830 ### Fixed - Fix path validation on windows MODULES-4170 - Fix headings in README - Fix for mimicking commented settings MODULES-4932 - Fix for Backwards compatible ini_file.set_value MODULES-5172 ## Supported Release 1.6.0 ### Summary This release expands functionality around sub-settings and adds the `refreshonly` parameter so the user can specify whether a resource should or should not respond to a refresh event. ### Features - `refreshonly` decide whether or not a value should be updated as part of a refresh - `insert_type` choose where the sub-setting is placed in the final string - `subsetting_key_val_separator` specify a key/value separator for sub-settings ### Bugfixes - MODULES-3145 Cast values to strings before passing to provider ## Supported Release 1.5.0 ### Summary This release adds the long-awaited `show_diff` parameter for diffing the complete file on changes (or can also just show the md5 sums). ### Features - Added `show_diff` parameter to show diffs on changes. - Remove empty ini sections when the last line in the section is removed. ### Bugfixes - Workaround `create_ini_settings()` duplicate resources puppet bug PUP-4709 ## Supported Release 1.4.3 ###Summary Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. ## 2015-09-01 - Supported Release 1.4.2 ### Summary This release adds some bugfixes. ####Bugfixes - MODULES-2212 Add use_exact_match parameter for subsettings - MODULES-1908 Munge the setting to ensure we always strip the whitespace - MODULES-2369 Support a space as a key_val_separator ## 2015-07-15 - Supported Release 1.4.1 ### Summary This release bumps the metadata for PE up. ##2015-07-07 - Supported Releases 1.4.0 ###Summary This is primarily a release which includes acceptance tests updates, but also includes some minor bug fixes and improvements ####Features - Solaris 12 Support - Acceptance testing improvements ####Bugfixes - MODULES-1599 Match only on space and tab whitespace after k/v separator ##2015-06-09 - Supported Releases 1.3.0 ###Summary This is primarily a feature release, but also includes test fixes, documentation updates and synchronization of files with modulesync. ####Features - Synchronized files using modulesync - Improved documentation - Allow changing key value separator beyond indentation - Adding the ability to change regex match for $section in inifile ####Bugfixes - pin beaker-rspec for windows testing - pin rspec gems for testing - Adds default values for section - Fixed names containing spaces ##2014-11-11 - Supported Releases 1.2.0 ###Summary This is primarily a bugfix release, but also includes documentation updates and synchronization of files with modulesync. ####Features - Synchronized files using modulesync - Improved documentation with a warning about old, manually installed inifile with PE3.3+ ####Bugfixes - Fix issue where single character settings were not being saved ##2014-09-30 - Supported Releases 1.1.4 ###Summary This release includes documentation and test updates. ##2014-07-15 - Supported Release 1.1.3 ###Summary This release merely updates metadata.json so the module can be uninstalled and upgraded via the puppet module command. ##2014-07-10 - Supported Release 1.1.2 ###Summary This is a re-packaging release. ##2014-07-07 - Release 1.1.1 ###Summary This supported bugfix release corrects the inifile section header detection regex (so you can use more characters in your section titles). ####Bugfixes - Correct section regex to allow anything other than ] - Correct `exists?` to return a boolean - Lots of test updates - Add missing CONTRIBUTING.md ##2014-06-04 - Release 1.1.0 ###Summary This is a compatibility and feature release. This release adds one new feature, the ability to control the quote character used. This allows you to do things like: ``` ini_subsetting { '-Xms': ensure => present, path => '/some/config/file', section => '', setting => 'JAVA_ARGS', quote_char => '"', subsetting => '-Xms' value => '256m', } ``` Which builds: ``` JAVA_ARGS="-Xmx256m -Xms256m" ``` ####Features - Add quote_char parameter to the ini_subsetting resource type ####Bugfixes ####Known Bugs * No known bugs ##2014-03-04 - Supported Release 1.0.3 ###Summary This is a supported release. It has only test changes. ####Features ####Bugfixes ####Known Bugs * No known bugs ##2014-02-26 - Version 1.0.2 ###Summary This release adds supported platforms to metadata.json and contains spec fixes ##2014-02-12 - Version 1.0.1 ###Summary This release is a bugfix for handling whitespace/[]'s better, and adding a bunch of tests. ####Bugfixes - Handle whitespace in sections - Handle square brances in values - Add metadata.json - Update some travis testing - Tons of beaker-rspec tests ##2013-07-16 - Version 1.0.0 ####Features - Handle empty values. - Handle whitespace in settings names (aka: server role = something) - Add mechanism for allowing ini_setting subclasses to override the formation of the namevar during .instances, to allow for ini_setting derived types that manage flat ini-file-like files and still purge them. --- ##2013-05-28 - Chris Price - 0.10.3 * Fix bug in subsetting handling for new settings (cbea5dc) ##2013-05-22 - Chris Price - 0.10.2 * Better handling of quotes for subsettings (1aa7e60) ##2013-05-21 - Chris Price - 0.10.1 * Change constants to class variables to avoid ruby warnings (6b19864) ##2013-04-10 - Erik Dalén - 0.10.1 * Style fixes (c4af8c3) ##2013-04-02 - Dan Bode - 0.10.1 * Add travisfile and Gemfile (c2052b3) ##2013-04-02 - Chris Price - 0.10.1 * Update README.markdown (ad38a08) ##2013-02-15 - Karel Brezina - 0.10.0 * Added 'ini_subsetting' custom resource type (4351d8b) ##2013-03-11 - Dan Bode - 0.10.0 * guard against nil indentation values (5f71d7f) ##2013-01-07 - Dan Bode - 0.10.0 * Add purging support to ini file (2f22483) ##2013-02-05 - James Sweeny - 0.10.0 * Fix test to use correct key_val_parameter (b1aff63) ##2012-11-06 - Chris Price - 0.10.0 * Added license file w/Apache 2.0 license (5e1d203) ##2012-11-02 - Chris Price - 0.9.0 * Version 0.9.0 released ##2012-10-26 - Chris Price - 0.9.0 * Add detection for commented versions of settings (a45ab65) ##2012-10-20 - Chris Price - 0.9.0 * Refactor to clarify implementation of `save` (f0d443f) ##2012-10-20 - Chris Price - 0.9.0 * Add example for `ensure=absent` (e517148) ##2012-10-20 - Chris Price - 0.9.0 * Better handling of whitespace lines at ends of sections (845fa70) ##2012-10-20 - Chris Price - 0.9.0 * Respect indentation / spacing for existing sections and settings (c2c26de) ##2012-10-17 - Chris Price - 0.9.0 * Minor tweaks to handling of removing settings (cda30a6) ##2012-10-10 - Dan Bode - 0.9.0 * Add support for removing lines (1106d70) ##2012-10-02 - Dan Bode - 0.9.0 * Make value a property (cbc90d3) ##2012-10-02 - Dan Bode - 0.9.0 * Make ruby provider a better parent. (1564c47) ##2012-09-29 - Reid Vandewiele - 0.9.0 * Allow values with spaces to be parsed and set (3829e20) ##2012-09-24 - Chris Price - 0.0.3 * Version 0.0.3 released ##2012-09-20 - Chris Price - 0.0.3 * Add validation for key_val_separator (e527908) ##2012-09-19 - Chris Price - 0.0.3 * Allow overriding separator string between key/val pairs (8d1fdc5) ##2012-08-20 - Chris Price - 0.0.2 * Version 0.0.2 released ##2012-08-17 - Chris Price - 0.0.2 * Add support for "global" section at beginning of file (c57dab4) [2.3.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.2.2...2.3.0 [2.2.2]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.2.1...2.2.2 [2.2.1]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.2.0...2.2.1 [2.2.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/2.1.1...2.2.0 puppetlabs-inifile-5.4.0/LICENSE0100644000175100001710000002613614316557455013326 0ustar00 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. puppetlabs-inifile-5.4.0/NOTICE0100644000175100001710000000124414316557455013216 0ustar00inifile puppet module Copyright (C) 2012-2016 Puppet Labs, Inc. Copyright (C) 2012 Chris Price Puppet Labs can be contacted at: info@puppetlabs.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. puppetlabs-inifile-5.4.0/README.md0100644000175100001710000002213114316557455013567 0ustar00# inifile [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-inifile.png?branch=main)](https://travis-ci.org/puppetlabs/puppetlabs-inifile) #### Table of Contents 1. [Overview](#overview) 1. [Module Description - What the module does and why it is useful](#module-description) 1. [Setup - The basics of getting started with inifile module](#setup) 1. [Usage - Configuration options and additional functionality](#usage) 1. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 1. [Limitations - OS compatibility, etc.](#limitations) 1. [Development - Guide for contributing to the module](#development) ## Overview The inifile module lets Puppet manage settings stored in INI-style configuration files. ## Module Description Many applications use INI-style configuration files to store their settings. This module supplies two custom resource types to let you manage those settings through Puppet. ## Setup ### Beginning with inifile To manage a single setting in an INI file, add the `ini_setting` type to a class: ~~~puppet ini_setting { "sample setting": ensure => present, path => '/tmp/foo.ini', section => 'bar', setting => 'baz', value => 'quux', } ~~~ ## Usage The inifile module is used to: * Support comments starting with either '#' or ';'. * Support either whitespace or no whitespace around '='. * Add any missing sections to the INI file. It does not manipulate your file any more than it needs to. In most cases, it doesn't affect the original whitespace, comments, or ordering. See the common usages below for examples. ### Manage multiple values in a setting Use the `ini_subsetting` type: ~~~puppet ini_subsetting {'sample subsetting': ensure => present, section => '', key_val_separator => '=', path => '/etc/default/pe-puppetdb', setting => 'JAVA_ARGS', subsetting => '-Xmx', value => '512m', } ~~~ Results in managing this `-Xmx` subsetting: ~~~puppet JAVA_ARGS="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" ~~~ ### Use a non-standard section header ~~~puppet ini_setting { 'default minage': ensure => present, path => '/etc/security/users', section => 'default', setting => 'minage', value => '1', section_prefix => '', section_suffix => ':', } ~~~ Results in: ~~~puppet default: minage = 1 ~~~ ### Use a non-standard indent character To use a non-standard indent character or string for added settings, set the `indent_char` and the `indent_width` parameters. The `indent_width` parameter controls how many `indent_char` appear in the indent. ~~~puppet ini_setting { 'procedure cache size': ensure => present, path => '/var/lib/ase/config/ASE-16_0/SYBASE.cfg', section => 'SQL Server Administration', setting => 'procedure cache size', value => '15000', indent_char => "\t", indent_width => 2, } ~~~ Results in: ~~~puppet [SQL Server Administration] procedure cache size = 15000 ~~~ ### Implement child providers You might want to create child providers that inherit the `ini_setting` provider for one of the following reasons: * To make a custom resource to manage an application that stores its settings in INI files, without recreating the code to manage the files themselves. * To [purge all unmanaged settings](https://docs.puppetlabs.com/references/latest/type.html#resources-attribute-purge) from a managed INI file. To implement child providers, first specify a custom type. Have it implement a namevar called `name` and a property called `value`: ~~~ruby #my_module/lib/puppet/type/glance_api_config.rb Puppet::Type.newtype(:glance_api_config) do ensurable newparam(:name, :namevar => true) do desc 'Section/setting name to manage from glance-api.conf' # namevar should be of the form section/setting newvalues(/\S+\/\S+/) end newproperty(:value) do desc 'The value of the setting to define' munge do |v| v.to_s.strip end end end ~~~ Your type also needs a provider that uses the `ini_setting` provider as its parent: ~~~ruby # my_module/lib/puppet/provider/glance_api_config/ini_setting.rb Puppet::Type.type(:glance_api_config).provide( :ini_setting, # set ini_setting as the parent provider :parent => Puppet::Type.type(:ini_setting).provider(:ruby) ) do # implement section as the first part of the namevar def section resource[:name].split('/', 2).first end def setting # implement setting as the second part of the namevar resource[:name].split('/', 2).last end # hard code the file path (this allows purging) def self.file_path '/etc/glance/glance-api.conf' end end ~~~ Now you can manage the settings in the `/etc/glance/glance-api.conf` file as individual resources: ~~~puppet glance_api_config { 'HEADER/important_config': value => 'secret_value', } ~~~ If you've implemented `self.file_path`, you can have Puppet purge the file of the all lines that aren't implemented as Puppet resources: ~~~puppet resources { 'glance_api_config': purge => true, } ~~~ ### Manage multiple ini_settings To manage multiple `ini_settings`, use the [`inifile::create_ini_settings`](REFERENCE.md#inifilecreate_ini_settings) function. ~~~puppet $defaults = { 'path' => '/tmp/foo.ini' } $example = { 'section1' => { 'setting1' => 'value1' } } inifile::create_ini_settings($example, $defaults) ~~~ Results in: ~~~puppet ini_setting { '[section1] setting1': ensure => present, section => 'section1', setting => 'setting1', value => 'value1', path => '/tmp/foo.ini', } ~~~ To include special parameters, use the following code: ~~~puppet $defaults = { 'path' => '/tmp/foo.ini' } $example = { 'section1' => { 'setting1' => 'value1', 'settings2' => { 'ensure' => 'absent' } } } inifile::create_ini_settings($example, $defaults) ~~~ Results in: ~~~puppet ini_setting { '[section1] setting1': ensure => present, section => 'section1', setting => 'setting1', value => 'value1', path => '/tmp/foo.ini', } ini_setting { '[section1] setting2': ensure => absent, section => 'section1', setting => 'setting2', path => '/tmp/foo.ini', } ~~~ #### Manage multiple ini_settings with Hiera For the profile `example`: ~~~puppet class profile::example ( Hash $settings, ) { $defaults = { 'path' => '/tmp/foo.ini' } inifile::create_ini_settings($settings, $defaults) } ~~~ Provide this in your Hiera data: ~~~puppet profile::example::settings: section1: setting1: value1 setting2: value2 setting3: ensure: absent ~~~ Results in: ~~~puppet ini_setting { '[section1] setting1': ensure => present, section => 'section1', setting => 'setting1', value => 'value1', path => '/tmp/foo.ini', } ini_setting { '[section1] setting2': ensure => present, section => 'section1', setting => 'setting2', value => 'value2', path => '/tmp/foo.ini', } ini_setting { '[section1] setting3': ensure => absent, section => 'section1', setting => 'setting3', path => '/tmp/foo.ini', } ~~~ ## Reference See [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-inifile/blob/main/REFERENCE.md) ## Limitations ### Supported operating systems For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-inifile/blob/main/metadata.json) ### create_ini_settings When using inifile::create_ini_settings it’s worth noting that namespace tags will not be applied to the resource. If you need these namespace tags we advise using the standard ini_setting resource. For more information about resource tags, please see [this article](https://puppet.com/docs/puppet/7/lang_tags.html#lang_tags-assigning-tags-to-resources). ## Development We are experimenting with a new tool for running acceptance tests. It's name is [puppet_litmus](https://github.com/puppetlabs/puppet_litmus) this replaces beaker as the test runner. To run the acceptance tests follow the instructions [here](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module). Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide.](https://puppet.com/docs/puppet/latest/contributing.html) ### Contributors To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-inifile/graphs/contributors) puppetlabs-inifile-5.4.0/REFERENCE.md0100644000175100001710000001727114316557455014141 0ustar00# Reference ## Table of Contents ### Resource types * [`ini_setting`](#ini_setting): ini_settings is used to manage a single setting in an INI file * [`ini_subsetting`](#ini_subsetting): ini_subsettings is used to manage multiple values in a setting in an INI file ### Functions * [`create_ini_settings`](#create_ini_settings): DEPRECATED. Use the namespaced function [`inifile::create_ini_settings`](#inifilecreate_ini_settings) instead. * [`inifile::create_ini_settings`](#inifilecreate_ini_settings): This function is used to create a set of ini_setting resources from a hash ## Resource types ### `ini_setting` ini_settings is used to manage a single setting in an INI file #### Properties The following properties are available in the `ini_setting` type. ##### `ensure` Valid values: `present`, `absent` Ensurable method handles modeling creation. It creates an ensure property Default value: `present` ##### `value` The value of the setting to be defined. #### Parameters The following parameters are available in the `ini_setting` type. * [`force_new_section_creation`](#force_new_section_creation) * [`indent_char`](#indent_char) * [`indent_width`](#indent_width) * [`key_val_separator`](#key_val_separator) * [`name`](#name) * [`path`](#path) * [`provider`](#provider) * [`refreshonly`](#refreshonly) * [`section`](#section) * [`section_prefix`](#section_prefix) * [`section_suffix`](#section_suffix) * [`setting`](#setting) * [`show_diff`](#show_diff) ##### `force_new_section_creation` Valid values: ``true``, ``false``, `yes`, `no` Create setting only if the section exists Default value: ``true`` ##### `indent_char` The character to indent new settings with. Default value: ` ` ##### `indent_width` The number of indent_chars to use to indent a new setting. ##### `key_val_separator` The separator string to use between each setting name and value. Default value: ` = ` ##### `name` namevar An arbitrary name used as the identity of the resource. ##### `path` The ini file Puppet will ensure contains the specified setting. ##### `provider` The specific backend to use for this `ini_setting` resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform. ##### `refreshonly` Valid values: ``true``, ``false``, `yes`, `no` A flag indicating whether or not the ini_setting should be updated only when called as part of a refresh event Default value: ``false`` ##### `section` The name of the section in the ini file in which the setting should be defined. Default value: `''` ##### `section_prefix` The prefix to the section name\'s header. Default value: `[` ##### `section_suffix` The suffix to the section name\'s header. Default value: `]` ##### `setting` The name of the setting to be defined. ##### `show_diff` Valid values: ``true``, `md5`, ``false`` Whether to display differences when the setting changes. Default value: ``true`` ### `ini_subsetting` ini_subsettings is used to manage multiple values in a setting in an INI file #### Properties The following properties are available in the `ini_subsetting` type. ##### `ensure` Valid values: `present`, `absent` Ensurable method handles modeling creation. It creates an ensure property Default value: `present` ##### `value` The value of the subsetting to be defined. #### Parameters The following parameters are available in the `ini_subsetting` type. * [`delete_if_empty`](#delete_if_empty) * [`insert_type`](#insert_type) * [`insert_value`](#insert_value) * [`key_val_separator`](#key_val_separator) * [`name`](#name) * [`path`](#path) * [`provider`](#provider) * [`quote_char`](#quote_char) * [`section`](#section) * [`setting`](#setting) * [`show_diff`](#show_diff) * [`subsetting`](#subsetting) * [`subsetting_key_val_separator`](#subsetting_key_val_separator) * [`subsetting_separator`](#subsetting_separator) * [`use_exact_match`](#use_exact_match) ##### `delete_if_empty` Valid values: ``true``, ``false`` Set to true to delete the parent setting when the subsetting is empty instead of writing an empty string Default value: ``false`` ##### `insert_type` Valid values: `start`, `end`, `before`, `after`, `index` Where the new subsetting item should be inserted * :start - insert at the beginning of the line. * :end - insert at the end of the line (default). * :before - insert before the specified element if possible. * :after - insert after the specified element if possible. * :index - insert at the specified index number. Default value: `end` ##### `insert_value` The value for the insert types which require one. ##### `key_val_separator` The separator string to use between each setting name and value. Default value: ` = ` ##### `name` namevar An arbitrary name used as the identity of the resource. ##### `path` The ini file Puppet will ensure contains the specified setting. ##### `provider` The specific backend to use for this `ini_subsetting` resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform. ##### `quote_char` The character used to quote the entire value of the setting. Valid values are '', '\"' and \"'\" Default value: `''` ##### `section` The name of the section in the ini file in which the setting should be defined. Default value: `''` ##### `setting` The name of the setting to be defined. ##### `show_diff` Valid values: ``true``, `md5`, ``false`` Whether to display differences when the setting changes. Default value: ``true`` ##### `subsetting` The name of the subsetting to be defined. ##### `subsetting_key_val_separator` The separator string between the subsetting name and its value. Defaults to the empty string. Default value: `''` ##### `subsetting_separator` The separator string between subsettings. Defaults to the empty string. Default value: ` ` ##### `use_exact_match` Valid values: ``true``, ``false`` Set to true if your subsettings don\'t have values and you want to use exact matches to determine if the subsetting exists. Default value: ``false`` ## Functions ### `create_ini_settings` Type: Ruby 4.x API DEPRECATED. Use the namespaced function [`inifile::create_ini_settings`](#inifilecreate_ini_settings) instead. #### `create_ini_settings(Any *$args)` The create_ini_settings function. Returns: `Any` ##### `*args` Data type: `Any` ### `inifile::create_ini_settings` Type: Ruby 4.x API This function is used to create a set of ini_setting resources from a hash #### `inifile::create_ini_settings(Hash $settings, Optional[Hash] $defaults)` The inifile::create_ini_settings function. Returns: `Any` ##### `settings` Data type: `Hash` A hash of settings you want to create ini_setting resources from ##### `defaults` Data type: `Optional[Hash]` A hash of defaults you would like to use in the ini_setting resources puppetlabs-inifile-5.4.0/data0040755000000000000000000000000014316557456013120 5ustar00puppetlabs-inifile-5.4.0/data/common.yaml0100644000175100001710000000000714316557455015373 0ustar00--- {} puppetlabs-inifile-5.4.0/examples0040755000000000000000000000000014316557456014025 5ustar00puppetlabs-inifile-5.4.0/examples/ini_setting.pp0100644000175100001710000000115214316557455017003 0ustar00ini_setting { 'sample setting': ensure => present, path => '/tmp/foo.ini', section => 'foo', setting => 'foosetting', value => 'FOO!', } ini_setting { 'sample setting2': ensure => present, path => '/tmp/foo.ini', section => 'bar', setting => 'barsetting', value => 'BAR!', key_val_separator => '=', require => Ini_setting['sample setting'], } ini_setting { 'sample setting3': ensure => absent, path => '/tmp/foo.ini', section => 'bar', setting => 'bazsetting', require => Ini_setting['sample setting2'], } puppetlabs-inifile-5.4.0/examples/ini_subsetting.pp0100644000175100001710000000200514316557455017513 0ustar00ini_subsetting { 'sample subsetting': ensure => 'present', section => '', key_val_separator => '=', path => '/etc/default/pe-puppetdb', setting => 'JAVA_ARGS', subsetting => '-Xmx', value => '512m', } ini_subsetting { 'sample subsetting2': ensure => 'absent', section => '', key_val_separator => '=', path => '/etc/default/pe-puppetdb', setting => 'JAVA_ARGS', subsetting => '-Xms', } ini_subsetting { 'sample subsetting3': ensure => 'present', section => '', key_val_separator => '=', subsetting_key_val_separator => ':', path => '/etc/default/pe-puppetdb', setting => 'JAVA_ARGS', subsetting => '-XX', value => '+HeapDumpOnOutOfMemoryError', insert_type => 'after', insert_value => '-Xmx', } puppetlabs-inifile-5.4.0/hiera.yaml0100644000175100001710000000125514316557455014270 0ustar00--- version: 5 defaults: # Used for any hierarchy level that omits these keys. datadir: data # This path is relative to hiera.yaml's directory. data_hash: yaml_data # Use the built-in YAML backend. hierarchy: - name: "osfamily/major release" paths: # Used to distinguish between Debian and Ubuntu - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" # Used for Solaris - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" - name: "osfamily" paths: - "os/%{facts.os.name}.yaml" - "os/%{facts.os.family}.yaml" - name: 'common' path: 'common.yaml' puppetlabs-inifile-5.4.0/lib0040755000000000000000000000000014316557456012755 5ustar00puppetlabs-inifile-5.4.0/lib/puppet0040755000000000000000000000000014316557456014272 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/functions0040755000000000000000000000000014316557456016302 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/functions/create_ini_settings.rb0100644000175100001710000000100114316557455022743 0ustar00# frozen_string_literal: true # @summary DEPRECATED. Use the namespaced function [`inifile::create_ini_settings`](#inifilecreate_ini_settings) instead. Puppet::Functions.create_function(:create_ini_settings) do dispatch :deprecation_gen do repeated_param 'Any', :args end def deprecation_gen(*args) call_function('deprecation', 'create_ini_settings', 'This method is deprecated, please use inifile::create_ini_settings instead.') call_function('inifile::create_ini_settings', *args) end end puppetlabs-inifile-5.4.0/lib/puppet/functions/inifile0040755000000000000000000000000014316557456017721 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/functions/inifile/create_ini_settings.rb0100644000175100001710000000257014316557455024376 0ustar00# frozen_string_literal: true # @summary This function is used to create a set of ini_setting resources from a hash Puppet::Functions.create_function(:'inifile::create_ini_settings') do # @param settings # A hash of settings you want to create ini_setting resources from # @param defaults # A hash of defaults you would like to use in the ini_setting resources dispatch :default_impl do param 'Hash', :settings optional_param 'Hash', :defaults end def default_impl(settings, defaults = {}) resources = settings.keys.each_with_object({}) do |section, res| unless settings[section].is_a?(Hash) raise(Puppet::ParseError, _('create_ini_settings(): Section %{section} must contain a Hash') % { section: section }) end path = defaults.merge(settings)['path'] raise Puppet::ParseError, _('create_ini_settings(): must pass the path parameter to the Ini_setting resource!') unless path settings[section].each do |setting, value| res["#{path} [#{section}] #{setting}"] = { 'ensure' => 'present', 'section' => section, 'setting' => setting, }.merge(if value.is_a?(Hash) value else { 'value' => value } end) end end call_function('create_resources', 'ini_setting', resources, defaults) end end puppetlabs-inifile-5.4.0/lib/puppet/provider0040755000000000000000000000000014316557456016124 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/provider/ini_setting0040755000000000000000000000000014316557456020440 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/provider/ini_setting/ruby.rb0100644000175100001710000001023014316557455022044 0ustar00# frozen_string_literal: true require File.expand_path('../../../util/ini_file', __FILE__) Puppet::Type.type(:ini_setting).provide(:ruby) do def self.instances desc ' Creates new ini_setting file, a specific config file with a provider that uses this as its parent and implements the method self.file_path, and that will provide the value for the path to the ini file.' raise(Puppet::Error, 'Ini_settings only support collecting instances when a file path is hard coded') unless respond_to?(:file_path) # figure out what to do about the seperator ini_file = Puppet::Util::IniFile.new(file_path, '=') resources = [] ini_file.section_names.each do |section_name| ini_file.get_settings(section_name).each do |setting, value| resources.push( new( name: namevar(section_name, setting), value: value, ensure: :present, ), ) end end resources end def self.namevar(section_name, setting) setting.nil? ? section_name : "#{section_name}/#{setting}" end def exists? if setting.nil? ini_file.section_names.include?(section) elsif ini_file.section?(section) !ini_file.get_value(section, setting).nil? elsif resource.parameters.key?(:force_new_section_creation) && !resource[:force_new_section_creation] # for backwards compatibility, if a user is using their own ini_setting # types but does not have this parameter, we need to fall back to the # previous functionality which was to create the section. Anyone # wishing to leverage this setting must define it in their provider # type. See comments on # https://github.com/puppetlabs/puppetlabs-inifile/pull/286 resource[:ensure] = :absent resource[:force_new_section_creation] elsif resource.parameters.key?(:force_new_section_creation) && resource[:force_new_section_creation] !resource[:force_new_section_creation] else false end end def create if setting.nil? && resource[:value].nil? ini_file.set_value(section) else ini_file.set_value(section, setting, separator, resource[:value]) end ini_file.save @ini_file = nil end def destroy ini_file.remove_setting(section, setting) ini_file.save @ini_file = nil end def value ini_file.get_value(section, setting) end def value=(_value) if setting.nil? && resource[:value].nil? ini_file.set_value(section) else ini_file.set_value(section, setting, separator, resource[:value]) end ini_file.save end def section # this method is here so that it can be overridden by a child provider resource[:section] end def setting # this method is here so that it can be overridden by a child provider resource[:setting] end def file_path # this method is here to support purging and sub-classing. # if a user creates a type and subclasses our provider and provides a # 'file_path' method, then they don't have to specify the # path as a parameter for every ini_setting declaration. # This implementation allows us to support that while still # falling back to the parameter value when necessary. if self.class.respond_to?(:file_path) self.class.file_path else resource[:path] end end def separator if resource.class.validattr?(:key_val_separator) resource[:key_val_separator] || '=' else '=' end end def section_prefix if resource.class.validattr?(:section_prefix) resource[:section_prefix] || '[' else '[' end end def section_suffix if resource.class.validattr?(:section_suffix) resource[:section_suffix] || ']' else ']' end end def indent_char if resource.class.validattr?(:indent_char) resource[:indent_char] || ' ' else ' ' end end def indent_width if resource.class.validattr?(:indent_width) resource[:indent_width] || nil else nil end end private def ini_file @ini_file ||= Puppet::Util::IniFile.new(file_path, separator, section_prefix, section_suffix, indent_char, indent_width) end end puppetlabs-inifile-5.4.0/lib/puppet/provider/ini_subsetting0040755000000000000000000000000014316557456021152 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/provider/ini_subsetting/ruby.rb0100644000175100001710000000447314316557455022572 0ustar00# frozen_string_literal: true require File.expand_path('../../../util/ini_file', __FILE__) require File.expand_path('../../../util/setting_value', __FILE__) Puppet::Type.type(:ini_subsetting).provide(:ruby) do desc ' Creates new ini_subsetting file, a specific config file with a provider that uses this as its parent and implements the method self.file_path, and that will provide the value for the path to the ini file.' def exists? setting_value.get_subsetting_value(subsetting, resource[:use_exact_match]) end def create setting_value.add_subsetting( subsetting, resource[:value], resource[:use_exact_match], resource[:insert_type], resource[:insert_value] ) ini_file.set_value(section, setting, key_val_separator, setting_value.get_value) ini_file.save @ini_file = nil @setting_value = nil end def destroy setting_value.remove_subsetting(subsetting, resource[:use_exact_match]) if setting_value.get_value.empty? && resource[:delete_if_empty] ini_file.remove_setting(section, setting) else ini_file.set_value(section, setting, key_val_separator, setting_value.get_value) end ini_file.save @ini_file = nil @setting_value = nil end def value setting_value.get_subsetting_value(subsetting) end def value=(value) setting_value.add_subsetting( subsetting, value, resource[:use_exact_match], resource[:insert_type], resource[:insert_value] ) ini_file.set_value(section, setting, key_val_separator, setting_value.get_value) ini_file.save end def section resource[:section] end def setting resource[:setting] end def subsetting resource[:subsetting] end def subsetting_separator resource[:subsetting_separator] end def file_path resource[:path] end def key_val_separator resource[:key_val_separator] || '=' end def subsetting_key_val_separator resource[:subsetting_key_val_separator] || '' end def quote_char resource[:quote_char] end private def ini_file @ini_file ||= Puppet::Util::IniFile.new(file_path, key_val_separator) end def setting_value @setting_value ||= Puppet::Util::SettingValue.new( ini_file.get_value(section, setting), subsetting_separator, quote_char, subsetting_key_val_separator ) end end puppetlabs-inifile-5.4.0/lib/puppet/type0040755000000000000000000000000014316557456015253 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/type/ini_setting.rb0100644000175100001710000001003714316557455020217 0ustar00# frozen_string_literal: true require 'digest/md5' require 'puppet/parameter/boolean' Puppet::Type.newtype(:ini_setting) do desc 'ini_settings is used to manage a single setting in an INI file' ensurable do desc 'Ensurable method handles modeling creation. It creates an ensure property' newvalue(:present) do provider.create end newvalue(:absent) do provider.destroy end def insync?(current) if @resource[:refreshonly] true else current == should end end defaultto :present end def munge_boolean_md5(value) case value when true, :true, 'true', :yes, 'yes' :true when false, :false, 'false', :no, 'no' :false when :md5, 'md5' :md5 else raise(_('expected a boolean value or :md5')) end end newparam(:name, namevar: true) do desc 'An arbitrary name used as the identity of the resource.' end newparam(:section) do desc 'The name of the section in the ini file in which the setting should be defined.' defaultto('') end newparam(:setting) do desc 'The name of the setting to be defined.' munge do |value| if value.match?(%r{(^\s|\s$)}) Puppet.warn('Settings should not have spaces in the value, we are going to strip the whitespace') end value.strip end end newparam(:force_new_section_creation, boolean: true, parent: Puppet::Parameter::Boolean) do desc 'Create setting only if the section exists' defaultto(true) end newparam(:path) do desc 'The ini file Puppet will ensure contains the specified setting.' validate do |value| unless Puppet::Util.absolute_path?(value) raise(Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }) end end end newparam(:show_diff) do desc 'Whether to display differences when the setting changes.' defaultto :true newvalues(:true, :md5, :false) munge do |value| @resource.munge_boolean_md5(value) end end newparam(:key_val_separator) do desc 'The separator string to use between each setting name and value.' defaultto(' = ') end newproperty(:value) do desc 'The value of the setting to be defined.' munge do |value| value = value.unwrap if value.respond_to?(:unwrap) if ([true, false].include? value) || value.is_a?(Numeric) value.to_s else value.strip.to_s end end def should_to_s(newvalue) if @resource[:show_diff] == :true && Puppet[:show_diff] newvalue elsif @resource[:show_diff] == :md5 && Puppet[:show_diff] '{md5}' + Digest::MD5.hexdigest(newvalue.to_s) else '[redacted sensitive information]' end end def is_to_s(value) # rubocop:disable Naming/PredicateName : Changing breaks the code (./.bundle/gems/gems/puppet-5.3.3-universal-darwin/lib/puppet/parameter.rb:525:in `to_s') should_to_s(value) end def insync?(current) if @resource[:refreshonly] true else current == should end end end newparam(:section_prefix) do desc 'The prefix to the section name\'s header.' defaultto('[') end newparam(:section_suffix) do desc 'The suffix to the section name\'s header.' defaultto(']') end newparam(:indent_char) do desc 'The character to indent new settings with.' defaultto(' ') end newparam(:indent_width) do desc 'The number of indent_chars to use to indent a new setting.' end newparam(:refreshonly, boolean: true, parent: Puppet::Parameter::Boolean) do desc 'A flag indicating whether or not the ini_setting should be updated only when called as part of a refresh event' defaultto false end def refresh if self[:ensure] == :absent && self[:refreshonly] return provider.destroy end # update the value in the provider, which will save the value to the ini file provider.value = self[:value] if self[:refreshonly] end autorequire(:file) do Pathname.new(self[:path]).parent.to_s end end puppetlabs-inifile-5.4.0/lib/puppet/type/ini_subsetting.rb0100644000175100001710000000754214316557455020740 0ustar00# frozen_string_literal: true require 'digest/md5' Puppet::Type.newtype(:ini_subsetting) do desc 'ini_subsettings is used to manage multiple values in a setting in an INI file' ensurable do desc 'Ensurable method handles modeling creation. It creates an ensure property' defaultvalues defaultto :present end def munge_boolean_md5(value) case value when true, :true, 'true', :yes, 'yes' :true when false, :false, 'false', :no, 'no' :false when :md5, 'md5' :md5 else raise(_('expected a boolean value or :md5')) end end newparam(:name, namevar: true) do desc 'An arbitrary name used as the identity of the resource.' end newparam(:section) do desc 'The name of the section in the ini file in which the setting should be defined.' defaultto('') end newparam(:setting) do desc 'The name of the setting to be defined.' end newparam(:subsetting) do desc 'The name of the subsetting to be defined.' end newparam(:subsetting_separator) do desc 'The separator string between subsettings. Defaults to the empty string.' defaultto(' ') end newparam(:subsetting_key_val_separator) do desc 'The separator string between the subsetting name and its value. Defaults to the empty string.' defaultto('') end newparam(:path) do desc 'The ini file Puppet will ensure contains the specified setting.' validate do |value| unless Puppet::Util.absolute_path?(value) raise(Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }) end end end newparam(:show_diff) do desc 'Whether to display differences when the setting changes.' defaultto :true newvalues(:true, :md5, :false) munge do |value| @resource.munge_boolean_md5(value) end end newparam(:key_val_separator) do desc 'The separator string to use between each setting name and value.' defaultto(' = ') end newparam(:quote_char) do desc "The character used to quote the entire value of the setting. Valid values are '', '\"' and \"'\"" defaultto('') validate do |value| unless value.match?(%r{^["']?$}) raise Puppet::Error, _(%q(:quote_char valid values are '', '"' and "'")) end end end newparam(:use_exact_match) do desc 'Set to true if your subsettings don\'t have values and you want to use exact matches to determine if the subsetting exists.' newvalues(:true, :false) defaultto(:false) end newproperty(:value) do desc 'The value of the subsetting to be defined.' def should_to_s(newvalue) if @resource[:show_diff] == :true && Puppet[:show_diff] newvalue elsif @resource[:show_diff] == :md5 && Puppet[:show_diff] '{md5}' + Digest::MD5.hexdigest(newvalue.to_s) else '[redacted sensitive information]' end end def is_to_s(value) # rubocop:disable Naming/PredicateName : Changing breaks the code (./.bundle/gems/gems/puppet-5.3.3-universal-darwin/lib/puppet/parameter.rb:525:in `to_s') should_to_s(value) end end newparam(:insert_type) do desc <<-eof Where the new subsetting item should be inserted * :start - insert at the beginning of the line. * :end - insert at the end of the line (default). * :before - insert before the specified element if possible. * :after - insert after the specified element if possible. * :index - insert at the specified index number. eof newvalues(:start, :end, :before, :after, :index) defaultto(:end) end newparam(:insert_value) do desc 'The value for the insert types which require one.' end newparam(:delete_if_empty) do desc 'Set to true to delete the parent setting when the subsetting is empty instead of writing an empty string' newvalues(:true, :false) defaultto(:false) end end puppetlabs-inifile-5.4.0/lib/puppet/util0040755000000000000000000000000014316557456015247 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/util/external_iterator.rb0100644000175100001710000000071414316557455021433 0ustar00# frozen_string_literal: true module Puppet::Util # # external_iterator.rb # class ExternalIterator def initialize(coll) @coll = coll @cur_index = -1 end def next @cur_index += 1 item_at(@cur_index) end def peek item_at(@cur_index + 1) end private def item_at(index) if @coll.length > index [@coll[index], index] else [nil, nil] end end end end puppetlabs-inifile-5.4.0/lib/puppet/util/ini_file0040755000000000000000000000000014316557456017025 5ustar00puppetlabs-inifile-5.4.0/lib/puppet/util/ini_file/section.rb0100644000175100001710000000607514316557455021130 0ustar00# frozen_string_literal: true class Puppet::Util::IniFile # # section.rb # class Section # Some implementation details: # # * `name` will be set to the empty string for the 'global' section. # * there will always be a 'global' section, with a `start_line` of 0, # but if the file actually begins with a real section header on # the first line, then the 'global' section will have an # `end_line` of `nil`. # * `start_line` and `end_line` will be set to `nil` for a new non-global # section. def initialize(name, start_line, end_line, settings, indentation) @name = name @start_line = start_line @end_line = end_line @existing_settings = settings.nil? ? {} : settings @additional_settings = {} @indentation = indentation end attr_reader :name, :start_line, :end_line, :additional_settings, :indentation def global? @name == '' end def new_section? # a new section (global or named) will always have `end_line` # set to `nil` @end_line.nil? end def setting_names @existing_settings.keys | @additional_settings.keys end def get_value(setting_name) @existing_settings[setting_name] || @additional_settings[setting_name] end def existing_setting?(setting_name) @existing_settings.key?(setting_name) end # the global section is empty whenever it's new; # other sections are empty when they have no lines def empty? global? ? new_section? : start_line == end_line end def update_existing_setting(setting_name, value) @existing_settings[setting_name] = value end def remove_existing_setting(setting_name) @end_line -= 1 if @existing_settings.delete(setting_name) && @end_line end # This is a hacky method; it's basically called when we need to insert # a new setting but we don't want it to appear at the very end of the # section. Instead we hack it into the existing settings list and # increment our end_line number--this assumes that the caller (`ini_file`) # is doing some babysitting w/rt the other sections and the actual data # of the lines. def insert_inline_setting(setting_name, value) @existing_settings[setting_name] = value @end_line += 1 if @end_line end def set_additional_setting(setting_name, value) @additional_settings[setting_name] = value end # Decrement the start and end line numbers for the section (if they are # defined); this is intended to be called when a setting is removed # from a section that comes before this section in the ini file. def decrement_line_nums @start_line -= 1 if @start_line @end_line -= 1 if @end_line end # Increment the start and end line numbers for the section (if they are # defined); this is intended to be called when an inline setting is added # to a section that comes before this section in the ini file. def increment_line_nums @start_line += 1 if @start_line @end_line += 1 if @end_line end end end puppetlabs-inifile-5.4.0/lib/puppet/util/ini_file.rb0100644000175100001710000003003214316557455017452 0ustar00# frozen_string_literal: true require File.expand_path('../external_iterator', __FILE__) require File.expand_path('../ini_file/section', __FILE__) module Puppet::Util # # ini_file.rb # class IniFile def initialize(path, key_val_separator = ' = ', section_prefix = '[', section_suffix = ']', indent_char = ' ', indent_width = nil) k_v_s = (key_val_separator =~ %r{^\s+$}) ? ' ' : key_val_separator.strip @section_prefix = section_prefix @section_suffix = section_suffix @indent_char = indent_char @indent_width = indent_width ? indent_width.to_i : nil @section_regex = section_regex @setting_regex = %r{^(\s*)([^#;\s]|[^#;\s].*?[^\s#{k_v_s}])(\s*#{k_v_s}[ \t]*)(.*)\s*$} @commented_setting_regex = %r{^(\s*)[#;]+(\s*)(.*?[^\s#{k_v_s}])(\s*#{k_v_s}[ \t]*)(.*)\s*$} @path = path @key_val_separator = key_val_separator @section_names = [] @sections_hash = {} parse_file end def section_regex # Only put in prefix/suffix if they exist r_string = '^\s*' r_string += Regexp.escape(@section_prefix) r_string += '(.*)' r_string += Regexp.escape(@section_suffix) r_string += '\s*$' %r{#{r_string}} end attr_reader :section_names def get_settings(section_name) section = @sections_hash[section_name] section.setting_names.each_with_object({}) do |setting, result| result[setting] = section.get_value(setting) end end def section?(section_name) @sections_hash.key?(section_name) end def get_value(section_name, setting) @sections_hash[section_name].get_value(setting) if @sections_hash.key?(section_name) end def set_value(*args) case args.size when 1 section_name = args[0] when 3 # Backwards compatible set_value function, See MODULES-5172 (section_name, setting, value) = args when 4 (section_name, setting, separator, value) = args end complete_setting = { setting: setting, separator: separator, value: value, } unless @sections_hash.key?(section_name) add_section(Section.new(section_name, nil, nil, nil, nil)) end section = @sections_hash[section_name] if section.existing_setting?(setting) update_line(section, setting, value) section.update_existing_setting(setting, value) elsif find_commented_setting(section, setting) # So, this stanza is a bit of a hack. What we're trying # to do here is this: for settings that don't already # exist, we want to take a quick peek to see if there # is a commented-out version of them in the section. # If so, we'd prefer to add the setting directly after # the commented line, rather than at the end of the section. # If we get here then we found a commented line, so we # call "insert_inline_setting_line" to update the lines array insert_inline_setting_line(find_commented_setting(section, setting), section, complete_setting) # Then, we need to tell the setting object that we hacked # in an inline setting section.insert_inline_setting(setting, value) # Finally, we need to update all of the start/end line # numbers for all of the sections *after* the one that # was modified. section_index = @section_names.index(section_name) increment_section_line_numbers(section_index + 1) elsif !setting.nil? || !value.nil? section.set_additional_setting(setting, value) end end def remove_setting(section_name, setting) section = @sections_hash[section_name] return unless section.existing_setting?(setting) # If the setting is found, we have some work to do. # First, we remove the line from our array of lines: remove_line(section, setting) # Then, we need to tell the setting object to remove # the setting from its state: section.remove_existing_setting(setting) # Finally, we need to update all of the start/end line # numbers for all of the sections *after* the one that # was modified. section_index = @section_names.index(section_name) decrement_section_line_numbers(section_index + 1) return unless section.empty? # By convention, it's time to remove this newly emptied out section lines.delete_at(section.start_line) decrement_section_line_numbers(section_index + 1) @section_names.delete_at(section_index) @sections_hash.delete(section.name) end def save global_empty = @sections_hash[''].empty? && @sections_hash[''].additional_settings.empty? File.open(@path, 'w') do |fh| @section_names.each_index do |index| name = @section_names[index] section = @sections_hash[name] # We need a buffer to cache lines that are only whitespace whitespace_buffer = [] if section.new_section? && !section.global? if index == 1 && !global_empty || index > 1 fh.puts('') end fh.puts("#{@section_prefix}#{section.name}#{@section_suffix}") end unless section.new_section? # write all of the pre-existing lines (section.start_line..section.end_line).each do |line_num| line = lines[line_num] # We buffer any lines that are only whitespace so that # if they are at the end of a section, we can insert # any new settings *before* the final chunk of whitespace # lines. if line.match?(%r{^\s*$}) whitespace_buffer << line else # If we get here, we've found a non-whitespace line. # We'll flush any cached whitespace lines before we # write it. flush_buffer_to_file(whitespace_buffer, fh) fh.puts(line) end end end # write new settings, if there are any section.additional_settings.each_pair do |key, value| fh.puts("#{@indent_char * (@indent_width || section.indentation || 0)}#{key}#{@key_val_separator}#{value}") end if !whitespace_buffer.empty? flush_buffer_to_file(whitespace_buffer, fh) elsif section.new_section? && !section.additional_settings.empty? && (index < @section_names.length - 1) # We get here if there were no blank lines at the end of the # section. # # If we are adding a new section with a new setting, # and if there are more sections that come after this one, # we'll write one blank line just so that there is a little # whitespace between the sections. # if (section.end_line.nil? && fh.puts('') end end end end private def add_section(section) @sections_hash[section.name] = section @section_names << section.name end def parse_file line_iter = create_line_iter # We always create a "global" section at the beginning of the file, for # anything that appears before the first named section. section = read_section('', 0, line_iter) add_section(section) line, line_num = line_iter.next while line if (match = @section_regex.match(line)) section = read_section(match[1], line_num, line_iter) add_section(section) end line, line_num = line_iter.next end end def read_section(name, start_line, line_iter) settings = {} end_line_num = start_line min_indentation = nil empty = true loop do line, line_num = line_iter.peek if line_num.nil? || @section_regex.match(line) # the global section always exists, even when it's empty; # when it's empty, we must be sure it's thought of as new, # which is signalled with a nil ending line end_line_num = nil if name == '' && empty return Section.new(name, start_line, end_line_num, settings, min_indentation) end if (match = @setting_regex.match(line)) settings[match[2]] = match[4] indentation = match[1].length min_indentation = [indentation, min_indentation || indentation].min end end_line_num = line_num empty = false line_iter.next end end def update_line(section, setting, value) (section.start_line..section.end_line).each do |line_num| next unless (match = @setting_regex.match(lines[line_num])) if match[2] == setting lines[line_num] = "#{match[1]}#{match[2]}#{match[3]}#{value}" end end end def remove_line(section, setting) (section.start_line..section.end_line).each do |line_num| next unless (match = @setting_regex.match(lines[line_num])) if match[2] == setting lines.delete_at(line_num) end end end def create_line_iter ExternalIterator.new(lines) end def lines @lines ||= IniFile.readlines(@path) end # This is mostly here because it makes testing easier--we don't have # to try to stub any methods on File. def self.readlines(path) # rubocop:disable Lint/IneffectiveAccessModifier : Attempting to change breaks tests # If this type is ever used with very large files, we should # write this in a different way, using a temp # file; for now assuming that this type is only used on # small-ish config files that can fit into memory without # too much trouble. File.file?(path) ? File.readlines(path) : [] end # This utility method scans through the lines for a section looking for # commented-out versions of a setting. It returns `nil` if it doesn't # find one. If it does find one, then it returns a hash containing # two keys: # # :line_num - the line number that contains the commented version # of the setting # :match - the ruby regular expression match object, which can # be used to mimic the whitespace from the comment line def find_commented_setting(section, setting) return nil if section.new_section? (section.start_line..section.end_line).each do |line_num| next unless (match = @commented_setting_regex.match(lines[line_num])) if match[3] == setting return { match: match, line_num: line_num } end end nil end # This utility method is for inserting a line into the existing # lines array. The `result` argument is expected to be in the # format of the return value of `find_commented_setting`. def insert_inline_setting_line(result, section, complete_setting) line_num = result[:line_num] s = complete_setting lines.insert(line_num + 1, "#{@indent_char * (@indent_width || section.indentation || 0)}#{s[:setting]}#{s[:separator]}#{s[:value]}") end # Utility method; given a section index (index into the @section_names # array), decrement the start/end line numbers for that section and all # all of the other sections that appear *after* the specified section. def decrement_section_line_numbers(section_index) @section_names[section_index..(@section_names.length - 1)].each do |name| section = @sections_hash[name] section.decrement_line_nums end end # Utility method; given a section index (index into the @section_names # array), increment the start/end line numbers for that section and all # all of the other sections that appear *after* the specified section. def increment_section_line_numbers(section_index) @section_names[section_index..(@section_names.length - 1)].each do |name| section = @sections_hash[name] section.increment_line_nums end end def flush_buffer_to_file(buffer, fh) return if buffer.empty? buffer.each { |l| fh.puts(l) } buffer.clear end end end puppetlabs-inifile-5.4.0/lib/puppet/util/setting_value.rb0100644000175100001710000001650414316557455020555 0ustar00# frozen_string_literal: true module Puppet::Util # This class can work with a list of subsettings inside # an ini file setting string to add, remove, extract and set their values. class SettingValue # The constructor method # @param setting_value [String] The initial setting value # @param subsetting_separator [String] The character is used to separate # subsettings in the setting_value string. # @param default_quote_char [String] Quote the setting string with this character. def initialize(setting_value, subsetting_separator = ' ', default_quote_char = '', key_val_separator = '') @setting_value = setting_value @subsetting_separator = subsetting_separator @quote_char = default_quote_char @key_val_separator = key_val_separator @subsetting_items = [] return unless @setting_value unquoted, quote_char = unquote_setting_value(setting_value) @quote_char = quote_char unless quote_char.empty? # an item can contain escaped separator @subsetting_items = unquoted.scan(Regexp.new("(?:(?:[^\\#{@subsetting_separator}]|\\.)+)")) @subsetting_items.map! { |item| item.strip } end # If the setting value is quoted, the quotes are # removed and the unquoted string and the quoting # character are returned. # @param setting_value [String] The input value # @return [Array] The unquoted string and the quoting character def unquote_setting_value(setting_value) quote_char = '' if setting_value.start_with?('"') && setting_value.end_with?('"') quote_char = '"' elsif setting_value.start_with?("'") && setting_value.end_with?("'") quote_char = "'" end unquoted = if quote_char != '' setting_value[1, setting_value.length - 2] else setting_value end [unquoted, quote_char] end # Get the resulting setting value by joining all the # subsettings, separator and quote characters. # @return [String] def get_value value = @subsetting_items.join @subsetting_separator @quote_char + value + @quote_char end # Get the value of the given subsetting item. # If the exact match is used the value will be true # if the item is found. # @param subsetting [String] The name of the subsetting to add. # @param use_exact_match [:true,:false] Should the full name match be used? # @return [nil,true,String] def get_subsetting_value(subsetting, use_exact_match = :false) index = find_subsetting(subsetting, use_exact_match) # the item is not found in the list return nil unless index # the exact match is set and the item is found, the value should be true return true if use_exact_match == :true item = @subsetting_items[index] item[(subsetting.length + @key_val_separator.length)..-1] end # Add a new subsetting item to the list of existing items # if such item is not already there. # @param subsetting [String] The name of the subsetting to add. # @param subsetting_value [String] The value of the subsetting. # It will be appended to the name. # @param use_exact_match [:true,:false] Should the full name match be used? # @param [Symbol] insert_type # @param [String,Integer] insert_value # @return [Array] The resulting subsettings list. def add_subsetting(subsetting, subsetting_value, use_exact_match = :false, insert_type = :end, insert_value = nil) index = find_subsetting(subsetting, use_exact_match) # update the existing values if the subsetting is found in the list return update_subsetting(subsetting, subsetting_value, use_exact_match) if index new_item = item_value(subsetting, subsetting_value) case insert_type when :start @subsetting_items.unshift(new_item) when :end @subsetting_items.push(new_item) when :before before_index = find_subsetting(insert_value, use_exact_match) if before_index @subsetting_items.insert(before_index, new_item) else @subsetting_items.push(new_item) end when :after after_index = find_subsetting(insert_value, use_exact_match) if after_index @subsetting_items.insert(after_index + 1, new_item) else @subsetting_items.push(new_item) end when :index before_index = insert_value.to_i before_index = @subsetting_items.length if before_index > @subsetting_items.length @subsetting_items.insert(before_index, new_item) else @subsetting_items.push(new_item) end @subsetting_items end # Update all matching items in the settings list to the new values. # @param subsetting [String] The name of the subsetting to add. # @param subsetting_value [String] The value of the subsetting. # @param use_exact_match [:true,:false] Should the full name match be used? # @return [Array] The resulting subsettings list. def update_subsetting(subsetting, subsetting_value, use_exact_match = :false) new_item = item_value(subsetting, subsetting_value) @subsetting_items.map! do |item| if match_subsetting?(item, subsetting, use_exact_match) new_item else item end end end # Find the first subsetting item matching the given name, # or, if the exact match is set, equal to the given name # and return its array index value. Returns nil if not found. # @param subsetting [String] The name of the subsetting to search. # @param use_exact_match [:true,:false] Look for the full string match? # @return [Integer, nil] def find_subsetting(subsetting, use_exact_match = :false) @subsetting_items.index do |item| match_subsetting?(item, subsetting, use_exact_match) end end # Check if the subsetting item matches the given name. # If the exact match is set the entire item is matched, # and only the item name and separator string if not. # @param item [String] The item value to check against the subsetting name. # @param subsetting [String] The subsetting name. # @param use_exact_match [:true,:false] Look for the full string match? # @return [true,false] def match_subsetting?(item, subsetting, use_exact_match = :false) if use_exact_match == :true item.eql?(subsetting) else item.start_with?(subsetting + @key_val_separator) end end # Remove all the subsetting items that match # the given subsetting name. # @param subsetting [String] The subsetting name to remove. # @param use_exact_match [:true,:false] Look for the full string match? # @return [Array] The resulting subsettings list. def remove_subsetting(subsetting, use_exact_match = :false) @subsetting_items.delete_if do |item| match_subsetting?(item, subsetting, use_exact_match) end end # The actual value of the subsetting item. # It's built from the subsetting name, its value and the separator # string if present. # @param subsetting [String] The subsetting name # @param subsetting_value [String] The value of the subsetting # @return [String] def item_value(subsetting, subsetting_value) (subsetting || '') + (@key_val_separator || '') + (subsetting_value || '') end end end puppetlabs-inifile-5.4.0/metadata.json0100644000175100001710000000430514316557455014766 0ustar00{ "name": "puppetlabs-inifile", "version": "5.4.0", "author": "puppetlabs", "summary": "Resource types for managing settings in INI files", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-inifile", "project_page": "https://github.com/puppetlabs/puppetlabs-inifile", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.13.0 < 9.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7", "8", "9" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "7", "8" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "12", "15" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "9", "10", "11" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "18.04", "20.04", "22.04" ] }, { "operatingsystem": "Solaris", "operatingsystemrelease": [ "11" ] }, { "operatingsystem": "Windows", "operatingsystemrelease": [ "10", "2012 R2", "2016", "2019", "2022" ] }, { "operatingsystem": "AIX", "operatingsystemrelease": [ "7.1" ] }, { "operatingsystem": "Rocky", "operatingsystemrelease": [ "8" ] }, { "operatingsystem": "AlmaLinux", "operatingsystemrelease": [ "8" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 6.0.0 < 8.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", "template-ref": "heads/main-0-g806810b", "pdk-version": "2.3.0" } puppetlabs-inifile-5.4.0/pdk.yaml0100644000175100001710000000001714316557455013751 0ustar00--- ignore: [] puppetlabs-inifile-5.4.0/provision.yaml0100644000175100001710000000312114316557455015222 0ustar00--- default: provisioner: docker images: - litmusimage/centos:7 vagrant: provisioner: vagrant images: - centos/7 - generic/ubuntu1804 - gusztavvargadr/windows-server travis_deb: provisioner: docker images: - litmusimage/debian:8 - litmusimage/debian:9 - litmusimage/debian:10 travis_ub_6: provisioner: docker images: - litmusimage/ubuntu:14.04 - litmusimage/ubuntu:16.04 - litmusimage/ubuntu:18.04 - litmusimage/ubuntu:20.04 travis_el7: provisioner: docker images: - litmusimage/centos:7 - litmusimage/oraclelinux:7 - litmusimage/scientificlinux:7 travis_el8: provisioner: docker images: - litmusimage/centos:8 release_checks_6: 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 - sles-15-x86_64 - ubuntu-1404-x86_64 - ubuntu-1604-x86_64 - ubuntu-1804-x86_64 - ubuntu-2004-x86_64 - win-2008r2-x86_64 - win-2012r2-x86_64 - win-2016-x86_64 - win-2019-x86_64 - win-10-pro-x86_64 release_checks_7: provisioner: abs images: - redhat-7-x86_64 - redhat-8-x86_64 - centos-7-x86_64 - centos-8-x86_64 - oracle-7-x86_64 - scientific-7-x86_64 - sles-12-x86_64 - sles-15-x86_64 - debian-9-x86_64 - debian-10-x86_64 - ubuntu-1804-x86_64 - ubuntu-2004-x86_64 - win-2012r2-x86_64 - win-2016-x86_64 - win-2019-x86_64 - win-10-pro-x86_64