diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index d59437a..4021da7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,230 +1,217 @@ name: "nightly" on: schedule: - cron: '0 0 * * *' 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: kvrhdn/gha-buildevents@v1.0.2 + uses: kvrhdn/gha-buildevents@5be4636b81803713c94d7cb7e3a4b85d759df112 # pin@v1.0.2 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} - name: "Honeycomb: Start first step" run: | echo STEP_ID=0 >> $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: actions/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: ruby-version: "2.7" - name: Cache gems uses: actions/cache@v2 if: ${{ github.repository_owner == 'puppetlabs' }} with: path: vendor/gems key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} restore-keys: | ${{ runner.os }}-${{ github.event_name }}- ${{ runner.os }}- - name: Install gems if: ${{ github.repository_owner == 'puppetlabs' }} run: | buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean - 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 else echo "::set-output name=matrix::{}" fi - name: "Honeycomb: Record setup time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' Acceptance: 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.platform }}' >> $BUILDEVENT_FILE echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE - name: "Honeycomb: Start recording" - uses: kvrhdn/gha-buildevents@v1.0.2 + uses: kvrhdn/gha-buildevents@5be4636b81803713c94d7cb7e3a4b85d759df112 # pin@v1.0.2 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} matrix-key: ${{ matrix.platform }}-${{ matrix.collection }} - name: "Honeycomb: start first step" run: | echo STEP_ID=${{ matrix.platform }}-${{ 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: actions/setup-ruby@v1 with: ruby-version: "2.7" - name: Cache gems uses: actions/cache@v2 with: path: vendor/gems key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} restore-keys: | ${{ runner.os }}-${{ github.event_name }}- ${{ runner.os }}- - name: "Honeycomb: Record cache setup time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Cache retrieval' echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-2 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Bundler Setup run: | buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Bundler Setup time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Bundler Setup' echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-3 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Provision test environment run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platform }}' -- bundle exec rake 'litmus:provision[provision::provision_service,${{ matrix.platform }}]' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: echo ::group::=== INVENTORY === sed -e 's/password: .*/password: "[redacted]"/' < inventory.yaml || true echo ::endgroup:: - # The provision service hands out machines as soon as they're provisioned. - # The GCP VMs might still take a while to spool up and configure themselves fully. - # This retry loop spins until all agents have been installed successfully. - name: Install agent - uses: nick-invision/retry@v1 - with: - timeout_minutes: 30 - max_attempts: 5 - retry_wait_seconds: 60 - command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - # The agent installer on windows does not finish in time for this to work. To - # work around this for now, retry after a minute if installing the module failed. - name: Install module - uses: nick-invision/retry@v1 - with: - timeout_minutes: 30 - max_attempts: 2 - retry_wait_seconds: 60 - command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus: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.platform }}-${{ matrix.collection }}-4 >> $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.platform }}-${{ matrix.collection }}-5 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Remove test environment if: ${{ always() }} run: | if [ -f 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: always() name: Post Workflow Status To Slack needs: - Acceptance runs-on: ubuntu-20.04 steps: - name: Slack Workflow Notification - uses: Gamesight/slack-workflow-status@master + uses: Gamesight/slack-workflow-status@88ee95b73b4669825883ddf22747966204663e58 # pin@master with: # Required Input repo_token: ${{ secrets.GITHUB_TOKEN }} slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} # Optional Input channel: '#team-ia-bots' name: 'GABot' diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml index 17f5a64..2b5ab1f 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -1,211 +1,198 @@ name: "PR Testing" on: [pull_request] env: HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 HONEYCOMB_DATASET: litmus tests jobs: setup_matrix: name: "Setup Test Matrix" runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.get-matrix.outputs.matrix }} steps: - name: "Honeycomb: Start recording" - uses: kvrhdn/gha-buildevents@v1.0.2 + uses: kvrhdn/gha-buildevents@5be4636b81803713c94d7cb7e3a4b85d759df112 # pin@v1.0.2 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} - name: "Honeycomb: Start first step" run: | echo STEP_ID=0 >> $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: actions/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: ruby-version: "2.7" - name: Cache gems uses: actions/cache@v2 if: ${{ github.repository_owner == 'puppetlabs' }} with: path: vendor/gems key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} restore-keys: | ${{ runner.os }}-${{ github.event_name }}- ${{ runner.os }}- - name: Install gems if: ${{ github.repository_owner == 'puppetlabs' }} run: | buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean - 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 else echo "::set-output name=matrix::{}" fi - name: "Honeycomb: Record setup time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' Acceptance: 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.platform }}' >> $BUILDEVENT_FILE echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE - name: "Honeycomb: Start recording" - uses: kvrhdn/gha-buildevents@v1.0.2 + uses: kvrhdn/gha-buildevents@5be4636b81803713c94d7cb7e3a4b85d759df112 # pin@v1.0.2 with: apikey: ${{ env.HONEYCOMB_WRITEKEY }} dataset: ${{ env.HONEYCOMB_DATASET }} job-status: ${{ job.status }} matrix-key: ${{ matrix.platform }}-${{ matrix.collection }} - name: "Honeycomb: start first step" run: | echo STEP_ID=${{ matrix.platform }}-${{ 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: actions/setup-ruby@v1 with: ruby-version: "2.7" - name: Cache gems uses: actions/cache@v2 with: path: vendor/gems key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} restore-keys: | ${{ runner.os }}-${{ github.event_name }}- ${{ runner.os }}- - name: "Honeycomb: Record cache setup time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Cache retrieval' echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-2 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Bundler Setup run: | buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean echo ::group::bundler environment buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env echo ::endgroup:: - name: "Honeycomb: Record Bundler Setup time" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Bundler Setup' echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-3 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Provision test environment run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platform }}' -- bundle exec rake 'litmus:provision[provision::provision_service,${{ matrix.platform }}]' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: echo ::group::=== INVENTORY === sed -e 's/password: .*/password: "[redacted]"/' < inventory.yaml || true echo ::endgroup:: - # The provision service hands out machines as soon as they're provisioned. - # The GCP VMs might still take a while to spool up and configure themselves fully. - # This retry loop spins until all agents have been installed successfully. - name: Install agent - uses: nick-invision/retry@v1 - with: - timeout_minutes: 30 - max_attempts: 5 - retry_wait_seconds: 60 - command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - # The agent installer on windows does not finish in time for this to work. To - # work around this for now, retry after a minute if installing the module failed. - name: Install module - uses: nick-invision/retry@v1 - with: - timeout_minutes: 30 - max_attempts: 2 - retry_wait_seconds: 60 - command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus: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.platform }}-${{ matrix.collection }}-4 >> $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.platform }}-${{ matrix.collection }}-5 >> $GITHUB_ENV echo STEP_START=$(date +%s) >> $GITHUB_ENV - name: Remove test environment if: ${{ always() }} run: | if [ -f inventory.yaml ]; then buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' echo ::group::=== REQUEST === cat request.json || true echo echo ::endgroup:: fi - name: "Honeycomb: Record removal times" if: ${{ always() }} run: | buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' diff --git a/.rubocop.yml b/.rubocop.yml index b7c972b..1823837 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,138 +1,538 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.4' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" - "**/Gemfile" - "**/Rakefile" - pkg/**/* - spec/fixtures/**/* - vendor/**/* - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. Exclude: - spec/acceptance/**/*.rb RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining -Style/BracesAroundHashParameters: - Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. - See https://github.com/rubocop-hq/rubocop/pull/7643 - Enabled: false Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact Style/EmptyElse: Description: Enforce against empty else clauses, but allow `nil` for clarity. EnforcedStyle: empty Style/FormatString: Description: Following the main puppet project's style, prefer the % format format. EnforcedStyle: percent Style/FormatStringToken: Description: Following the main puppet project's style, prefer the simpler template tokens over annotated ones. EnforcedStyle: template Style/Lambda: Description: Prefer the keyword for easier discoverability. EnforcedStyle: literal Style/RegexpLiteral: Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 EnforcedStyle: percent_r Style/TernaryParentheses: Description: Checks for use of parentheses around ternary conditions. Enforce parentheses on complex expressions for better readability, but seriously consider breaking it up. EnforcedStyle: require_parentheses_when_complex Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets -inherit_from: ".rubocop_todo.yml" RSpec/MessageSpies: EnforcedStyle: receive Style/Documentation: Exclude: - lib/puppet/parser/functions/**/* - spec/**/* Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/Caller: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/Casecmp: + Enabled: true +Performance/CollectionLiteralInLoop: + Exclude: + - spec/**/* + Enabled: true +Performance/CompareWithBlock: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/Count: + Enabled: true +Performance/Detect: + Enabled: true +Performance/DoubleStartEndWith: + Enabled: true +Performance/EndWith: + Enabled: true +Performance/FixedSize: + Enabled: true +Performance/FlatMap: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RangeInclude: + Enabled: true +Performance/RedundantBlockCall: + Enabled: true +Performance/RedundantMatch: + Enabled: true +Performance/RedundantMerge: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/RegexpMatch: + Enabled: true +Performance/ReverseEach: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/Size: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StartWith: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/StringReplacement: + Enabled: true +Performance/Sum: + Enabled: true +Performance/TimesMap: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/InsecureProtocolSource: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Gemspec/DuplicatedAssignment: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: Enabled: false Metrics/MethodLength: Enabled: false Metrics/ModuleLength: Enabled: false Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/CurrentPathExpectation: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/Capybara/VisibilityMatcher: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false Style/AsciiComments: Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NilLambda: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false +Style/SwapValues: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false diff --git a/.sync.yml b/.sync.yml index a2bc3db..b82952b 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,60 +1,47 @@ --- ".gitlab-ci.yml": delete: true -".rubocop.yml": - default_configs: - inherit_from: ".rubocop_todo.yml" - require: - - rubocop-i18n - - rubocop-rspec ".travis.yml": - global_env: + global_env: - HONEYCOMB_WRITEKEY="7f3c63a70eecc61d635917de46bea4e6",HONEYCOMB_DATASET="litmus tests" deploy_to_forge: enabled: false branches: - release use_litmus: true litmus: provision_list: - ---travis_el - travis_deb complex: - collection: puppet_collection: - puppet6 provision_list: - travis_ub_6 - collection: puppet_collection: - puppet5 provision_list: - travis_ub_5 simplecov: true notifications: slack: secure: KeXxAkZ1x/P1otYM3pgpEFnJdFRLDDz0YlTmDRwdNYy09LGo4lRUuUUEUUZoTe4oQaMb3+NigiAs+3j2A7OIMKlcUFWz5zetqnyMdIceJm99iJOD6Ng/kVblo38bN28oVwss66XzG1T0c0+YFMF+X0NkUezbr6RaJrZNsCNTH9M= appveyor.yml: delete: true Gemfile: optional: ":development": - gem: github_changelog_generator - git: https://github.com/skywinder/github-changelog-generator - ref: 20ee04ba1234e9e83eb2ffb5056e23d641c7a018 - condition: Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') - - gem: puppet-lint-i18n -Rakefile: - requires: - - puppet_pot_generator/rake_tasks spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true .gitpod.Dockerfile: unmanaged: false .gitpod.yml: unmanaged: false .github/workflows/pr_test.yml: unmanaged: false .github/workflows/nightly.yml: unmanaged: false diff --git a/.travis.yml b/.travis.yml index 3c16fd8..05d4b78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,93 +1,89 @@ --- os: linux dist: xenial language: ruby cache: bundler before_install: - bundle -v - rm -f Gemfile.lock - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - gem --version - bundle -v script: - 'SIMPLECOV=yes bundle exec rake $CHECK' bundler_args: --without system_tests rvm: - 2.5.7 env: global: - HONEYCOMB_WRITEKEY="7f3c63a70eecc61d635917de46bea4e6",HONEYCOMB_DATASET="litmus tests" stages: - static - spec - acceptance jobs: fast_finish: true include: - - + - bundler_args: --with system_tests before_script: - "bundle exec rake 'litmus:provision_list[travis_ub_6]'" - "bundle exec rake 'litmus:install_agent[puppet6]'" - "bundle exec rake litmus:install_module" - bundler_args: env: PLATFORMS=travis_ub_6_puppet6 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker stage: acceptance - - + - bundler_args: --with system_tests before_script: - "bundle exec rake 'litmus:provision_list[travis_ub_5]'" - "bundle exec rake 'litmus:install_agent[puppet5]'" - "bundle exec rake litmus:install_module" - bundler_args: env: PLATFORMS=travis_ub_5_puppet5 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker stage: acceptance - - + - bundler_args: --with system_tests before_script: - "bundle exec rake 'litmus:provision_list[travis_deb]'" - "bundle exec rake 'litmus:install_agent[puppet5]'" - "bundle exec rake litmus:install_module" - bundler_args: env: PLATFORMS=travis_deb_puppet5 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker stage: acceptance - - + - bundler_args: --with system_tests before_script: - "bundle exec rake 'litmus:provision_list[travis_deb]'" - "bundle exec rake 'litmus:install_agent[puppet6]'" - "bundle exec rake litmus:install_module" - bundler_args: env: PLATFORMS=travis_deb_puppet6 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker stage: acceptance - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" stage: static - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec rvm: 2.4.5 stage: spec - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec rvm: 2.5.7 stage: spec branches: only: - main - /^v\d/ - release notifications: email: false slack: secure: KeXxAkZ1x/P1otYM3pgpEFnJdFRLDDz0YlTmDRwdNYy09LGo4lRUuUUEUUZoTe4oQaMb3+NigiAs+3j2A7OIMKlcUFWz5zetqnyMdIceJm99iJOD6Ng/kVblo38bN28oVwss66XzG1T0c0+YFMF+X0NkUezbr6RaJrZNsCNTH9M= diff --git a/Gemfile b/Gemfile index 19423c5..ae2b430 100644 --- a/Gemfile +++ b/Gemfile @@ -1,75 +1,73 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' def location_for(place_or_version, fake_version = nil) git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} file_url_regex = %r{\Afile:\/\/(?.*)} if place_or_version && (git_url = place_or_version.match(git_url_regex)) [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else [place_or_version, { require: false }] end end ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') - gem "puppet-lint-i18n", require: false + gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "github_changelog_generator", require: false +end +group :system_tests do + gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] end puppet_version = ENV['PUPPET_GEM_VERSION'] facter_version = ENV['FACTER_GEM_VERSION'] hiera_version = ENV['HIERA_GEM_VERSION'] gems = {} gems['puppet'] = location_for(puppet_version) # If facter or hiera versions have been specified via the environment # variables gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} # If we're using a Puppet gem on Windows which handles its own win32-xxx gem # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). gems['win32-dir'] = ['<= 0.4.9', require: false] gems['win32-eventlog'] = ['<= 0.6.5', require: false] gems['win32-process'] = ['<= 0.7.5', require: false] gems['win32-security'] = ['<= 0.2.5', require: false] gems['win32-service'] = ['0.8.8', require: false] end gems.each do |gem_name, gem_params| gem gem_name, *gem_params end # Evaluate Gemfile.local and ~/.gemfile if they exist extra_gemfiles = [ "#{__FILE__}.local", File.join(Dir.home, '.gemfile'), ] extra_gemfiles.each do |gemfile| if File.file?(gemfile) && File.readable?(gemfile) eval(File.read(gemfile), binding) end end # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index f8ec754..0a5093b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,88 +1,87 @@ # frozen_string_literal: true require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? -require 'puppet_pot_generator/rake_tasks' def changelog_user return unless Rake.application.top_level_tasks.include? "changelog" returnVal = nil || JSON.load(File.read('metadata.json'))['author'] raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator user:#{returnVal}" returnVal end def changelog_project return unless Rake.application.top_level_tasks.include? "changelog" returnVal = nil returnVal ||= begin metadata_source = JSON.load(File.read('metadata.json'))['source'] metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) metadata_source_match && metadata_source_match[1] end raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator project:#{returnVal}" returnVal end def changelog_future_release return unless Rake.application.top_level_tasks.include? "changelog" returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator future_release:#{returnVal}" returnVal end PuppetLint.configuration.send('disable_relative') if Bundler.rubygems.find_name('github_changelog_generator').any? GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? config.user = "#{changelog_user}" config.project = "#{changelog_project}" config.future_release = "#{changelog_future_release}" config.exclude_labels = ['maintenance'] config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." config.add_pr_wo_labels = true config.issues = false config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", "labels" => ["backwards-incompatible"], }, "Added" => { "prefix" => "### Added", "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", "labels" => ["bug", "documentation", "bugfix"], }, } end else desc 'Generate a Changelog from GitHub' task :changelog do raise < 1.15' condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/lib/facter/apt_reboot_required.rb b/lib/facter/apt_reboot_required.rb index 1e1650a..7656f70 100644 --- a/lib/facter/apt_reboot_required.rb +++ b/lib/facter/apt_reboot_required.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # apt_reboot_required.rb Facter.add(:apt_reboot_required) do confine osfamily: 'Debian' setcode do File.file?('/var/run/reboot-required') end end diff --git a/lib/facter/apt_update_last_success.rb b/lib/facter/apt_update_last_success.rb index 9866a2b..84acec1 100644 --- a/lib/facter/apt_update_last_success.rb +++ b/lib/facter/apt_update_last_success.rb @@ -1,16 +1,18 @@ +# frozen_string_literal: true + require 'facter' # This is derived from the file /var/lib/apt/periodic/update-success-stamp # This is generated upon a successful apt-get update run natively in ubuntu. # the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes Facter.add('apt_update_last_success') do confine osfamily: 'Debian' setcode do if File.exist?('/var/lib/apt/periodic/update-success-stamp') # get epoch time File.mtime('/var/lib/apt/periodic/update-success-stamp').to_i else -1 end end end diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index eae1cf3..e3b17d9 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -1,106 +1,108 @@ +# frozen_string_literal: true + apt_package_updates = nil apt_dist_updates = nil # Executes the upgrading of packages # @param # upgrade_option Type of upgrade passed into apt-get command arguments i.e. 'upgrade' or 'dist-upgrade' def get_updates(upgrade_option) apt_updates = nil if File.executable?('/usr/bin/apt-get') apt_get_result = Facter::Util::Resolution.exec("/usr/bin/apt-get -s -o Debug::NoLocking=true #{upgrade_option} 2>&1") unless apt_get_result.nil? apt_updates = [[], []] apt_get_result.each_line do |line| - next unless line =~ %r{^Inst\s} + next unless %r{^Inst\s}.match?(line) package = line.gsub(%r{^Inst\s([^\s]+)\s.*}, '\1').strip apt_updates[0].push(package) security_matches = [ %r{ Debian-Security:}, %r{ Ubuntu[^\s]+-security[, ]}, %r{ gNewSense[^\s]+-security[, ]}, ] re = Regexp.union(security_matches) if line.match(re) apt_updates[1].push(package) end end end end apt_updates end Facter.add('apt_has_updates') do confine osfamily: 'Debian' setcode do apt_package_updates = get_updates('upgrade') if !apt_package_updates.nil? && apt_package_updates.length == 2 apt_package_updates != [[], []] end end end Facter.add('apt_has_dist_updates') do confine osfamily: 'Debian' setcode do apt_dist_updates = get_updates('dist-upgrade') if !apt_dist_updates.nil? && apt_dist_updates.length == 2 apt_dist_updates != [[], []] end end end Facter.add('apt_package_updates') do confine apt_has_updates: true setcode do apt_package_updates[0] end end Facter.add('apt_package_dist_updates') do confine apt_has_dist_updates: true setcode do apt_dist_updates[0] end end Facter.add('apt_package_security_updates') do confine apt_has_updates: true setcode do apt_package_updates[1] end end Facter.add('apt_package_security_dist_updates') do confine apt_has_dist_updates: true setcode do apt_dist_updates[1] end end Facter.add('apt_updates') do confine apt_has_updates: true setcode do Integer(apt_package_updates[0].length) end end Facter.add('apt_dist_updates') do confine apt_has_dist_updates: true setcode do Integer(apt_dist_updates[0].length) end end Facter.add('apt_security_updates') do confine apt_has_updates: true setcode do Integer(apt_package_updates[1].length) end end Facter.add('apt_security_dist_updates') do confine apt_has_dist_updates: true setcode do Integer(apt_dist_updates[1].length) end end diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 9f70cc6..e9e377b 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -1,251 +1,253 @@ +# frozen_string_literal: true + require 'open-uri' require 'net/ftp' require 'tempfile' Puppet::Type.type(:apt_key).provide(:apt_key) do desc 'apt-key provider for apt_key resource' confine osfamily: :debian defaultfor osfamily: :debian commands apt_key: 'apt-key' commands gpg: '/usr/bin/gpg' def self.instances cli_args = ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'] key_output = apt_key(cli_args).encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') pub_line, sub_line, fpr_line = nil key_array = key_output.split("\n").map do |line| if line.start_with?('pub') pub_line = line # reset fpr_line, to skip any previous subkeys which were collected fpr_line = nil sub_line = nil elsif line.start_with?('sub') sub_line = line elsif line.start_with?('fpr') fpr_line = line end if sub_line && fpr_line sub_line, fpr_line = nil next end next unless pub_line && fpr_line line_hash = key_line_hash(pub_line, fpr_line) # reset everything pub_line, fpr_line = nil expired = false if line_hash[:key_expiry] expired = Time.now >= line_hash[:key_expiry] end new( name: line_hash[:key_fingerprint], id: line_hash[:key_long], fingerprint: line_hash[:key_fingerprint], short: line_hash[:key_short], long: line_hash[:key_long], ensure: :present, expired: expired, expiry: line_hash[:key_expiry].nil? ? nil : line_hash[:key_expiry].strftime('%Y-%m-%d'), size: line_hash[:key_size], type: line_hash[:key_type], created: line_hash[:key_created].strftime('%Y-%m-%d'), ) end key_array.compact! end def self.prefetch(resources) apt_keys = instances resources.each_key do |name| if name.length == 40 provider = apt_keys.find { |key| key.fingerprint == name } resources[name].provider = provider if provider elsif name.length == 16 provider = apt_keys.find { |key| key.long == name } resources[name].provider = provider if provider elsif name.length == 8 provider = apt_keys.find { |key| key.short == name } resources[name].provider = provider if provider end end end def self.key_line_hash(pub_line, fpr_line) pub_split = pub_line.split(':') fpr_split = fpr_line.split(':') fingerprint = fpr_split.last return_hash = { key_fingerprint: fingerprint, key_long: fingerprint[-16..-1], # last 16 characters of fingerprint key_short: fingerprint[-8..-1], # last 8 characters of fingerprint key_size: pub_split[2], key_type: nil, key_created: Time.at(pub_split[5].to_i), key_expiry: pub_split[6].empty? ? nil : Time.at(pub_split[6].to_i), } # set key type based on types defined in /usr/share/doc/gnupg/DETAILS.gz case pub_split[3] when '1' return_hash[:key_type] = :rsa when '17' return_hash[:key_type] = :dsa when '18' return_hash[:key_type] = :ecc when '19' return_hash[:key_type] = :ecdsa end return_hash end def source_to_file(value) parsed_value = URI.parse(value) if parsed_value.scheme.nil? raise(_('The file %{_value} does not exist') % { _value: value }) unless File.exist?(value) # Because the tempfile method has to return a live object to prevent GC # of the underlying file from occuring too early, we also have to return # a file object here. The caller can still call the #path method on the # closed file handle to get the path. f = File.open(value, 'r') f.close f else begin # Only send basic auth if URL contains userinfo # Some webservers (e.g. Amazon S3) return code 400 if empty basic auth is sent if parsed_value.userinfo.nil? key = if parsed_value.scheme == 'https' && resource[:weak_ssl] == true open(parsed_value, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read else parsed_value.read end else user_pass = parsed_value.userinfo.split(':') parsed_value.userinfo = '' key = open(parsed_value, http_basic_authentication: user_pass).read end rescue OpenURI::HTTPError, Net::FTPPermError => e raise(_('%{_e} for %{_resource}') % { _e: e.message, _resource: resource[:source] }) rescue SocketError raise(_('could not resolve %{_resource}') % { _resource: resource[:source] }) else tempfile(key) end end end # The tempfile method needs to return the tempfile object to the caller, so # that it doesn't get deleted by the GC immediately after it returns. We # want the caller to control when it goes out of scope. def tempfile(content) file = Tempfile.new('apt_key') file.write content file.close # confirm that the fingerprint from the file, matches the long key that is in the manifest if name.size == 40 if File.executable? command(:gpg) extracted_key = execute(["#{command(:gpg)} --no-tty --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], failonfail: false) extracted_key = extracted_key.chomp found_match = false extracted_key.each_line do |line| if line.chomp == name found_match = true end end unless found_match - raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Metrics/LineLength + raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Layout/LineLength end else warning('/usr/bin/gpg cannot be found for verification of the id.') end end file end # Update a key if it is expired def update_expired_key # Return without doing anything if refresh or expired is false return unless resource[:refresh] == true && resource[:expired] == true # Execute command to update key command = [] unless resource[:source].nil? && resource[:content].nil? raise(_('an unexpected condition occurred while trying to add the key: %{_resource}') % { _resource: resource[:id] }) end # Breaking up the command like this is needed because it blows up # if --recv-keys isn't the last argument. command.push('adv', '--no-tty', '--keyserver', resource[:server]) unless resource[:options].nil? command.push('--keyserver-options', resource[:options]) end command.push('--recv-keys', resource[:id]) end def exists? update_expired_key # report expired keys as non-existing when refresh => true @property_hash[:ensure] == :present && !(resource[:refresh] && @property_hash[:expired]) end def create command = [] if resource[:source].nil? && resource[:content].nil? # Breaking up the command like this is needed because it blows up # if --recv-keys isn't the last argument. command.push('adv', '--no-tty', '--keyserver', resource[:server]) unless resource[:options].nil? command.push('--keyserver-options', resource[:options]) end command.push('--recv-keys', resource[:id]) elsif resource[:content] key_file = tempfile(resource[:content]) command.push('add', key_file.path) elsif resource[:source] key_file = source_to_file(resource[:source]) command.push('add', key_file.path) # In case we really screwed up, better safe than sorry. else raise(_('an unexpected condition occurred while trying to add the key: %{_resource}') % { _resource: resource[:id] }) end apt_key(command) @property_hash[:ensure] = :present end def destroy loop do apt_key('del', resource.provider.short) r = execute(["#{command(:apt_key)} list | grep '/#{resource.provider.short}\s'"], failonfail: false) break unless r.exitstatus.zero? end @property_hash.clear end def read_only(_value) raise(_('This is a read-only property.')) end mk_resource_methods # Alias the setters of read-only properties # to the read_only function. alias_method :created=, :read_only alias_method :expired=, :read_only alias_method :expiry=, :read_only alias_method :size=, :read_only alias_method :type=, :read_only end diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 7c275ef..51e3039 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -1,151 +1,153 @@ +# frozen_string_literal: true + require 'pathname' require 'puppet/parameter/boolean' Puppet::Type.newtype(:apt_key) do @doc = <<-MANIFEST @summary This type provides Puppet with the capabilities to manage GPG keys needed by apt to perform package validation. Apt has it's own GPG keyring that can be manipulated through the `apt-key` command. @example Basic usage apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F': source => 'http://apt.puppetlabs.com/pubkey.gpg' } **Autorequires** If Puppet is given the location of a key file which looks like an absolute path this type will autorequire that file. @api private MANIFEST ensurable validate do if self[:refresh] == true && self[:ensure] == :absent raise(_('ensure => absent and refresh => true are mutually exclusive')) end if self[:content] && self[:source] raise(_('The properties content and source are mutually exclusive.')) end if self[:id].length < 40 warning(_('The id should be a full fingerprint (40 characters), see README.')) end end newparam(:id, namevar: true) do desc 'The ID of the key you want to manage.' # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's # and may start with the optional 0x, or they can be 40-digit key fingerprints newvalues(%r{\A(0x)?[0-9a-fA-F]{8}\Z}, %r{\A(0x)?[0-9a-fA-F]{16}\Z}, %r{\A(0x)?[0-9a-fA-F]{40}\Z}) munge do |value| id = if value.start_with?('0x') value.partition('0x').last.upcase else value.upcase end id end end newparam(:content) do desc 'The content of, or string representing, a GPG key.' end newparam(:source) do desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://' newvalues(%r{\Ahttps?://}, %r{\Aftp://}, %r{\A/\w+}) end autorequire(:file) do if self[:source] && Pathname.new(self[:source]).absolute? self[:source] end end newparam(:server) do desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' newvalues(%r{\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$}) end newparam(:options) do desc 'Additional options to pass to apt-key\'s --keyserver-options.' end newparam(:refresh, boolean: true, parent: Puppet::Parameter::Boolean) do desc 'When true, recreate an existing expired key' defaultto false end newparam(:weak_ssl, boolean: true, parent: Puppet::Parameter::Boolean) do desc 'When true and source uses https, accepts download of keys without SSL verfication' defaultto false end newproperty(:fingerprint) do desc <<-MANIFEST The 40-digit hexadecimal fingerprint of the specified GPG key. This property is read-only. MANIFEST end newproperty(:long) do desc <<-MANIFEST The 16-digit hexadecimal id of the specified GPG key. This property is read-only. MANIFEST end newproperty(:short) do desc <<-MANIFEST The 8-digit hexadecimal id of the specified GPG key. This property is read-only. MANIFEST end newproperty(:expired) do desc <<-MANIFEST Indicates if the key has expired. This property is read-only. MANIFEST end newproperty(:expiry) do desc <<-MANIFEST The date the key will expire, or nil if it has no expiry date. This property is read-only. MANIFEST end newproperty(:size) do desc <<-MANIFEST The key size, usually a multiple of 1024. This property is read-only. MANIFEST end newproperty(:type) do desc <<-MANIFEST The key type, one of: rsa, dsa, ecc, ecdsa This property is read-only. MANIFEST end newproperty(:created) do desc <<-MANIFEST Date the key was created. This property is read-only. MANIFEST end end diff --git a/metadata.json b/metadata.json index f1f1744..7afcee5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,48 +1,48 @@ { "name": "puppetlabs-apt", "version": "7.7.0", "author": "puppetlabs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "project_page": "https://github.com/puppetlabs/puppetlabs-apt", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.16.0 < 7.0.0" }, { "name": "puppetlabs/translate", "version_requirement": ">= 1.0.0 < 3.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "8", "9", "10" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04", "18.04", "20.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 5.5.10 < 8.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g5afcd3d", + "template-ref": "heads/main-0-g4543421", "pdk-version": "1.18.1" } diff --git a/spec/acceptance/01_apt_class_spec.rb b/spec/acceptance/01_apt_class_spec.rb index 53d75f6..1b50c7b 100644 --- a/spec/acceptance/01_apt_class_spec.rb +++ b/spec/acceptance/01_apt_class_spec.rb @@ -1,16 +1,18 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'apt class' do context 'with default parameters' do # Using puppet_apply as a helper it 'works with no errors' do pp = <<-MANIFEST class { 'apt': } MANIFEST # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end end end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 0c4539d..0db1d32 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -1,922 +1,924 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' -PUPPETLABS_GPG_KEY_SHORT_ID = 'EF8D349F'.freeze -PUPPETLABS_GPG_KEY_LONG_ID = '7F438280EF8D349F'.freeze -PUPPETLABS_GPG_KEY_FINGERPRINT = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze -PUPPETLABS_APT_URL = 'apt.puppetlabs.com'.freeze -PUPPETLABS_GPG_KEY_FILE = 'DEB-GPG-KEY-puppet'.freeze -CENTOS_GPG_KEY_SHORT_ID = 'C105B9DE'.freeze -CENTOS_GPG_KEY_LONG_ID = '0946FCA2C105B9DE'.freeze -CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE'.freeze -CENTOS_REPO_URL = 'ftp.cvut.cz/centos'.freeze -CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6'.freeze -PUPPETLABS_EXP_KEY_LONG_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'.freeze -PUPPETLABS_EXP_KEY_DATES = 'pub:e:4096:1:1054B7A24BD6EC30:2010-07-10:2017-01-05::-:Puppet Labs Release Key'.freeze -SHOULD_NEVER_EXIST_ID = 'EF8D349F'.freeze -KEY_CHECK_COMMAND = 'apt-key adv --no-tty --list-keys --with-colons --fingerprint | grep '.freeze -PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}".freeze -CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}".freeze -PUPPETLABS_EXP_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} '#{PUPPETLABS_EXP_KEY_DATES}'".freeze -DEBIAN_PUPPETLABS_EXP_CHECK_COMMAND = 'apt-key list | grep -F -A 1 \'pub rsa4096 2010-07-10 [SC] [expired: 2017-01-05]\' | grep \'47B3 20EB 4C7C 375A A9DA E1A0 1054 B7A2 4BD6 EC30\''.freeze +PUPPETLABS_GPG_KEY_SHORT_ID = 'EF8D349F' +PUPPETLABS_GPG_KEY_LONG_ID = '7F438280EF8D349F' +PUPPETLABS_GPG_KEY_FINGERPRINT = '6F6B15509CF8E59E6E469F327F438280EF8D349F' +PUPPETLABS_APT_URL = 'apt.puppetlabs.com' +PUPPETLABS_GPG_KEY_FILE = 'DEB-GPG-KEY-puppet' +CENTOS_GPG_KEY_SHORT_ID = 'C105B9DE' +CENTOS_GPG_KEY_LONG_ID = '0946FCA2C105B9DE' +CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE' +CENTOS_REPO_URL = 'ftp.cvut.cz/centos' +CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' +PUPPETLABS_EXP_KEY_LONG_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' +PUPPETLABS_EXP_KEY_DATES = 'pub:e:4096:1:1054B7A24BD6EC30:2010-07-10:2017-01-05::-:Puppet Labs Release Key' +SHOULD_NEVER_EXIST_ID = 'EF8D349F' +KEY_CHECK_COMMAND = 'apt-key adv --no-tty --list-keys --with-colons --fingerprint | grep ' +PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}" +CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}" +PUPPETLABS_EXP_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} '#{PUPPETLABS_EXP_KEY_DATES}'" +DEBIAN_PUPPETLABS_EXP_CHECK_COMMAND = 'apt-key list | grep -F -A 1 \'pub rsa4096 2010-07-10 [SC] [expired: 2017-01-05]\' | grep \'47B3 20EB 4C7C 375A A9DA E1A0 1054 B7A2 4BD6 EC30\'' def install_key(key) retry_on_error_matching do run_shell("apt-key adv --no-tty --keyserver pgp.mit.edu --recv-keys #{key}") end end def apply_manifest_twice(manifest_pp) retry_on_error_matching do apply_manifest(manifest_pp, catch_failures: true) end retry_on_error_matching do apply_manifest(manifest_pp, catch_changes: true) end end refresh_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': id => '#{PUPPETLABS_EXP_KEY_LONG_ID}', ensure => 'present', content => '-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKe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P5hA//UTZfD340ukip6jPlMzxwSD/QapwtO7D4 gsGTsXezDkO97D21d1pNaNT0RrXAMagwk1ElDxmn/YHUDfMovZa2bKagjWmV38xk Ws+Prh1P44vUDG30CAU6KZ+mTGLUbolfOvDffCTm9Mn1i2kxFaJxbVhWR6zR28KZ R28s1IBsrqeTCksYfdKdkuw1/j850hW8MM3hPBJ/48VLx5QEFfnlXwt1fp+LygAv rIyJw7vJtsa9QjCIkQk2tcv77rhkiZ6ADthgVIx5j3yDWSm4nLqFpwbQTKrNRrCb 5XbL/oIMeHJuFICb2HckDS1KuKXHmqvDuLoRr0/wFEZMps5XQevomUa7JkMeS5j9 AubCG4g1zKEtPPaGDsfDKBljCHBKwUysQj5oGU5w8VvlOPnS62DBfsgU2y5ipmmI TYkjSOL6LXwO6xG5/sxA8cyoJSmbN286imcY6AHloTiiu6/N7Us+CNrhw/V7HAun 56etWBn3bZWCRGGAPF3qJr4y2sUMY0E3Ha7OPEHIKfBb4MiJnpXntWT28nQfF3dl TFTthAzwcnZchx2es4yrfDXn33Y4eisqxWCbTluErXUogUEKH1KohSatYMtxencv 7bUlzIr22zSUCYyVf9cyg50kBy+0J7seEpqG5K5R8z9s/63BT5Oghmi6bB2s5iK5 fBt3Tu1IYpw= =cXcR -----END PGP PUBLIC KEY BLOCK-----' } MANIFEST gpg_key_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', content => "-----BEGIN PGP PUBLIC KEY BLOCK----- mQINBFe2Iz4BEADqbv/nWmR26bsivTDOLqrfBEvRu9kSfDMzYh9Bmik1A8Z036Eg h5+TZD8Rrd5TErLQ6eZFmQXk9yKFoa9/C4aBjmsL/u0yeMmVb7/66i+x3eAYGLzV FyunArjtefZyxq0B2mdRHE8kwl5XGl8015T5RGHCTEhpX14O9yigI7gtliRoZcl3 hfXtedcvweOf9VrV+t5LF4PrZejom8VcB5CE2pdQ+23KZD48+Cx/sHSLHDtahOTQ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IbEKSISrcO6Nvjt9PwLCjR/dUvco0f0YFTPv+kamn +Bwp2Zt6d3MenXC6mLXPHR4OqFjzCpUT8kFwycvGPsuqZQ/CO0qzLDmAGTY+4ly3 9aQEsQyFhV3P+6SWnaC2TldWpfG/2pCSaSa8dbYbRe3SUNKXwT8kw3WoQYNofF6n or8oFVA+UIVlvHc5h7L3tfFylRy5CwtR5rBQtoBicRVxEQc7ARNmB1XWuPntMQl/ N1Fcfc+KSILFblAR6eVv+6BhMvRqzxqe81AEAP+oKVVwJ7H+wTQun2UKAgZATDWP /LQsYinmLADpraDPqxT2WJe8kjszMDQZCK+jhsVrhZdkiw9EHAM0z7BKz6JERmLu TIEcickkTfzbJWXZgv40Bvl99yPMswnR1lQHD7TKxyHYrI7dzJQri4mbORg4lOnZ 3Tyodv21Ocf4as2No1p6esZW+M46zjZeO8zzExmmENI2+P7/VUt+LWyQFiqRM0iW zGioYMWgVePywFGaTV51/0uF9ymHHC7BDIcLgUWHdg/1B67jR5YQfzPJUqLhnylt 1sjDRQIlf+3U+ddvre2YxX/rYUI2gBT32QzQrv016KsiZO+N+Iya3B4D68s6xxQS 3xJn =mMjt -----END PGP PUBLIC KEY BLOCK-----", } MANIFEST multiple_keys_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', content => "-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2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GaYQ0jb4/v9VS34tbJAWKpEzSJbMaKhgxaBV4/LAUZpNXnX/S4X3KYcc LsEMhwuBRYd2D/UHruNHlhB/M8lSouGfKW3WyMNFAiV/7dT512+t7ZjFf+thQjaA FPfZDNCu/TXoqyJk7434jJrcHgPryzrHFBLfEmc= =TREp -----END PGP PUBLIC KEY BLOCK----- ", } MANIFEST bogus_key_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', content => 'For posterity: such content, much bogus, wow', } MANIFEST hkp_pool_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', server => 'hkp://keyserver.ubuntu.com:80', } MANIFEST -hkps_protocol_supported = os[:family] =~ %r{Ubuntu} && \ - os[:family][:release][:full] =~ %r{^18\.04} +hkps_protocol_supported = host_inventory['facter']['os']['family'] =~ %r{Ubuntu}i && \ + host_inventory['facter']['os']['release']['major'] =~ %r{^18\.04} if hkps_protocol_supported hkps_ubuntu_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'hkps://keyserver.ubuntu.com', } MANIFEST end nonexistant_key_server_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'nonexistant.key.server', } MANIFEST dot_server_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => '.pgp.key.server', } MANIFEST http_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } MANIFEST http_works_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } MANIFEST four_oh_four_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } MANIFEST socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } MANIFEST ftp_works_pp = <<-MANIFEST apt_key { 'CentOS 6': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } MANIFEST ftp_550_pp = <<-MANIFEST apt_key { 'CentOS 6': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } MANIFEST ftp_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } MANIFEST https_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } MANIFEST https_with_weak_ssl_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', weak_ssl => true, } MANIFEST https_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } MANIFEST https_404_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } MANIFEST https_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } MANIFEST path_exists_pp = <<-MANIFEST apt_key { 'puppetlabs': id => 'EF8D349F', ensure => 'present', source => '/tmp/puppetlabs-pubkey.gpg', } MANIFEST path_does_not_exist_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/totally_bogus.file', } MANIFEST path_bogus_content_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/fake-key.gpg', } MANIFEST debug_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', options => 'debug', } MANIFEST fingerprint_match_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } MANIFEST fingerprint_does_not_match_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '6F6B15509CF8E59E6E469F327F438280EF8D9999', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } MANIFEST refresh_true_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': id => '#{PUPPETLABS_EXP_KEY_LONG_ID}', ensure => 'present', refresh => true, } MANIFEST refresh_false_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': id => '#{PUPPETLABS_EXP_KEY_LONG_ID}', ensure => 'present', refresh => false, } MANIFEST refresh_del_key_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': ensure => 'absent', } MANIFEST refresh_check_for_dirmngr_pp = <<-MANIFEST package { 'dirmngr': ensure => 'present', } MANIFEST describe 'apt_key' do before(:each) do # Delete twice to make sure everything is cleaned # up after the short key collision run_shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", expect_failures: true) run_shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", expect_failures: true) end describe 'ensure =>' do ensure_present_pp = <<-MANIFEST apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', } MANIFEST ensure_absent_pp = <<-MANIFEST apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } MANIFEST it 'add an apt_key resource' do apply_manifest_twice(ensure_present_pp) end it 'remove the apt_key resource' do apply_manifest_twice(ensure_absent_pp) end end describe 'content =>' do context 'with puppetlabs gpg key' do it 'works' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching do apply_manifest(gpg_key_pp, catch_failures: true) end apply_manifest(gpg_key_pp, catch_changes: true) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'with multiple keys' do it 'runs without errors' do apply_manifest_twice(multiple_keys_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'with bogus key' do it 'fails' do apply_manifest(bogus_key_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{no valid OpenPGP data found}) end end end end describe 'server =>' do context 'with hkp://pgp.mit.edu:80' do it 'works' do retry_on_error_matching do apply_manifest(hkp_pool_pp, catch_failures: true) end apply_manifest(hkp_pool_pp, catch_changes: true) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end end if hkps_protocol_supported context 'with hkps://keyserver.ubuntu.com' do it 'works' do retry_on_error_matching do apply_manifest(hkps_ubuntu_pp, catch_failures: true) end apply_manifest(hkps_ubuntu_pp, catch_changes: true) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end end end context 'with nonexistant.key.server' do it 'fails' do apply_manifest(nonexistant_key_server_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{(Host not found|Couldn't resolve host|No name)}) end end end context 'with key server start with dot' do it 'fails' do apply_manifest(dot_server_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{Invalid value ".pgp.key.server"}) end end end end describe 'source =>' do context 'with http://' do it 'works' do apply_manifest_twice(http_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'works with userinfo' do apply_manifest_twice(http_works_userinfo_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails with a 404' do apply_manifest(four_oh_four_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{404 Not Found}) end end it 'fails with a socket error' do apply_manifest(socket_error_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{could not resolve}) end end end # disabled when running in travis, security issues prevent FTP context 'with ftp://', unless: (ENV['TRAVIS'] == 'true') do before(:each) do run_shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", expect_failures: true) end it 'works' do apply_manifest_twice(ftp_works_pp) run_shell(CENTOS_KEY_CHECK_COMMAND) end it 'fails with a 550' do apply_manifest(ftp_550_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{550 Failed to open}) end end it 'fails with a socket error' do apply_manifest(ftp_socket_error_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{could not resolve}) end end end context 'with https://' do it 'works' do apply_manifest_twice(https_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'works with weak ssl' do apply_manifest_twice(https_with_weak_ssl_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'works with userinfo' do apply_manifest_twice(https_userinfo_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails with a 404' do apply_manifest(https_404_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{404 Not Found}) end end it 'fails with a socket error' do apply_manifest(https_socket_error_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{could not resolve}) end end end context 'with /path/that/exists' do before(:each) do run_shell("curl -o /tmp/puppetlabs-pubkey.gpg \ http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}") end after(:each) do run_shell('rm /tmp/puppetlabs-pubkey.gpg') end it 'works' do apply_manifest_twice(path_exists_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'with /path/that/does/not/exist' do it 'fails' do apply_manifest(path_does_not_exist_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{does not exist}) end end end context 'with /path/that/exists/with/bogus/content' do before(:each) do run_shell('echo "here be dragons" > /tmp/fake-key.gpg') end after(:each) do run_shell('rm /tmp/fake-key.gpg') end it 'fails' do apply_manifest(path_bogus_content_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{no valid OpenPGP data found}) end end end end describe 'options =>' do context 'with debug' do it 'works' do apply_manifest_twice(debug_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end end end describe 'fingerprint validation against source/content' do context 'with fingerprint in id matches fingerprint from remote key' do it 'works' do apply_manifest_twice(fingerprint_match_pp) end end context 'with fingerprint in id does NOT match fingerprint from remote key' do it 'works' do apply_manifest(fingerprint_does_not_match_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{don't match}) end end end end describe 'refresh' do if ['8', '14.04', '16.04'].include?(host_inventory['facter']['os']['release']['major']) # older OSes use puppetlabs_exp_check_command let(:puppetlabs_exp_check_command) { PUPPETLABS_EXP_CHECK_COMMAND } else # Set Debian Stetch and newer OSes puppetlabs_exp_check_command let(:puppetlabs_exp_check_command) { DEBIAN_PUPPETLABS_EXP_CHECK_COMMAND } # Ensure dirmngr package is installed apply_manifest(refresh_check_for_dirmngr_pp, acceptable_exit_codes: [0, 2]) end before(:each) do # Delete the Puppet Labs Release Key and install an expired version of the key apply_manifest(refresh_del_key_pp) apply_manifest(refresh_pp, catch_failures: true) end context 'when refresh => true' do it 'updates an expired key' do apply_manifest(refresh_true_pp) # Check key has been updated to new version run_shell(puppetlabs_exp_check_command.to_s) end end context 'when refresh => false' do it 'does not replace an expired key' do apply_manifest(refresh_false_pp) # Expired key is present and has not been updated by the new version run_shell(puppetlabs_exp_check_command.to_s, expect_failures: true) end end end end diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index f6f3d1d..6dc4de9 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -1,57 +1,59 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' everything_everything_pp = <<-MANIFEST $sources = { 'puppetlabs' => { 'ensure' => present, 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pool.sks-keyservers.net', }, }, } class { 'apt': update => { 'frequency' => 'always', 'timeout' => 400, 'tries' => 3, }, purge => { 'sources.list' => true, 'sources.list.d' => true, 'preferences' => true, 'preferences.d' => true, 'apt.conf.d' => true, }, sources => $sources, } MANIFEST describe 'apt class' do context 'with reset' do it 'fixes the sources.list' do run_shell('cp /etc/apt/sources.list /tmp') end end context 'with all the things' do it 'works with no errors' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching do apply_manifest(everything_everything_pp, catch_failures: true) end end it 'stills work' do run_shell('apt-get update') run_shell('apt-get -y --force-yes upgrade') end end context 'with reset' do it 'fixes the sources.list' do run_shell('cp /tmp/sources.list /etc/apt') end end end diff --git a/spec/acceptance/init_task_spec.rb b/spec/acceptance/init_task_spec.rb index f35d2fc..02b3f34 100644 --- a/spec/acceptance/init_task_spec.rb +++ b/spec/acceptance/init_task_spec.rb @@ -1,29 +1,31 @@ +# frozen_string_literal: true + # run a test task require 'spec_helper_acceptance' describe 'apt tasks' do describe 'update' do it 'updates package lists' do result = run_bolt_task('apt', 'action' => 'update') expect(result.stdout).to contain(%r{Reading package lists}) end end describe 'upgrade' do it 'upgrades packages' do result = run_bolt_task('apt', 'action' => 'upgrade') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end describe 'dist-upgrade' do it 'dist-upgrades packages' do result = run_bolt_task('apt', 'action' => 'dist-upgrade') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end describe 'autoremove' do it 'autoremoves obsolete packages' do result = run_bolt_task('apt', 'action' => 'autoremove') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end end diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 765269d..57e8a06 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -1,246 +1,248 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::backports', type: :class do let(:pre_condition) { "class{ '::apt': }" } describe 'debian/ubuntu tests' do context 'with defaults on deb' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end it { is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian', repos: 'main contrib non-free', release: 'jessie-backports', pin: { 'priority' => 200, 'release' => 'jessie-backports' }) } end context 'with defaults on ubuntu' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistrelease: '16.04', } end it { is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', repos: 'main universe multiverse restricted', release: 'xenial-backports', pin: { 'priority' => 200, 'release' => 'xenial-backports' }) } end context 'with everything set' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistrelease: '16.04', } end let(:params) do { location: 'http://archive.ubuntu.com/ubuntu-test', release: 'vivid', repos: 'main', key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', pin: '90', } end it { is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test', key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', repos: 'main', release: 'vivid', pin: { 'priority' => 90, 'release' => 'vivid' }) } end context 'when set things with hashes' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistrelease: '16.04', } end let(:params) do { key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', }, pin: { 'priority' => '90', }, } end it { is_expected.to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, pin: { 'priority' => '90' }) } end end describe 'mint tests' do let(:facts) do { os: { family: 'Debian', name: 'Linuxmint', release: { major: '17', full: '17' } }, lsbdistid: 'linuxmint', osfamily: 'Debian', lsbdistcodename: 'qiana', } end context 'with all the needed things set' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', release: 'trusty-backports', repos: 'main universe multiverse restricted', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it { is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', repos: 'main universe multiverse restricted', release: 'trusty-backports', pin: { 'priority' => 200, 'release' => 'trusty-backports' }) } end context 'with missing location' do let(:params) do { release: 'trusty-backports', repos: 'main universe multiverse restricted', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end context 'with missing release' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', repos: 'main universe multiverse restricted', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end context 'with missing repos' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', release: 'trusty-backports', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end context 'with missing key' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', release: 'trusty-backports', repos: 'main universe multiverse restricted', } end it do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end end describe 'validation' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistrelease: '16.04', } end context 'with invalid location' do let(:params) do { location: true, } end it do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end context 'with invalid release' do let(:params) do { release: true, } end it do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end context 'with invalid repos' do let(:params) do { repos: true, } end it do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end context 'with invalid key' do let(:params) do { key: true, } end it do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end context 'with invalid pin' do let(:params) do { pin: true, } end it do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end end end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 03ca86f..f7ab7bc 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,608 +1,610 @@ +# frozen_string_literal: true + require 'spec_helper' sources_list = { ensure: 'file', path: '/etc/apt/sources.list', owner: 'root', group: 'root', notify: 'Class[Apt::Update]' } sources_list_d = { ensure: 'directory', path: '/etc/apt/sources.list.d', owner: 'root', group: 'root', purge: false, recurse: false, notify: 'Class[Apt::Update]' } preferences = { ensure: 'file', path: '/etc/apt/preferences', owner: 'root', group: 'root', notify: 'Class[Apt::Update]' } preferences_d = { ensure: 'directory', path: '/etc/apt/preferences.d', owner: 'root', group: 'root', purge: false, recurse: false, notify: 'Class[Apt::Update]' } apt_conf_d = { ensure: 'directory', path: '/etc/apt/apt.conf.d', owner: 'root', group: 'root', purge: false, recurse: false, notify: 'Class[Apt::Update]' } describe 'apt' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end context 'with defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list) } it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d) } it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences) } it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d) } it { is_expected.to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d) } it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') } it 'lays down /etc/apt/apt.conf.d/15update-stamp' do is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root', owner: 'root').with_content( %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};}, ) end it { is_expected.to contain_exec('apt_update').with(refreshonly: 'true') } it { is_expected.not_to contain_apt__setting('conf-proxy') } end describe 'proxy=' do context 'when host=localhost' do let(:params) { { proxy: { 'host' => 'localhost' } } } it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).without_content( %r{Acquire::https::proxy}, ) } end context 'when host=localhost and port=8180' do let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } } it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8180/";}, ).without_content( %r{Acquire::https::proxy}, ) } end context 'when host=localhost and https=true' do let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } } it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).with_content( %r{Acquire::https::proxy "https://localhost:8080/";}, ) } end context 'when host=localhost and direct=true' do let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } } it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).with_content( %r{Acquire::https::proxy "DIRECT";}, ) } end context 'when host=localhost and https=true and direct=true' do let(:params) { { proxy: { 'host' => 'localhost', 'https' => true, 'direct' => true } } } it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).with_content( %r{Acquire::https::proxy "https://localhost:8080/";}, ) } it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).without_content( %r{Acquire::https::proxy "DIRECT";}, ) } end context 'when ensure=absent' do let(:params) { { proxy: { 'ensure' => 'absent' } } } it { is_expected.to contain_apt__setting('conf-proxy').with(ensure: 'absent', priority: '01') } end end context 'with lots of non-defaults' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => false, 'sources.list.d' => false, 'preferences' => false, 'preferences.d' => false, 'apt.conf.d' => false }, } end it { is_expected.to contain_file('sources.list').with(content: nil) } it { is_expected.to contain_file('sources.list.d').with(purge: false, recurse: false) } it { is_expected.to contain_file('preferences').with(ensure: 'file') } it { is_expected.to contain_file('preferences.d').with(purge: false, recurse: false) } it { is_expected.to contain_file('apt.conf.d').with(purge: false, recurse: false) } it { is_expected.to contain_exec('apt_update').with(refreshonly: false, timeout: 1, tries: 3) } end context 'with lots of non-defaults' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => true, 'sources.list.d' => true, 'preferences' => true, 'preferences.d' => true, 'apt.conf.d' => true }, } end it { is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n") } it { is_expected.to contain_file('sources.list.d').with(purge: true, recurse: true) } it { is_expected.to contain_file('preferences').with(ensure: 'absent') } it { is_expected.to contain_file('preferences.d').with(purge: true, recurse: true) } it { is_expected.to contain_file('apt.conf.d').with(purge: true, recurse: true) } it { is_expected.to contain_exec('apt_update').with(refreshonly: false, timeout: 1, tries: 3) } end context 'with defaults for sources_list_force' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => true }, sources_list_force: false, } end it { is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n") } end context 'with non defaults for sources_list_force' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => true }, sources_list_force: true, } end it { is_expected.to contain_file('sources.list').with(ensure: 'absent') } end context 'with entries for /etc/apt/auth.conf' do facts_hash = { 'Ubuntu 14.04' => { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, osfamily: 'Debian', lsbdistcodename: 'trusty', lsbdistid: 'Ubuntu', lsbdistrelease: '14.04', }, 'Ubuntu 16.04' => { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', lsbdistrelease: '16.04', }, 'Ubuntu 18.04' => { os: { family: 'Debian', name: 'Ubuntu', release: { major: '18', full: '18.04' } }, osfamily: 'Debian', lsbdistcodename: 'bionic', lsbdistid: 'Ubuntu', lsbdistrelease: '18.04', }, 'Debian 7.0' => { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'wheezy', }, 'Debian 8.0' => { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', }, 'Debian 9.0' => { os: { family: 'Debian', name: 'Debian', release: { major: '9', full: '9.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'stretch', }, 'Debian 10.0' => { os: { family: 'Debian', name: 'Debian', release: { major: '10', full: '10.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'buster', }, } facts_hash.each do |os, facts| context "on #{os}" do let(:facts) do facts end let(:params) do { auth_conf_entries: [ { machine: 'deb.example.net', login: 'foologin', password: 'secret', }, { machine: 'apt.example.com', login: 'aptlogin', password: 'supersecret', }, ], } end context 'with manage_auth_conf => true' do let(:params) do super().merge(manage_auth_conf: true) end # Going forward starting with Ubuntu 16.04 and Debian 9.0 # /etc/apt/auth.conf is owned by _apt. In previous versions it is # root. auth_conf_owner = case os when 'Ubuntu 14.04', 'Debian 7.0', 'Debian 8.0' 'root' else '_apt' end auth_conf_content = "// This file is managed by Puppet. DO NOT EDIT. machine deb.example.net login foologin password secret machine apt.example.com login aptlogin password supersecret " it { is_expected.to contain_file('/etc/apt/auth.conf').with(ensure: 'present', owner: auth_conf_owner, group: 'root', mode: '0600', notify: 'Class[Apt::Update]', content: sensitive(auth_conf_content)) } end context 'with manage_auth_conf => false' do let(:params) do super().merge(manage_auth_conf: false) end it { is_expected.not_to contain_file('/etc/apt/auth.conf') } end end context 'with improperly specified entries for /etc/apt/auth.conf' do let(:params) do { auth_conf_entries: [ { machinn: 'deb.example.net', username: 'foologin', password: 'secret', }, { machine: 'apt.example.com', login: 'aptlogin', password: 'supersecret', }, ], } end it { is_expected.to raise_error(Puppet::Error) } end end end context 'with sources defined on valid osfamily' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', lsbdistrelease: '16.04', } end let(:params) do { sources: { 'debian_unstable' => { 'location' => 'http://debian.mirror.iweb.ca/debian/', 'release' => 'unstable', 'repos' => 'main contrib non-free', 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, 'pin' => '-10', 'include' => { 'src' => true }, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, }, } } end it { is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present') } it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) } it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) } it { is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present') } it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com xenial main$}) } end context 'with confs defined on valid osfamily' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', } end let(:params) do { confs: { 'foo' => { 'content' => 'foo', }, 'bar' => { 'content' => 'bar', }, } } end it { is_expected.to contain_apt__conf('foo').with(content: 'foo') } it { is_expected.to contain_apt__conf('bar').with(content: 'bar') } end context 'with keys defined on valid osfamily' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', } end let(:params) do { keys: { '55BE302B' => { 'server' => 'subkeys.pgp.net', }, 'EF8D349F' => { 'server' => 'pgp.mit.edu', }, } } end it { is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net') } it { is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu') } end context 'with ppas defined on valid osfamily' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', lsbdistrelease: '16.04', } end let(:params) do { ppas: { 'ppa:drizzle-developers/ppa' => {}, 'ppa:nginx/stable' => {}, } } end it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa') } it { is_expected.to contain_apt__ppa('ppa:nginx/stable') } end context 'with settings defined on valid osfamily' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', } end let(:params) do { settings: { 'conf-banana' => { 'content' => 'banana' }, 'pref-banana' => { 'content' => 'banana' }, } } end it { is_expected.to contain_apt__setting('conf-banana') } it { is_expected.to contain_apt__setting('pref-banana') } end context 'with pins defined on valid osfamily' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', } end let(:params) do { pins: { 'stable' => { 'priority' => 600, 'order' => 50 }, 'testing' => { 'priority' => 700, 'order' => 100 }, } } end it { is_expected.to contain_apt__pin('stable') } it { is_expected.to contain_apt__pin('testing') } end describe 'failing tests' do context "with purge['sources.list']=>'banana'" do let(:params) { { purge: { 'sources.list' => 'banana' } } } it do is_expected.to raise_error(Puppet::Error) end end context "with purge['sources.list.d']=>'banana'" do let(:params) { { purge: { 'sources.list.d' => 'banana' } } } it do is_expected.to raise_error(Puppet::Error) end end context "with purge['preferences']=>'banana'" do let(:params) { { purge: { 'preferences' => 'banana' } } } it do is_expected.to raise_error(Puppet::Error) end end context "with purge['preferences.d']=>'banana'" do let(:params) { { purge: { 'preferences.d' => 'banana' } } } it do is_expected.to raise_error(Puppet::Error) end end context "with purge['apt.conf.d']=>'banana'" do let(:params) { { purge: { 'apt.conf.d' => 'banana' } } } it do is_expected.to raise_error(Puppet::Error) end end end end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index d2683a2..463566b 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -1,145 +1,147 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::update', type: :class do context "when apt::update['frequency']='always'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', apt_update_last_success: factval, lsbdistcodename: 'jessie', } end let(:pre_condition) do "class{'::apt': update => {'frequency' => 'always' },}" end it 'triggers an apt-get update run' do # set the apt_update exec's refreshonly attribute to false is_expected.to contain_exec('apt_update').with('refreshonly' => false) end end end context 'when $::apt_update_last_success is nil' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } it 'triggers an apt-get update run' do # set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with('refreshonly' => false) end end end context "when apt::update['frequency']='reluctantly'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', apt_update_last_success: factval, lsbdistcodename: 'jessie', } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'does not trigger an apt-get update run' do # don't change the apt_update exec's refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with('refreshonly' => true) end end end context 'when $::apt_update_last_success is nil' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'does not trigger an apt-get update run' do # don't change the apt_update exec's refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with('refreshonly' => true) end end end ['daily', 'weekly'].each do |update_frequency| context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', apt_update_last_success: factval, lsbdistcodename: 'jessie', } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'triggers an apt-get update run' do # set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with('refreshonly' => false) end end end context 'when the $::apt_update_last_success fact has a recent value' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', apt_update_last_success: Time.now.to_i, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'does not trigger an apt-get update run' do # don't change the apt_update exec\'s refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with('refreshonly' => true) end end context 'when $::apt_update_last_success is nil' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', apt_update_last_success: nil, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'triggers an apt-get update run' do # set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with('refreshonly' => false) end end end end end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 5decab5..3158c16 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -1,87 +1,89 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::conf', type: :define do let :pre_condition do 'class { "apt": }' end let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end let :title do 'norecommends' end describe 'when creating an apt preference' do let :default_params do { priority: '00', content: "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", } end let :params do default_params end let :filename do '/etc/apt/apt.conf.d/00norecommends' end it { is_expected.to contain_file(filename).with('ensure' => 'present', 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, 'owner' => 'root', 'group' => 'root') } context 'with notify_update = true (default)' do let :params do default_params end it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(true) } end context 'with notify_update = false' do let :params do default_params.merge(notify_update: false) end it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(false) } end end describe 'when creating a preference without content' do let :params do { priority: '00', } end it 'fails' do is_expected.to raise_error(%r{pass in content}) end end describe 'when removing an apt preference' do let :params do { ensure: 'absent', priority: '00', } end let :filename do '/etc/apt/apt.conf.d/00norecommends' end it { is_expected.to contain_file(filename).with('ensure' => 'absent', 'owner' => 'root', 'group' => 'root') } end end diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 47b03d4..fc401ba 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -1,359 +1,361 @@ +# frozen_string_literal: true + require 'spec_helper' def contains_apt_key_example(title) { id: title, ensure: 'present', source: 'http://apt.puppetlabs.com/pubkey.gpg', server: 'pgp.mit.edu', content: params[:content], options: 'debug' } end def apt_key_example(title) { id: title, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', content: nil, keyserver_options: nil } end describe 'apt::key', type: :define do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze + GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', } end let :title do GPG_KEY_ID end let :pre_condition do 'include apt' end describe 'normal operation' do describe 'default options' do it { is_expected.to contain_apt_key(title).with(id: title, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', content: nil) } it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end end describe 'title and key =>' do let :title do 'puppetlabs' end let :params do { id: GPG_KEY_ID, } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: GPG_KEY_ID, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', content: nil) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") end end describe 'ensure => absent' do let :params do { ensure: 'absent', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, ensure: 'absent', source: nil, server: 'keyserver.ubuntu.com', content: nil) end it 'contains the apt_key absent anchor' do is_expected.to contain_anchor("apt_key #{title} absent") end end describe 'set a bunch of things!' do let :params do { content: 'GPG key content', source: 'http://apt.puppetlabs.com/pubkey.gpg', server: 'pgp.mit.edu', options: 'debug', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(contains_apt_key_example(title)) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end end context 'when domain has dash' do let(:params) do { server: 'p-gp.m-it.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, server: 'p-gp.m-it.edu') end end context 'with url' do let :params do { server: 'hkp://pgp.mit.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, server: 'hkp://pgp.mit.edu') end end context 'with url and port number' do let :params do { server: 'hkp://pgp.mit.edu:80', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, server: 'hkp://pgp.mit.edu:80') end end end describe 'validation' do context 'when domain begins with a dash' do let(:params) do { server: '-pgp.mit.edu', } end it 'fails' do is_expected .to raise_error(%r{expects a match}) end end context 'when domain begins with dot' do let(:params) do { server: '.pgp.mit.edu', } end it 'fails' do is_expected .to raise_error(%r{expects a match}) end end context 'when domain ends with dot' do let(:params) do { server: 'pgp.mit.edu.', } end it 'fails' do is_expected .to raise_error(%r{expects a match}) end end context 'when url character limit is exceeded' do let :params do { server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with incorrect port number url' do let :params do { server: 'hkp://pgp.mit.edu:8008080', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with incorrect protocol for url' do let :params do { server: 'abc://pgp.mit.edu:80', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with missing port number url' do let :params do { server: 'hkp://pgp.mit.edu:', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with url ending with a dot' do let :params do { server: 'hkp://pgp.mit.edu.', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with url begin with a dash' do let(:params) do { server: 'hkp://-pgp.mit.edu', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with invalid source' do let :params do { source: 'afp://puppetlabs.com/key.gpg', } end it 'fails' do is_expected.to raise_error(%r{evaluating a Resource}) end end context 'with invalid content' do let :params do { content: [], } end it 'fails' do is_expected.to raise_error(%r{expects a}) end end context 'with invalid server' do let :params do { server: 'two bottles of rum', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with invalid keyserver_options' do let :params do { options: {}, } end it 'fails' do is_expected.to raise_error(%r{expects a}) end end context 'with invalid ensure' do let :params do { ensure: 'foo', } end it 'fails' do is_expected.to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]}) end end describe 'duplication - two apt::key resources for same key, different titles' do let :pre_condition do "#{super()}\napt::key { 'duplicate': id => '#{title}', }" end it 'contains the duplicate apt::key resource' do is_expected.to contain_apt__key('duplicate').with(id: title, ensure: 'present') end it 'contains the original apt::key resource' do is_expected.to contain_apt__key(title).with(id: title, ensure: 'present') end it 'contains the native apt_key' do is_expected.to contain_apt_key('duplicate').with(apt_key_example(title)) end it 'does not contain the original apt_key' do is_expected.not_to contain_apt_key(title) end end describe 'duplication - two apt::key resources, different ensure' do let :pre_condition do "#{super()}\napt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do is_expected.to raise_error(%r{already ensured as absent}) end end end end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index ad715d6..6ad0978 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,408 +1,410 @@ +# frozen_string_literal: true + require 'spec_helper' -GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze +GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' title_key_example = { id: GPG_KEY_ID, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', content: nil, options: nil } def default_apt_key_example(title) { id: title, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', content: nil, options: nil, refresh: false } end def bunch_things_apt_key_example(title, params) { id: title, ensure: 'present', source: 'http://apt.puppetlabs.com/pubkey.gpg', server: 'pgp.mit.edu', content: params[:content], options: 'debug' } end def absent_apt_key(title) { id: title, ensure: 'absent', source: nil, server: 'keyserver.ubuntu.com', content: nil, keyserver: nil } end describe 'apt::key' do let :pre_condition do 'class { "apt": }' end let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end let :title do GPG_KEY_ID end describe 'normal operation' do describe 'default options' do it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(default_apt_key_example(title)) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end end describe 'title and key =>' do let :title do 'puppetlabs' end let :params do { id: GPG_KEY_ID, } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(title_key_example) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") end end describe 'ensure => absent' do let :params do { ensure: 'absent', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(absent_apt_key(title)) end it 'contains the apt_key absent anchor' do is_expected.to contain_anchor("apt_key #{title} absent") end end describe 'ensure => refreshed' do let :params do { ensure: 'refreshed', } end it 'contains the apt_key with refresh => true' do is_expected.to contain_apt_key(title).with( ensure: 'present', refresh: true, ) end end describe 'set a bunch of things!' do let :params do { content: 'GPG key content', source: 'http://apt.puppetlabs.com/pubkey.gpg', server: 'pgp.mit.edu', options: 'debug', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(bunch_things_apt_key_example(title, params)) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end end context 'when domain with dash' do let(:params) do { server: 'p-gp.m-it.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, server: 'p-gp.m-it.edu') end end context 'with url' do let :params do { server: 'hkp://pgp.mit.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, server: 'hkp://pgp.mit.edu') end end context 'when url with port number' do let :params do { server: 'hkp://pgp.mit.edu:80', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(id: title, server: 'hkp://pgp.mit.edu:80') end end end describe 'validation' do context 'when domain begin with dash' do let(:params) do { server: '-pgp.mit.edu', } end it 'fails' do is_expected .to raise_error(%r{expects a match}) end end context 'when domain begin with dot' do let(:params) do { server: '.pgp.mit.edu', } end it 'fails' do is_expected .to raise_error(%r{expects a match}) end end context 'when domain end with dot' do let(:params) do { server: 'pgp.mit.edu.', } end it 'fails' do is_expected .to raise_error(%r{expects a match}) end end context 'when character url exceeded' do let :params do { server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with incorrect port number url' do let :params do { server: 'hkp://pgp.mit.edu:8008080', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with incorrect protocol for url' do let :params do { server: 'abc://pgp.mit.edu:80', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with missing port number url' do let :params do { server: 'hkp://pgp.mit.edu:', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with url ending with a dot' do let :params do { server: 'hkp://pgp.mit.edu.', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'when url begins with a dash' do let(:params) do { server: 'hkp://-pgp.mit.edu', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with invalid source' do let :params do { source: 'afp://puppetlabs.com/key.gpg', } end it 'fails' do is_expected.to raise_error(%r{evaluating a Resource}) end end context 'with invalid content' do let :params do { content: [], } end it 'fails' do is_expected.to raise_error(%r{expects a}) end end context 'with invalid server' do let :params do { server: 'two bottles of rum', } end it 'fails' do is_expected.to raise_error(%r{expects a match}) end end context 'with invalid options' do let :params do { options: {}, } end it 'fails' do is_expected.to raise_error(%r{expects a}) end end context 'with invalid ensure' do ['foo', 'aabsent', 'absenta', 'apresent', 'presenta', 'refresh', 'arefreshed', 'refresheda'].each do |param| let :params do { ensure: param, } end it 'fails' do is_expected.to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got}) end end end describe 'duplication - two apt::key resources for same key, different titles' do let :pre_condition do "class { 'apt': } apt::key { 'duplicate': id => '#{title}', }" end it 'contains two apt::key resource - duplicate' do is_expected.to contain_apt__key('duplicate').with(id: title, ensure: 'present') end it 'contains two apt::key resource - title' do is_expected.to contain_apt__key(title).with(id: title, ensure: 'present') end it 'contains only a single apt_key - duplicate' do is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title)) end it 'contains only a single apt_key - no title' do is_expected.not_to contain_apt_key(title) end end describe 'duplication - two apt::key resources, different ensure' do let :pre_condition do "class { 'apt': } apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do is_expected.to raise_error(%r{already ensured as absent}) end end end describe 'defaults' do context 'when setting keyserver on the apt class' do let :pre_condition do 'class { "apt": keyserver => "keyserver.example.com", }' end it 'uses default keyserver' do is_expected.to contain_apt_key(title).with_server('keyserver.example.com') end end context 'when setting key_options on the apt class' do let :pre_condition do 'class { "apt": key_options => "http-proxy=http://proxy.example.com:8080", }' end it 'uses default keyserver' do is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080') end end end end diff --git a/spec/defines/mark_spec.rb b/spec/defines/mark_spec.rb index f776039..9228510 100644 --- a/spec/defines/mark_spec.rb +++ b/spec/defines/mark_spec.rb @@ -1,40 +1,42 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::mark', type: :define do let :title do 'my_source' end let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', lsbdistcodename: 'jessie', osfamily: 'Debian', } end context 'with correct seting' do let :params do { 'setting' => 'manual', } end it { is_expected.to contain_exec('/usr/bin/apt-mark manual my_source') } end describe 'with wrong setting' do let :params do { 'setting' => 'foobar', } end it do is_expected.to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'}) end end end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index a80ee6f..fd56dbf 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -1,147 +1,149 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::pin', type: :define do let :pre_condition do 'class { "apt": }' end let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end let(:title) { 'my_pin' } context 'with defaults' do it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n}) } end context 'with set version' do let :params do { 'packages' => 'vim', 'version' => '1', } end it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n}) } end context 'with set origin' do let :params do { 'packages' => 'vim', 'origin' => 'test', } end it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n}) } end context 'without defaults' do let :params do { 'explanation' => 'foo', 'order' => 99, 'release' => '1', 'codename' => 'bar', 'release_version' => '2', 'component' => 'baz', 'originator' => 'foobar', 'label' => 'foobaz', 'priority' => 10, } end it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n}) } it { is_expected.to contain_apt__setting('pref-my_pin').with('priority' => 99) } end context 'with ensure absent' do let :params do { 'ensure' => 'absent', } end it { is_expected.to contain_apt__setting('pref-my_pin').with('ensure' => 'absent') } end context 'with bad characters' do let(:title) { 'such bad && wow!' } it { is_expected.to contain_apt__setting('pref-such__bad____wow_') } end describe 'validation' do context 'with invalid order' do let :params do { 'order' => 'foo', } end it do is_expected.to raise_error(Puppet::Error, %r{expects an Integer value, got String}) end end context 'with packages == * and version' do let :params do { 'version' => '1', } end it do is_expected.to raise_error(Puppet::Error, %r{parameter version cannot be used in general form}) end end context 'with packages == * and release and origin' do let :params do { 'origin' => 'test', 'release' => 'foo', } end it do is_expected.to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive}) end end context 'with specific release and origin' do let :params do { 'release' => 'foo', 'origin' => 'test', 'packages' => 'vim', } end it do is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive}) end end context 'with specific version and origin' do let :params do { 'version' => '1', 'origin' => 'test', 'packages' => 'vim', } end it do is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive}) end end end end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index ba234fd..b0e689e 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,328 +1,330 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::ppa' do let :pre_condition do 'class { "apt": }' end describe 'defaults' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '41.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', } end let(:title) { 'ppa:needs/such.substitution/wow+type' } it { is_expected.not_to contain_package('python-software-properties') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with(environment: [], - command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type || (rm /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && false)', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow_type.gpg', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type || (rm /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow_type.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end describe 'Ubuntu 15.10 sources.list filename' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '15', full: '15.10' } }, lsbdistrelease: '15.10', lsbdistcodename: 'wily', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', } end let(:title) { 'ppa:user/foo' } it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [], - command: '/usr/bin/add-apt-repository -y ppa:user/foo || (rm /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && false)', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user_ubuntu_foo.gpg', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository -y ppa:user/foo || (rm /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user_ubuntu_foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end describe 'package_name => software-properties-common' do let :pre_condition do 'class { "apt": }' end let :params do { package_name: 'software-properties-common', package_manage: true, } end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', } end let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Metrics/LineLength - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Metrics/LineLength + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength 'user' => 'root', 'logoutput' => 'on_failure') } it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') } end describe 'package_manage => false' do let :pre_condition do 'class { "apt": }' end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', } end let :params do { package_manage: false, } end let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.not_to contain_package('python-software-properties') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Metrics/LineLength - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Metrics/LineLength + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength 'user' => 'root', 'logoutput' => 'on_failure') } it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') } end describe 'apt included, no proxy' do let :pre_condition do 'class { "apt": } apt::ppa { "ppa:user/foo2": } ' end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', } end let :params do { options: '', package_manage: true, require: 'Apt::Ppa[ppa:user/foo2]', } end let(:title) { 'ppa:user/foo' } it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [], - command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end describe 'apt included, proxy host' do let :pre_condition do 'class { "apt": proxy => { "host" => "localhost" }, }' end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', } end let :params do { 'options' => '', 'package_manage' => true, } end let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8080'], - command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end describe 'apt included, proxy host and port' do let :pre_condition do 'class { "apt": proxy => { "host" => "localhost", "port" => 8180 }, }' end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', } end let :params do { options: '', package_manage: true, } end let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180'], - command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end describe 'apt included, proxy host and port and https' do let :pre_condition do 'class { "apt": proxy => { "host" => "localhost", "port" => 8180, "https" => true }, }' end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', } end let :params do { options: '', package_manage: true, } end let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], - command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end describe 'ensure absent' do let :pre_condition do 'class { "apt": }' end let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', } end let(:title) { 'ppa:user/foo' } let :params do { ensure: 'absent', } end it { is_expected.to contain_file('/etc/apt/sources.list.d/user-foo-trusty.list').that_notifies('Class[Apt::Update]').with(ensure: 'absent') } end context 'with validation' do describe 'no release' do let :facts do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, lsbdistrelease: '14.04', operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodeanme: nil, } end let(:title) { 'ppa:user/foo' } it do is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) end end describe 'not ubuntu' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '6', full: '6.0.7' } }, lsbdistrelease: '6.0.7', lsbdistcodename: 'wheezy', operatingsystem: 'Debian', lsbdistid: 'debian', osfamily: 'Debian', } end let(:title) { 'ppa:user/foo' } it do is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian}) end end end end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 16db751..09cb922 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -1,137 +1,139 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } let :facts do { os: { distro: { codename: 'jessie' }, family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistrelease: '8.0', lsbdistcodename: 'jessie', operatingsystem: 'Debian', osfamily: 'Debian', lsbdistid: 'Debian', } end let(:title) { 'conf-teddybear' } let(:default_params) { { content: 'di' } } describe 'when using the defaults' do context 'without source or content' do it do is_expected.to raise_error(Puppet::Error, %r{needs either of }) end end context 'with title=conf-teddybear ' do let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') } end context 'with title=pref-teddybear' do let(:title) { 'pref-teddybear' } let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') } end context 'with title=list-teddybear' do let(:title) { 'list-teddybear' } let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') } end context 'with source' do let(:params) { { source: 'puppet:///la/die/dah' } } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', owner: 'root', group: 'root', source: params[:source].to_s) } end context 'with content' do let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', owner: 'root', group: 'root', content: params[:content].to_s) } end end describe 'settings requiring settings, MODULES-769' do let(:pre_condition) do 'class { "apt": } apt::setting { "list-teddybear": content => "foo" } ' end let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', } end let(:title) { 'conf-teddybear' } let(:default_params) { { content: 'di' } } let(:params) { default_params.merge(require: 'Apt::Setting[list-teddybear]') } it { is_expected.to compile.with_all_deps } end describe 'when trying to pull one over' do context 'with source and content' do let(:params) { default_params.merge(source: 'la') } it do is_expected.to raise_error(Puppet::Error, %r{cannot have both }) end end context 'with title=ext-teddybear' do let(:title) { 'ext-teddybear' } let(:params) { default_params } it do is_expected.to raise_error(Puppet::Error, %r{must start with either}) end end context 'with ensure=banana' do let(:params) { default_params.merge(ensure: 'banana') } it do is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]}) end end context 'with priority=1.2' do let(:params) { default_params.merge(priority: 1.2) } it { is_expected.to compile.and_raise_error(%r{expects a value of type}) } end end describe 'with priority=100' do let(:params) { default_params.merge(priority: 100) } it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') } end describe 'with ensure=absent' do let(:params) { default_params.merge(ensure: 'absent') } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent') } end end diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index 12d3d47..0c42ef1 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -1,115 +1,117 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::source', type: :define do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze + GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' let :title do 'my_source' end let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', lsbdistcodename: 'jessie', osfamily: 'Debian', } end context 'with mostly defaults' do let :params do { 'include' => { 'deb' => false, 'src' => true }, 'location' => 'http://debian.mirror.iweb.ca/debian/', } end it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end context 'with no defaults' do let :params do { 'comment' => 'foo', 'location' => 'http://debian.mirror.iweb.ca/debian/', 'release' => 'sid', 'repos' => 'testing', 'include' => { 'src' => false }, 'key' => GPG_KEY_ID, 'pin' => '10', 'architecture' => 'x86_64', 'allow_unsigned' => true, } end it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) .without_content(%r{deb-src}) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', 'priority' => '10', 'origin' => 'debian.mirror.iweb.ca') } it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', 'id' => GPG_KEY_ID) } end context 'when allow_unsigned true' do let :params do { 'include' => { 'src' => false }, 'location' => 'http://debian.mirror.iweb.ca/debian/', 'allow_unsigned' => true, } end it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end context 'with architecture equals x86_64' do let :params do { 'location' => 'http://debian.mirror.iweb.ca/debian/', 'architecture' => 'x86_64', } end it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end context 'with ensure => absent' do let :params do { 'ensure' => 'absent', } end it { is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent') } end describe 'validation' do context 'with no release' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, osfamily: 'Debian', } end it do is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) end end end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index dc8466c..0adcaad 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -1,362 +1,364 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::source' do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze + GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' let :pre_condition do 'class { "apt": }' end let :title do 'my_source' end let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', lsbdistcodename: 'jessie', operatingsystem: 'Debian', osfamily: 'Debian', } end context 'with defaults' do context 'without location' do it do is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location}) end end context 'with location' do let(:params) { { location: 'hello.there' } } it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n}) is_expected.not_to contain_package('apt-transport-https') } end end describe 'no defaults' do context 'with complex pin' do let :params do { location: 'hello.there', pin: { 'release' => 'wishwash', 'explanation' => 'wishwash', 'priority' => 1001 }, } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there jessie main\n}) } it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', priority: 1001, explanation: 'wishwash', release: 'wishwash') } end context 'with simple key' do let :params do { comment: 'foo', location: 'http://debian.mirror.iweb.ca/debian/', release: 'sid', repos: 'testing', key: GPG_KEY_ID, pin: '10', architecture: 'x86_64', allow_unsigned: true, } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) .without_content(%r{deb-src}) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', priority: '10', origin: 'debian.mirror.iweb.ca') } it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', id: GPG_KEY_ID) } end context 'with complex key' do let :params do { comment: 'foo', location: 'http://debian.mirror.iweb.ca/debian/', release: 'sid', repos: 'testing', key: { 'ensure' => 'refreshed', 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', 'source' => 'http://apt.puppetlabs.com/pubkey.gpg' }, pin: '10', architecture: 'x86_64', allow_unsigned: true, } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) .without_content(%r{deb-src}) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', priority: '10', origin: 'debian.mirror.iweb.ca') } it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed', id: GPG_KEY_ID, server: 'pgp.mit.edu', content: 'GPG key content', source: 'http://apt.puppetlabs.com/pubkey.gpg') } end end context 'with allow_unsigned true' do let :params do { location: 'hello.there', allow_unsigned: true, } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there jessie main\n}) } end context 'with a https location, install apt-transport-https' do let :params do { location: 'HTTPS://foo.bar', allow_unsigned: false, } end it { is_expected.to contain_package('apt-transport-https') } end context 'with a https location and custom release, install apt-transport-https' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } end let :params do { location: 'HTTPS://foo.bar', allow_unsigned: false, release: 'customrelease', } end it { is_expected.to contain_package('apt-transport-https') } end context 'with a https location, do not install apt-transport-https on oses not in list eg buster' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '10', full: '10.0' } }, lsbdistid: 'Debian', lsbdistcodename: 'buster', osfamily: 'Debian', } end let :params do { location: 'https://foo.bar', allow_unsigned: false, } end it { is_expected.not_to contain_package('apt-transport-https') } end context 'with architecture equals x86_64' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, lsbdistid: 'Debian', lsbdistcodename: 'wheezy', osfamily: 'Debian', } end let :params do { location: 'hello.there', include: { 'deb' => false, 'src' => true }, architecture: 'x86_64', } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n}) } end context 'with architecture fact and unset architecture parameter' do let :facts do super().merge(architecture: 'amd64') end let :params do { location: 'hello.there', include: { 'deb' => false, 'src' => true }, } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there jessie main\n}) } end context 'with include_src => true' do let :params do { location: 'hello.there', include: { 'src' => true }, } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there jessie main\ndeb-src hello.there jessie main\n}) } end context 'with include deb => false' do let :params do { include: { 'deb' => false }, location: 'hello.there', } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n}) } it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) } end context 'with include src => true and include deb => false' do let :params do { include: { 'deb' => false, 'src' => true }, location: 'hello.there', } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there jessie main\n}) } it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there jessie main\n}) } end context 'with ensure => absent' do let :params do { ensure: 'absent', } end it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'absent') } end describe 'validation' do context 'with no release' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, osfamily: 'Debian', } end let(:params) { { location: 'hello.there' } } it do is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) end end context 'with release is empty string' do let(:params) { { location: 'hello.there', release: '' } } it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there main}) } end context 'with invalid pin' do let :params do { location: 'hello.there', pin: true, } end it do is_expected.to raise_error(Puppet::Error, %r{expects a value}) end end context 'with notify_update = undef (default)' do let :params do { location: 'hello.there', } end it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) } end context 'with notify_update = true' do let :params do { location: 'hello.there', notify_update: true, } end it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) } end context 'with notify_update = false' do let :params do { location: 'hello.there', notify_update: false, } end it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) } end end end diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 4022171..d5339ae 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze MAX_RETRY_COUNT = 5 RETRY_WAIT = 3 -ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)} +ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)}.freeze # this is needed for puppet facts / apply lsb_package = <<-MANIFEST package { 'lsb-release': ensure => installed, } MANIFEST include PuppetLitmus apply_manifest(lsb_package) # This method allows a block to be passed in and if an exception is raised # that matches the 'error_matcher' matcher, the block will wait a set number # of seconds before retrying. # Params: # - max_retry_count - Max number of retries # - retry_wait_interval_secs - Number of seconds to wait before retry # - error_matcher - Matcher which the exception raised must match to allow retry # Example Usage: # retry_on_error_matching(3, 5, /OpenGPG Error/) do # apply_manifest(pp, :catch_failures => true) # end def retry_on_error_matching(max_retry_count = MAX_RETRY_COUNT, retry_wait_interval_secs = RETRY_WAIT, error_matcher = ERROR_MATCHER) try = 0 begin puts "retry_on_error_matching: try #{try}" unless try.zero? try += 1 yield rescue StandardError => e raise('Attempted this %{value0} times. Raising %{value1}' % { value0: max_retry_count, value1: e }) unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher) sleep retry_wait_interval_secs retry end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 2e897cb..ce4d062 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -1,28 +1,30 @@ +# frozen_string_literal: true + if ENV['COVERAGE'] == 'yes' require 'simplecov' require 'simplecov-console' require 'codecov' SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console, SimpleCov::Formatter::Codecov, ] SimpleCov.start do track_files 'lib/**/*.rb' add_filter '/spec' # do not track vendored files add_filter '/vendor' add_filter '/.vendor' # do not track gitignored files # this adds about 4 seconds to the coverage check # this could definitely be optimized add_filter do |f| # system returns true if exit status is 0, which with git-check-ignore means file is ignored system("git check-ignore --quiet #{f.filename}") end end end diff --git a/spec/unit/facter/apt_dist_has_updates_spec.rb b/spec/unit/facter/apt_dist_has_updates_spec.rb index 6130f27..17b6d81 100644 --- a/spec/unit/facter/apt_dist_has_updates_spec.rb +++ b/spec/unit/facter/apt_dist_has_updates_spec.rb @@ -1,39 +1,41 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_has_dist_updates fact' do subject { Facter.fact(:apt_has_dist_updates).value } before(:each) { Facter.clear } describe 'on non-Debian distro' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat') end it { is_expected.to be_nil } end describe 'on Debian based distro missing apt-get' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false) end it { is_expected.to be_nil } end describe 'on Debian based distro' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test') apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_dist_package_security_updates_spec.rb b/spec/unit/facter/apt_dist_package_security_updates_spec.rb index 4033a28..418c953 100644 --- a/spec/unit/facter/apt_dist_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_security_updates_spec.rb @@ -1,52 +1,54 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_package_security_dist_updates fact' do subject { Facter.fact(:apt_package_security_dist_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test') allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_get_upgrade_output) end describe 'on Debian' do let(:apt_get_upgrade_output) do "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Inst vim [7.52.1-5] (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64]) []\n" \ "Conf vim (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64])\n" \ end it { is_expected.to eq(['vim']) } end describe 'on Ubuntu' do let(:apt_get_upgrade_output) do "Inst extremetuxracer [2016f-0ubuntu0.16.04] (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Conf extremetuxracer (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Inst vim [7.47.0-1ubuntu2] (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64]) []\n" \ "Conf vim (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64])\n" \ "Inst onioncircuits [2:3.3.10-4ubuntu2] (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" \ "Conf onioncircuits (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" end it { is_expected.to eq(['extremetuxracer', 'vim']) } end end end diff --git a/spec/unit/facter/apt_dist_package_updates_spec.rb b/spec/unit/facter/apt_dist_package_updates_spec.rb index 59e02b8..952bf5c 100644 --- a/spec/unit/facter/apt_dist_package_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_updates_spec.rb @@ -1,31 +1,33 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_package_dist_updates fact' do subject { Facter.fact(:apt_package_dist_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test') allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end it { is_expected.to eq(['extremetuxracer', 'planet.rb']) } end end diff --git a/spec/unit/facter/apt_dist_security_updates_spec.rb b/spec/unit/facter/apt_dist_security_updates_spec.rb index 895a36c..c75df88 100644 --- a/spec/unit/facter/apt_dist_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_security_updates_spec.rb @@ -1,52 +1,54 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_security_updates fact' do subject { Facter.fact(:apt_security_dist_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has security updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test') allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_get_upgrade_output) end describe 'on Debian' do let(:apt_get_upgrade_output) do "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Inst vim [7.52.1-5] (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64]) []\n" \ "Conf vim (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64])\n" \ end it { is_expected.to eq(1) } end describe 'on Ubuntu' do let(:apt_get_upgrade_output) do "Inst extremetuxracer [2016f-0ubuntu0.16.04] (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Conf extremetuxracer (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Inst vim [7.47.0-1ubuntu2] (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64]) []\n" \ "Conf vim (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64])\n" \ "Inst onioncircuits [2:3.3.10-4ubuntu2] (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" \ "Conf onioncircuits (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" end it { is_expected.to eq(2) } end end end diff --git a/spec/unit/facter/apt_dist_updates_spec.rb b/spec/unit/facter/apt_dist_updates_spec.rb index 112dca8..2bce358 100644 --- a/spec/unit/facter/apt_dist_updates_spec.rb +++ b/spec/unit/facter/apt_dist_updates_spec.rb @@ -1,31 +1,33 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_updates fact' do subject { Facter.fact(:apt_dist_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test') allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end it { is_expected.to eq(2) } end end diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb index ea3e085..1fc5ab6 100644 --- a/spec/unit/facter/apt_has_updates_spec.rb +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -1,38 +1,40 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_has_updates fact' do subject { Facter.fact(:apt_has_updates).value } before(:each) { Facter.clear } describe 'on non-Debian distro' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat') end it { is_expected.to be_nil } end describe 'on Debian based distro missing apt-get' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false) end it { is_expected.to be_nil } end describe 'on Debian based distro' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) apt_output = "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_package_security_updates_spec.rb b/spec/unit/facter/apt_package_security_updates_spec.rb index 958fd00..699eb61 100644 --- a/spec/unit/facter/apt_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_package_security_updates_spec.rb @@ -1,50 +1,52 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_package_security_updates fact' do subject { Facter.fact(:apt_package_security_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_get_upgrade_output) end describe 'on Debian' do let(:apt_get_upgrade_output) do "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Inst curl [7.52.1-5] (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64]) []\n" \ "Conf curl (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64])\n" \ end it { is_expected.to eq(['curl']) } end describe 'on Ubuntu' do let(:apt_get_upgrade_output) do "Inst tzdata [2016f-0ubuntu0.16.04] (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Conf tzdata (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Inst curl [7.47.0-1ubuntu2] (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64]) []\n" \ "Conf curl (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64])\n" \ "Inst procps [2:3.3.10-4ubuntu2] (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" \ "Conf procps (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" end it { is_expected.to eq(['tzdata', 'curl']) } end end end diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index 4c81d0c..267e2bf 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -1,29 +1,31 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_package_updates fact' do subject { Facter.fact(:apt_package_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) apt_output = "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end it { is_expected.to eq(['tzdata', 'unhide.rb']) } end end diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index 22f5617..7621872 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -1,25 +1,27 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_reboot_required fact' do subject { Facter.fact(:apt_reboot_required).value } before(:each) { Facter.clear } describe 'if a reboot is required' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:file?).and_return(true) allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true) end it { is_expected.to eq true } end describe 'if a reboot is not required' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:file?).and_return(true) allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false) end it { is_expected.to eq false } end end diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index 4e4b54d..8942120 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -1,50 +1,52 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_security_updates fact' do subject { Facter.fact(:apt_security_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has security updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_get_upgrade_output) end describe 'on Debian' do let(:apt_get_upgrade_output) do "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Inst curl [7.52.1-5] (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64]) []\n" \ "Conf curl (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64])\n" \ end it { is_expected.to eq(1) } end describe 'on Ubuntu' do let(:apt_get_upgrade_output) do "Inst tzdata [2016f-0ubuntu0.16.04] (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Conf tzdata (2016j-0ubuntu0.16.04 Ubuntu:16.04/xenial-security, Ubuntu:16.04/xenial-updates [all])\n" \ "Inst curl [7.47.0-1ubuntu2] (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64]) []\n" \ "Conf curl (7.47.0-1ubuntu2.2 Ubuntu:16.04/xenial-security [amd64])\n" \ "Inst procps [2:3.3.10-4ubuntu2] (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" \ "Conf procps (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n" end it { is_expected.to eq(2) } end end end diff --git a/spec/unit/facter/apt_update_last_success_spec.rb b/spec/unit/facter/apt_update_last_success_spec.rb index f4858dd..c0b028a 100644 --- a/spec/unit/facter/apt_update_last_success_spec.rb +++ b/spec/unit/facter/apt_update_last_success_spec.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_update_last_success fact' do subject { Facter.fact(:apt_update_last_success).value } before(:each) { Facter.clear } describe 'on Debian based distro which has not yet created the update-success-stamp file' do it 'has a value of -1' do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:exist?).with('/var/lib/apt/periodic/update-success-stamp').and_return(false) is_expected.to eq(-1) end end describe 'on Debian based distro which has created the update-success-stamp' do it 'has the value of the mtime of the file' do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:mtime).and_return(1_407_660_561) is_expected.to eq(1_407_660_561) end end end diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index 1f1c15b..5114104 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -1,29 +1,31 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt_updates fact' do subject { Facter.fact(:apt_updates).value } before(:each) { Facter.clear } describe 'when apt has no updates' do before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end it { is_expected.to be nil } end describe 'when apt has updates' do before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:executable?) # Stub all other calls allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true) apt_output = "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n" \ "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end it { is_expected.to eq(2) } end end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 7b87017..b895817 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -1,216 +1,218 @@ +# frozen_string_literal: true + require 'spec_helper' describe Puppet::Type.type(:apt_key).provider(:apt_key) do describe 'instances' do it 'has an instance method' do expect(described_class).to respond_to :instances end end describe 'prefetch' do it 'has a prefetch method' do expect(described_class).to respond_to :prefetch end end context 'self.instances no key' do before :each do # Unable to remove `master` from below terminology as it relies on outside code allow(described_class).to receive(:apt_key).with( ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return('uid:-::::1284991450::07BEBE04F4AE4A8E885A761325717D8509D9C1DC::Ubuntu Extras Archive Automatic Signing Key ::::::::::0:') end it 'returns no resources' do expect(described_class.instances.size).to eq(0) end end context 'self.instances multiple keys' do before :each do command_output = <<-OUTPUT Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.DU0GdRxjmE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/puppetlabs-pc1-keyring.gpg --no-tty --list-keys --with-colons --fingerprint --fixed-list-mode tru:t:1:1549900774:0:3:1:5 pub:-:1024:17:40976EAF437D05B5:1095016255:::-:::scESC: fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: uid:-::::1095016255::B84AE656F4F5A826C273A458512EF8E282754CE1::Ubuntu Archive Automatic Signing Key : sub:-:2048:16:251BEFF479164387:1095016263::::::e: pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC: fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: OUTPUT allow(described_class).to receive(:apt_key).with( ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return(command_output) end it 'returns 2 resources' do expect(described_class.instances.size).to eq(2) expect(described_class.instances[0].name).to eq('630239CC130E1A7FD81A27B140976EAF437D05B5') expect(described_class.instances[0].id).to eq('40976EAF437D05B5') expect(described_class.instances[1].name).to eq('C5986B4F1257FFA86632CBA746181433FBB75451') expect(described_class.instances[1].id).to eq('46181433FBB75451') end end context 'create apt_key resource' do it 'apt_key with content set and source nil' do expect(described_class).to receive(:apt_key).with(['adv', '--no-tty', '--keyserver', :"keyserver.ubuntu.com", '--recv-keys', 'C105B9DE']) resource = Puppet::Type::Apt_key.new(name: 'source and content nil', id: 'C105B9DE', ensure: 'present') provider = described_class.new(resource) expect(provider).not_to be_exist provider.create expect(provider).to be_exist end it 'apt_key content and source nil, options set' do expect(described_class).to receive(:apt_key).with(['adv', '--no-tty', '--keyserver', :"keyserver.ubuntu.com", '--keyserver-options', 'jimno', '--recv-keys', 'C105B9DE']) resource = Puppet::Type::Apt_key.new(name: 'source and content nil', id: 'C105B9DE', options: 'jimno', ensure: 'present') provider = described_class.new(resource) expect(provider).not_to be_exist provider.create expect(provider).to be_exist end it 'apt_key with content set' do expect(described_class).to receive(:apt_key).with(array_including('add', kind_of(String))) resource = Puppet::Type::Apt_key.new(name: 'gsd', id: 'C105B9DE', content: 'asad', ensure: 'present') provider = described_class.new(resource) expect(provider).not_to be_exist expect(provider).to receive(:tempfile).and_return(Tempfile.new('foo')) provider.create expect(provider).to be_exist end it 'apt_key with source set' do expect(described_class).to receive(:apt_key).with(array_including('add', kind_of(String))) resource = Puppet::Type::Apt_key.new(name: 'gsd', id: 'C105B9DE', source: 'ftp://bla/herpderp.gpg', ensure: 'present') provider = described_class.new(resource) expect(provider).not_to be_exist expect(provider).to receive(:source_to_file).and_return(Tempfile.new('foo')) provider.create expect(provider).to be_exist end it 'apt_key with source and weak ssl verify set' do expect(described_class).to receive(:apt_key).with(array_including('add', kind_of(String))) resource = Puppet::Type::Apt_key.new(name: 'gsd', id: 'C105B9DE', source: 'https://bla/herpderp.gpg', ensure: 'present', weak_ssl: true) provider = described_class.new(resource) expect(provider).not_to be_exist expect(provider).to receive(:source_to_file).and_return(Tempfile.new('foo')) provider.create expect(provider).to be_exist end describe 'different valid id keys' do hash_of_keys = { '32bit key id' => 'EF8D349F', '64bit key id' => '7F438280EF8D349F', '160bit key fingerprint' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', '32bit key id lowercase' => 'EF8D349F'.downcase, '64bit key id lowercase' => '7F438280EF8D349F'.downcase, '160bit key fingerprint lowercase' => '6F6B15509CF8E59E6E469F327F438280EF8D349F'.downcase, '32bit key id 0x formatted' => '0xEF8D349F', '64bit key id 0x formatted' => '0x7F438280EF8D349F', '160bit key fingerprint 0x formatted' => '0x6F6B15509CF8E59E6E469F327F438280EF8D349F', } hash_of_keys.each do |key_type, value| it "#{key_type} #{value} is valid" do expect(described_class).to receive(:apt_key).with(array_including('adv', '--no-tty', '--keyserver', :"keyserver.ubuntu.com", '--recv-keys')) resource = Puppet::Type::Apt_key.new(name: 'source and content nil', id: value, ensure: 'present') provider = described_class.new(resource) expect(provider).not_to be_exist provider.create expect(provider).to be_exist end end end it 'apt_key with invalid key length' do expect { Puppet::Type::Apt_key.new(name: 'source and content nil', id: '1', ensure: 'present') }.to raise_error(Puppet::ResourceError, %r{Parameter id failed on Apt_key}) end end context 'key_line_hash function' do it 'matches rsa' do expect(described_class.key_line_hash('pub:-:1024:1:40976EAF437D05B5:1095016255:::-:::scESC:', 'fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:')).to include( key_expiry: nil, key_fingerprint: '630239CC130E1A7FD81A27B140976EAF437D05B5', key_long: '40976EAF437D05B5', key_short: '437D05B5', key_size: '1024', key_type: :rsa, ) end it 'matches dsa' do expect(described_class.key_line_hash('pub:-:1024:17:40976EAF437D05B5:1095016255:::-:::scESC:', 'fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:')).to include( key_expiry: nil, key_fingerprint: '630239CC130E1A7FD81A27B140976EAF437D05B5', key_long: '40976EAF437D05B5', key_short: '437D05B5', key_size: '1024', key_type: :dsa, ) end it 'matches ecc' do expect(described_class.key_line_hash('pub:-:1024:18:40976EAF437D05B5:1095016255:::-:::scESC:', 'fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:')).to include( key_expiry: nil, key_fingerprint: '630239CC130E1A7FD81A27B140976EAF437D05B5', key_long: '40976EAF437D05B5', key_short: '437D05B5', key_size: '1024', key_type: :ecc, ) end it 'matches ecdsa' do expect(described_class.key_line_hash('pub:-:1024:19:40976EAF437D05B5:1095016255:::-:::scESC:', 'fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:')).to include( key_expiry: nil, key_fingerprint: '630239CC130E1A7FD81A27B140976EAF437D05B5', key_long: '40976EAF437D05B5', key_short: '437D05B5', key_size: '1024', key_type: :ecdsa, ) end end end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index 253b644..b20a09a 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -1,243 +1,245 @@ +# frozen_string_literal: true + require 'spec_helper' require 'puppet' describe Puppet::Type.type(:apt_key) do context 'with only namevar 32bit key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'EF8D349F', ) end it 'id is set' do expect(resource[:id]).to eq 'EF8D349F' end it 'name is set to id' do expect(resource[:name]).to eq 'EF8D349F' end it 'keyserver is default' do expect(resource[:server]).to eq :'keyserver.ubuntu.com' end it 'source is not set' do expect(resource[:source]).to eq nil end it 'content is not set' do expect(resource[:content]).to eq nil end it 'refresh is not set' do expect(resource[:refresh]).to eq nil end it 'weak_ssl is not set' do expect(resource[:weak_ssl]).to eq nil end end context 'with a lowercase 32bit key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'ef8d349f', ) end it 'id is set' do expect(resource[:id]).to eq 'EF8D349F' end end context 'with a 64bit key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'FFFFFFFFEF8D349F', ) end it 'id is set' do expect(resource[:id]).to eq 'FFFFFFFFEF8D349F' end end context 'with a 0x formatted key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: '0xEF8D349F', ) end it 'id is set' do expect(resource[:id]).to eq 'EF8D349F' end end context 'with a 0x formatted lowercase key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: '0xef8d349f', ) end it 'id is set' do expect(resource[:id]).to eq 'EF8D349F' end end context 'with a 0x formatted 64bit key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: '0xFFFFFFFFEF8D349F', ) end it 'id is set' do expect(resource[:id]).to eq 'FFFFFFFFEF8D349F' end end context 'with source' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'EF8D349F', source: 'http://apt.puppetlabs.com/pubkey.gpg', ) end it 'source is set to the URL' do expect(resource[:source]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end context 'with source and weak_ssl' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'EF8D349F', source: 'https://apt.puppetlabs.com/pubkey.gpg', weak_ssl: true, ) end it 'source is set to the URL' do expect(resource[:source]).to eq 'https://apt.puppetlabs.com/pubkey.gpg' end end context 'with content' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'EF8D349F', content: 'http://apt.puppetlabs.com/pubkey.gpg', ) end it 'content is set to the string' do expect(resource[:content]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end context 'with keyserver' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'EF8D349F', server: 'http://keyring.debian.org', ) end it 'keyserver is set to Debian' do expect(resource[:server]).to eq 'http://keyring.debian.org' end end context 'with validation' do it 'raises an error if content and source are set' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'http://apt.puppetlabs.com/pubkey.gpg', content: 'Completely invalid as a GPG key') }.to raise_error(%r{content and source are mutually exclusive}) end it 'raises an error if refresh => true and ensure => absent' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'http://apt.puppetlabs.com/pubkey.gpg', ensure: :absent, refresh: :true) }.to raise_error(%r{ensure => absent and refresh => true are mutually exclusive}) end it 'raises an error if a weird length key is used' do expect { Puppet::Type.type(:apt_key).new(id: 'FEF8D349F', source: 'http://apt.puppetlabs.com/pubkey.gpg', content: 'Completely invalid as a GPG key') }.to raise_error(%r{Valid values match}) end it 'raises an error when an invalid URI scheme is used in source' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'hkp://pgp.mit.edu') }.to raise_error(%r{Valid values match}) end it 'allows the http URI scheme in source' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'http://pgp.mit.edu') }.not_to raise_error end it 'allows the http URI with username and password' do expect { Puppet::Type.type(:apt_key).new(id: '4BD6EC30', source: 'http://testme:Password2@pgp.mit.edu') }.not_to raise_error end it 'allows the https URI scheme in source' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'https://pgp.mit.edu') }.not_to raise_error end it 'allows the https URI with username and password' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'https://testme:Password2@pgp.mit.edu') }.not_to raise_error end it 'allows the ftp URI scheme in source' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'ftp://pgp.mit.edu') }.not_to raise_error end it 'allows an absolute path in source' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: '/path/to/a/file') }.not_to raise_error end it 'allows 5-digit ports' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'http://pgp.mit.edu:12345/key') }.not_to raise_error end it 'allows 5-digit ports when using key servers' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', server: 'http://pgp.mit.edu:12345') }.not_to raise_error end end end diff --git a/tasks/init.rb b/tasks/init.rb index 3cd20d4..4305312 100755 --- a/tasks/init.rb +++ b/tasks/init.rb @@ -1,24 +1,26 @@ #!/opt/puppetlabs/puppet/bin/ruby +# frozen_string_literal: true + require 'json' require 'open3' require 'puppet' def apt_get(action) cmd = ['apt-get', action] cmd << '-y' if ['upgrade', 'dist-upgrade', 'autoremove'].include?(action) stdout, stderr, status = Open3.capture3(*cmd) raise Puppet::Error, stderr if status != 0 { status: stdout.strip } end params = JSON.parse(STDIN.read) action = params['action'] begin result = apt_get(action) puts result.to_json exit 0 rescue Puppet::Error => e puts({ status: 'failure', error: e.message }.to_json) exit 1 end