diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4e115c9..4021da7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,217 +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:: - name: Install agent run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - name: Install module run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' - name: "Honeycomb: Record deployment times" if: ${{ always() }} run: | echo ::group::honeycomb step buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' echo STEP_ID=${{ matrix.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 b8f49c7..2b5ab1f 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -1,198 +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:: - name: Install agent run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - name: Install module run: | buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' - name: "Honeycomb: Record deployment times" if: ${{ always() }} run: | echo ::group::honeycomb step buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' echo STEP_ID=${{ matrix.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 34a4a2e..3aaa696 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,137 +1,512 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true 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 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/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/InsecureProtocolSource: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Layout/EmptyComment: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: 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 +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/CurrentPathExpectation: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/Capybara/VisibilityMatcher: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false Style/AsciiComments: Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NilLambda: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.sync.yml b/.sync.yml index cb2fbd9..876031f 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,54 +1,51 @@ --- ".gitlab-ci.yml": delete: true ".travis.yml": dist: 'bionic' - 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 - travis_el7 complex: - collection: puppet_collection: - puppet6 provision_list: - travis_ub_6 - collection: puppet_collection: - puppet5 provision_list: - travis_ub_5 simplecov: true notifications: slack: secure: hFiD5ejH+4p5mnXINU7qsoRObHyeQNn/mns2FLeNDXj7EEWFuqDbnO+jxw87GjXCeoSenkoszOIYvDn/p/we5SGqlMDMyFLCDT4D5tLN4lRYSphOo+Db0uNynPCwFgTbG1BdN4eQuy2GdT8LQuNcEjXmLrdrR7A9FbRzTbwEGkE= 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') Rakefile: changelog_user: puppetlabs spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true .gitpod.Dockerfile: unmanaged: false .gitpod.yml: unmanaged: false .github/workflows/nightly.yml: unmanaged: false .github/workflows/pr_test.yml: unmanaged: false diff --git a/.travis.yml b/.travis.yml index e9510e9..bc90462 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,115 +1,109 @@ --- os: linux dist: bionic 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_el7]'" - "bundle exec rake 'litmus:install_agent[puppet5]'" - "bundle exec rake litmus:install_module" - bundler_args: env: PLATFORMS=travis_el7_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 - - + - bundler_args: --with system_tests before_script: - "bundle exec rake 'litmus:provision_list[travis_el7]'" - "bundle exec rake 'litmus:install_agent[puppet6]'" - "bundle exec rake litmus:install_module" - bundler_args: env: PLATFORMS=travis_el7_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: hFiD5ejH+4p5mnXINU7qsoRObHyeQNn/mns2FLeNDXj7EEWFuqDbnO+jxw87GjXCeoSenkoszOIYvDn/p/we5SGqlMDMyFLCDT4D5tLN4lRYSphOo+Db0uNynPCwFgTbG1BdN4eQuy2GdT8LQuNcEjXmLrdrR7A9FbRzTbwEGkE= diff --git a/Gemfile b/Gemfile index b6b25af..ae2b430 100644 --- a/Gemfile +++ b/Gemfile @@ -1,74 +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-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/metadata.json b/metadata.json index d4ecee4..d68b927 100644 --- a/metadata.json +++ b/metadata.json @@ -1,98 +1,98 @@ { "name": "puppetlabs-ntp", "version": "8.5.0", "author": "puppetlabs", "summary": "Installs, configures, and manages the NTP service.", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-ntp", "project_page": "https://github.com/puppetlabs/puppetlabs-ntp", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.13.1 < 7.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "11 SP1", "12", "15" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "8", "9", "10" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04", "18.04", "20.04" ] }, { "operatingsystem": "Solaris", "operatingsystemrelease": [ "11" ] }, { "operatingsystem": "AIX", "operatingsystemrelease": [ "5.3", "6.1", "7.1" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 5.5.10 < 8.0.0" } ], "description": "NTP Module for Debian, Ubuntu, CentOS, RHEL, OEL, Fedora, FreeBSD, ArchLinux, Amazon Linux and Gentoo.", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g62126e1", + "template-ref": "heads/main-0-g4543421", "pdk-version": "1.18.1" } diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index e82dc83..1b4fdba 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -1,1150 +1,1150 @@ # frozen_string_literal: true require 'spec_helper' on_supported_os.each do |os, f| describe 'ntp' do let(:facts) { { is_virtual: false } } let(:conf_path) do - if os.match?(%r{solaris}) + if os.include?('solaris') '/etc/inet/ntp.conf' else '/etc/ntp.conf' end end context "on #{os}" do let(:facts) do f.merge(super()) end it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('ntp::install') } it { is_expected.to contain_class('ntp::config') } it { is_expected.to contain_class('ntp::service') } describe 'ntp::config' do it { is_expected.to contain_file(conf_path).with_owner('0') } it { is_expected.to contain_file(conf_path).with_group('0') } it { is_expected.to contain_file(conf_path).with_mode('0644') } if f[:os]['family'] == 'RedHat' it { is_expected.to contain_file('/etc/ntp/step-tickers').with_owner('0') } it { is_expected.to contain_file('/etc/ntp/step-tickers').with_group('0') } it { is_expected.to contain_file('/etc/ntp/step-tickers').with_mode('0644') } end if f[:os]['family'] == 'Suse' && f[:os]['release']['major'] == '12' it { is_expected.to contain_file('/var/run/ntp/servers-netconfig').with_ensure_absent } end describe 'allows template to be overridden with erb template' do let(:params) { { config_template: 'my_ntp/ntp.conf.erb' } } it { is_expected.to contain_file(conf_path).with_content(%r{erbserver1}) } end describe 'allows template to be overridden with epp template' do let(:params) { { config_epp: 'my_ntp/ntp.conf.epp' } } it { is_expected.to contain_file(conf_path).with_content(%r{eppserver1}) } end describe 'broadcastclient' do context 'when set to true' do let(:params) do { broadcastclient: true, } end it 'contains broadcastclient setting' do is_expected.to contain_file(conf_path).with('content' => %r{^broadcastclient\n}) end end context 'when set to false' do let(:params) do { broadcastclient: false, } end it 'does not contain broadcastclient setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^broadcastclient\n}) end end end describe 'burst' do context 'when set to true' do let(:params) do { burst: true, } end it do is_expected.to contain_file(conf_path).with('content' => %r{ burst\n}) end end context 'when set to false' do let(:params) do { burst: false, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{ burst\n}) end end end context 'config_dir' do context 'when set to custom dir' do let(:params) do { keys_enable: true, config_dir: '/tmp/foo', keys_file: '/tmp/foo/ntp.keys', } end it 'contains custom config directory' do is_expected.to contain_file('/tmp/foo').with( 'ensure' => 'directory', 'owner' => '0', 'group' => '0', 'mode' => '0775', 'recurse' => 'false', ) end end end context 'config_file_mode' do context 'when set to custom mode' do let(:params) do { config_file_mode: '0777', } end it 'contains file mode of 0777' do is_expected.to contain_file(conf_path).with_mode('0777') end end end - context 'default pool servers' do + context 'default pool servers' do # rubocop:disable RSpec/EmptyExampleGroup case f[:os]['family'] when 'RedHat' it 'uses the centos ntp servers' do is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.centos.pool.ntp.org}) end it do is_expected.to contain_file('/etc/ntp/step-tickers').with('content' => %r{\d.centos.pool.ntp.org}) end when 'Debian' it 'uses the debian ntp servers' do is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.debian.pool.ntp.org iburst\n}) end when 'Suse' it 'uses the opensuse ntp servers' do is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.opensuse.pool.ntp.org}) end when 'FreeBSD' it 'uses the freebsd ntp servers' do is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.freebsd.pool.ntp.org iburst maxpoll 9}) end when 'Solaris' it 'uses the generic NTP pool servers' do is_expected.to contain_file('/etc/inet/ntp.conf').with('content' => %r{server \d.pool.ntp.org}) end when 'AIX' it 'uses the generic NTP pool servers on AIX' do is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.pool.ntp.org}) end else it { expect { catalogue }.to raise_error( %r{The ntp module is not supported on an unsupported based system.}, ) } end end describe 'disable_auth' do context 'when set to true' do let(:params) do { disable_auth: true, } end it 'contains disable auth setting' do is_expected.to contain_file(conf_path).with('content' => %r{^disable auth\n}) end end context 'when set to false' do let(:params) do { disable_auth: false, } end it 'does not contain disable auth setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^disable auth\n}) end end end describe 'disable_dhclient' do context 'when set to true' do let(:params) do { disable_dhclient: true, } end it 'contains disable ntp-servers setting' do is_expected.to contain_augeas('disable ntp-servers in dhclient.conf') end it 'contains dhcp file' do is_expected.to contain_file('/var/lib/ntp/ntp.conf.dhcp').with_ensure('absent') end it 'contains ntp.sh file' do is_expected.to contain_file('/etc/dhcp/dhclient.d/ntp.sh').with_ensure('absent') end end context 'when set to false' do let(:params) do { disable_dhclient: false, } end it 'does not contain disable ntp-servers setting' do is_expected.not_to contain_augeas('disable ntp-servers in dhclient.conf') end it 'does not contain dhcp file' do is_expected.not_to contain_file('/var/lib/ntp/ntp.conf.dhcp').with_ensure('absent') end end end describe 'disable_kernel' do context 'when set to true' do let(:params) do { disable_kernel: true, } end it 'contains disable kernel setting' do is_expected.to contain_file(conf_path).with('content' => %r{^disable kernel\n}) end end context 'when set to false' do let(:params) do { disable_kernel: false, } end it 'does not contain disable kernel setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^disable kernel\n}) end end end describe 'disable_monitor' do context 'when default' do let(:params) do { } end it 'contains disable monitor setting' do is_expected.to contain_file(conf_path).with('content' => %r{^disable monitor\n}) end end context 'when set to true' do let(:params) do { disable_monitor: true, } end it 'contains disable monitor setting' do is_expected.to contain_file(conf_path).with('content' => %r{^disable monitor\n}) end end context 'when set to false' do let(:params) do { disable_monitor: false, } end it 'does not contain disable monitor setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^disable monitor\n}) end end end describe 'driftfile' do context 'when not set' do it 'contains default driftfile' do is_expected.to contain_file(conf_path).with('content' => %r{^driftfile}) end end context 'when set' do let(:params) do { driftfile: '/tmp/driftfile', } end it 'contains driftfile value' do is_expected.to contain_file(conf_path).with('content' => %r{^driftfile /tmp/driftfile\n}) end end end describe 'enable_mode7' do context 'when default' do let(:params) do { } end it 'does not contain enable mode7 setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^enable mode7\n}) end end context 'when set to true' do let(:params) do { enable_mode7: true, } end it 'contains enable mode7 setting' do is_expected.to contain_file(conf_path).with('content' => %r{^enable mode7\n}) end end context 'when set to false' do let(:params) do { enable_mode7: false, } end it 'does not contain enable mode7 setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^enable mode7\n}) end end end describe 'interfaces' do context 'when set' do let(:params) do { servers: ['a', 'b', 'c', 'd'], interfaces: ['127.0.0.1', 'a.b.c.d'], } end it { is_expected.to contain_file(conf_path).with('content' => %r{interface ignore wildcard\ninterface listen 127.0.0.1\ninterface listen a.b.c.d}) } end context 'when not set' do let(:params) do { servers: ['a', 'b', 'c', 'd'], } end it { is_expected.not_to contain_file(conf_path).with('content' => %r{interface ignore wildcard}) } end end describe 'interfaces_ignore' do context 'when set' do let(:params) do { interfaces: ['a.b.c.d'], interfaces_ignore: ['wildcard', 'ipv6'], } end it { is_expected.to contain_file(conf_path).with('content' => %r{interface ignore wildcard\ninterface ignore ipv6\ninterface listen a.b.c.d}) } end context 'when not set' do let(:params) do { interfaces: ['127.0.0.1'], servers: ['a', 'b', 'c', 'd'], } end it { is_expected.to contain_file(conf_path).with('content' => %r{interface ignore wildcard\ninterface listen 127.0.0.1}) } end end describe 'keys' do context 'when enabled' do let(:params) do { keys_enable: true, keys_trusted: [1, 2, 3], keys_controlkey: 2, keys_requestkey: 3, keys: ['1 M AAAABBBB'], } end let(:keys_file) do if os.match?(%r{redhat|centos|oracle|scientific}) '/etc/ntp/keys' - elsif os.match?(%r{solaris}) + elsif os.include?('solaris') '/etc/inet/ntp.keys' else '/etc/ntp.keys' end end it { is_expected.to contain_file(conf_path).with('content' => %r{trustedkey 1 2 3}) } it { is_expected.to contain_file(conf_path).with('content' => %r{controlkey 2}) } it { is_expected.to contain_file(conf_path).with('content' => %r{requestkey 3}) } it { is_expected.to contain_file(keys_file).with('content' => %r{1 M AAAABBBB}) } end end context 'when disabled' do let(:params) do { keys_enable: false, keys_trusted: [1, 2, 3], keys_controlkey: 2, keys_requestkey: 3, } end it { is_expected.not_to contain_file(conf_path).with('content' => %r{trustedkey 1 2 3}) } it { is_expected.not_to contain_file(conf_path).with('content' => %r{controlkey 2}) } it { is_expected.not_to contain_file(conf_path).with('content' => %r{requestkey 3}) } end describe 'noselect servers' do context 'when set' do let(:params) do { servers: ['a', 'b', 'c', 'd'], noselect_servers: ['a', 'b'], iburst_enable: false, } end it { is_expected.to contain_file(conf_path).with('content' => %r{server a (maxpoll 9 )?noselect\nserver b (maxpoll 9 )?noselect\nserver c( maxpoll 9)?\nserver d( maxpoll 9)?}) } end context 'when not set' do let(:params) do { servers: ['a', 'b', 'c', 'd'], noselect_servers: [], } end it { is_expected.not_to contain_file(conf_path).with('content' => %r{server a noselect}) } end end describe 'preferred servers' do context 'when set' do let(:params) do { servers: ['a', 'b', 'c', 'd'], preferred_servers: ['a', 'b'], iburst_enable: false, } end it { is_expected.to contain_file(conf_path).with('content' => %r{server a prefer( maxpoll 9)?\nserver b prefer( maxpoll 9)?\nserver c( maxpoll 9)?\nserver d( maxpoll 9)?}) } end context 'when not set' do let(:params) do { servers: ['a', 'b', 'c', 'd'], preferred_servers: [], } end it { is_expected.not_to contain_file(conf_path).with('content' => %r{server a prefer}) } end end describe 'restrict' do context 'when not set' do it 'does not contain restrict value' do is_expected.to contain_file(conf_path).without_content(%r{^restrict test restrict}) end end context 'when set' do let(:params) do { restrict: ['test restrict'], } end it 'contains restrict value' do is_expected.to contain_file(conf_path).with_content(%r{^restrict test restrict}) end end end describe 'slewalways' do context 'when absent' do if f[:kernel] == 'AIX' it 'on AIX does contain "slewalways no"' do is_expected.to contain_file(conf_path).with_content(%r{^slewalways no}) end else it 'on non-AIX does not contain a slewalways' do is_expected.to contain_file(conf_path).without_content(%r{^slewalways}) end end end context 'when "no"' do let(:params) do { slewalways: 'no', } end it 'does contain "slewalways no"' do is_expected.to contain_file(conf_path).with_content(%r{^slewalways no}) end end context 'when "yes"' do let(:params) do { slewalways: 'yes', } end it 'does contain "slewalways yes"' do is_expected.to contain_file(conf_path).with_content(%r{^slewalways yes}) end end end describe 'statistics' do context 'when not set' do it 'does not contain statistics' do is_expected.to contain_file(conf_path).without_content(%r{^filegen loopstats file loopstats type day enable}) end end context 'when set' do let(:params) do { statistics: ['loopstats'], disable_monitor: false, } end it 'contains statistics value' do is_expected.to contain_file(conf_path).with_content(%r{^filegen loopstats file loopstats type day enable}) is_expected.to contain_file(conf_path).with_content(%r{^statsdir /var/log/ntpstats}) end end end describe 'udlc' do context 'when not set' do it 'does not contain udlc' do is_expected.to contain_file(conf_path).without_content(%r{127.127.1.0}) end end context 'when set' do let(:params) do { udlc: true, } end it 'contains udlc value' do is_expected.to contain_file(conf_path).with_content(%r{127.127.1.0}) end end end describe 'udlc_stratum' do context 'when not set' do it 'does not contain udlc_stratum' do is_expected.to contain_file(conf_path).without_content(%r{stratum 10}) end end context 'when set' do let(:params) do { udlc: true, udlc_stratum: 10, } end it 'contains udlc_stratum value' do is_expected.to contain_file(conf_path).with_content(%r{stratum 10}) end end end end describe 'ntp::install' do let(:params) { { package_ensure: 'present', package_name: ['ntp'], package_manage: true } } it { is_expected.to contain_package('ntp').with( ensure: 'present', ) } describe 'should allow package ensure to be overridden' do let(:params) { { package_ensure: 'latest', package_name: ['ntp'], package_manage: true } } it { is_expected.to contain_package('ntp').with_ensure('latest') } end describe 'should allow the package name to be overridden' do let(:params) { { package_ensure: 'present', package_name: ['hambaby'], package_manage: true } } it { is_expected.to contain_package('hambaby') } end describe 'should allow the package to be unmanaged' do let(:params) { { package_manage: false, package_name: ['ntp'] } } it { is_expected.not_to contain_package('ntp') } end end describe 'ntp::service' do let(:params) do { service_manage: true, service_enable: true, service_ensure: 'running', service_name: 'ntp', } end describe 'with defaults' do it { is_expected.to contain_service('ntp').with( enable: true, ensure: 'running', name: 'ntp', hasstatus: true, hasrestart: true, ) } end describe 'authprov' do context 'when set to true' do let(:params) do { servers: ['a', 'b', 'c', 'd'], authprov: '/opt/novell/xad/lib64/libw32time.so 131072:4294967295 global', } end it 'contains authprov setting' do is_expected.to contain_file(conf_path).with('content' => %r{^authprov /opt/novell/xad/lib64/libw32time.so 131072:4294967295 global\n}) end end context 'when set to false' do let(:params) do { servers: ['a', 'b', 'c', 'd'], } end it 'does not contain a authprov line' do is_expected.not_to contain_file(conf_path).with('content' => %r{authprov }) end end end describe 'for physical machines' do let :facts do super().merge(is_virtual: false) end it 'disallows large clock skews' do is_expected.not_to contain_file(conf_path).with('content' => %r{tinker panic 0}) end end describe 'for virtual machines' do let :facts do super().merge(is_virtual: true) end it 'does not use local clock as a time source' do is_expected.not_to contain_file(conf_path).with('content' => %r{server.*127.127.1.0.*fudge.*127.127.1.0 stratum 10}) end it 'allows large clock skews' do is_expected.to contain_file(conf_path).with('content' => %r{tinker panic 0}) end end describe 'iburst_enable' do context 'when set to true' do let(:params) do { iburst_enable: true, } end it do is_expected.to contain_file(conf_path).with('content' => %r{iburst}) end end context 'when set to false' do let(:params) do { iburst_enable: false, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{iburst\n}) end end end describe 'leapfile' do context 'when set to true' do let(:params) do { servers: ['a', 'b', 'c', 'd'], leapfile: '/etc/leap-seconds.3629404800', } end it 'contains leapfile setting' do is_expected.to contain_file(conf_path).with('content' => %r{^leapfile \/etc\/leap-seconds\.3629404800\n}) end end context 'when set to false' do let(:params) do { servers: ['a', 'b', 'c', 'd'], } end it 'does not contain a leapfile line' do is_expected.not_to contain_file(conf_path).with('content' => %r{leapfile }) end end end describe 'logfile' do context 'when set to true' do let(:params) do { servers: ['a', 'b', 'c', 'd'], logfile: '/var/log/foobar.log', } end it 'contains logfile setting' do is_expected.to contain_file(conf_path).with('content' => %r{^logfile \/var\/log\/foobar\.log\n}) end end context 'when set to false' do let(:params) do { servers: ['a', 'b', 'c', 'd'], } end it 'does not contain a logfile line' do is_expected.not_to contain_file(conf_path).with('content' => %r{logfile }) end end end describe 'logconfig' do context 'when set to true' do let(:params) do { servers: ['a', 'b', 'c', 'd'], logconfig: '=syncall +peerinfo', } end it 'contains logconfig setting' do is_expected.to contain_file(conf_path).with('content' => %r{^logconfig =syncall \+peerinfo\n}) end end context 'when set to false' do let(:params) do { servers: ['a', 'b', 'c', 'd'], } end it 'does not contain a logconfig line' do is_expected.not_to contain_file(conf_path).with('content' => %r{logconfig }) end end end describe 'minpoll and maxpoll' do context 'when minpoll changed from default' do let(:params) do { minpoll: 6, } end it do is_expected.to contain_file(conf_path).with('content' => %r{minpoll 6}) end end context 'when maxpoll changed from default' do let(:params) do { maxpoll: 12, } end it do is_expected.to contain_file(conf_path).with('content' => %r{maxpoll 12\n}) end end context 'when minpoll and maxpoll changed from default simultaneously' do let(:params) do { minpoll: 6, maxpoll: 12, } end it do is_expected.to contain_file(conf_path).with('content' => %r{minpoll 6 maxpoll 12\n}) end end end describe 'ntpsigndsocket' do context 'when set to true' do let(:params) do { servers: ['a', 'b', 'c', 'd'], ntpsigndsocket: '/usr/local/samba/var/lib/ntp_signd', } end it 'contains ntpsigndsocket setting' do is_expected.to contain_file(conf_path).with('content' => %r{^ntpsigndsocket /usr/local/samba/var/lib/ntp_signd\n}) end end context 'when set to false' do let(:params) do { servers: ['a', 'b', 'c', 'd'], } end it 'does not contain a ntpsigndsocket line' do is_expected.not_to contain_file(conf_path).with('content' => %r{ntpsigndsocket }) end end end describe 'peers' do context 'when empty' do let(:params) do { peers: [], } end it 'does not contain a peer line' do is_expected.to contain_file(conf_path).without_content(%r{^peer}) end end context 'when set' do let(:params) do { peers: ['foo', 'bar'], } end it 'contains the peer lines - expectation one' do is_expected.to contain_file(conf_path).with_content(%r{peer foo}) end it 'contains the peer lines - expectation two' do is_expected.to contain_file(conf_path).with_content(%r{peer bar}) end end end describe 'pool' do context 'when empty' do let(:params) do { pool: [], } end it 'does not contain a pool line' do is_expected.to contain_file(conf_path).without_content(%r{^pool}) end end context 'when set' do let(:params) do { pool: ['foo', 'bar'], } end it 'contains the pool lines - expectation one' do is_expected.to contain_file(conf_path).with_content(%r{pool foo}) end it 'contains the pool lines - expectation two' do is_expected.to contain_file(conf_path).with_content(%r{pool bar}) end end end describe 'service_ensure' do describe 'when overridden' do let(:params) { { service_name: 'ntp', service_ensure: 'stopped' } } it { is_expected.to contain_service('ntp').with_ensure('stopped') } end end describe 'service_hasstatus' do describe 'when overridden' do let(:params) { { service_name: 'ntp', service_hasstatus: false } } it { is_expected.to contain_service('ntp').with_hasstatus(false) } end end describe 'service_hasrestart' do describe 'when overridden' do let(:params) { { service_name: 'ntp', service_hasrestart: false } } it { is_expected.to contain_service('ntp').with_hasrestart(false) } end end describe 'service_manage' do let(:params) do { service_manage: false, service_enable: true, service_ensure: 'running', service_name: 'ntpd', } end it 'when set to false' do is_expected.not_to contain_service('ntp').with('enable' => true, 'ensure' => 'running', 'name' => 'ntpd') end end describe 'tinker' do describe 'when set to false' do context 'when panic or stepout not overriden' do let(:params) do { tinker: false, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{^tinker }) end end context 'when panic overriden' do let(:params) do { tinker: false, panic: 257, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{^tinker }) end end context 'when stepout overriden' do let(:params) do { tinker: false, stepout: 5, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{^tinker }) end end context 'when panic and stepout overriden' do let(:params) do { tinker: false, panic: 257, stepout: 5, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{^tinker }) end end end describe 'when set to true' do context 'when only tinker set to true' do let(:params) do { tinker: true, } end it do is_expected.not_to contain_file(conf_path).with('content' => %r{^tinker }) end end context 'when panic changed' do let(:params) do { tinker: true, panic: 257, } end it do is_expected.to contain_file(conf_path).with('content' => %r{^tinker panic 257\n}) end end context 'when stepout changed' do let(:params) do { tinker: true, stepout: 5, } end it do is_expected.to contain_file(conf_path).with('content' => %r{^tinker stepout 5\n}) end end context 'when panic and stepout changed' do let(:params) do { tinker: true, panic: 257, stepout: 5, } end it do is_expected.to contain_file(conf_path).with('content' => %r{^tinker panic 257 stepout 5\n}) end end end end describe 'tos' do context 'when set to true' do let(:params) do { tos: true, } end it 'contains tos setting' do is_expected.to contain_file(conf_path).with('content' => %r{^tos}) end end context 'when set to false' do let(:params) do { tos: false, } end it 'does not contain tos setting' do is_expected.not_to contain_file(conf_path).with('content' => %r{^tos}) end end end end end end end