From e881718572e17b1a82703505a40141bb2e1e1b83 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 09:02:56 +0100 Subject: [PATCH 001/146] Update based on voxpupuli/modulesync_config 0.16.3 --- .github/CONTRIBUTING.md | 100 ++++ .github/ISSUE_TEMPLATE.md | 25 + .github/PULL_REQUEST_TEMPLATE.md | 7 + .gitignore | 28 +- .msync.yml | 1 + .rspec | 2 + .rubocop.yml | 512 ++++++++++++++++++ .sync.yml | 7 + .travis.yml | 78 +-- .yardopts | 1 + Gemfile | 76 ++- Rakefile | 74 +-- spec/acceptance/nodesets/centos-511-x64.yml | 15 + spec/acceptance/nodesets/centos-64-x64.yml | 11 - spec/acceptance/nodesets/centos-66-x64-pe.yml | 17 + spec/acceptance/nodesets/centos-66-x64.yml | 15 + spec/acceptance/nodesets/centos-72-x64.yml | 15 + spec/acceptance/nodesets/debian-78-x64.yml | 15 + spec/acceptance/nodesets/debian-82-x64.yml | 15 + spec/acceptance/nodesets/default.yml | 12 - spec/acceptance/nodesets/docker/centos-5.yml | 19 + spec/acceptance/nodesets/docker/centos-6.yml | 20 + spec/acceptance/nodesets/docker/centos-7.yml | 18 + spec/acceptance/nodesets/docker/debian-7.yml | 19 + spec/acceptance/nodesets/docker/debian-8.yml | 20 + .../nodesets/docker/ubuntu-12.04.yml | 19 + .../nodesets/docker/ubuntu-14.04.yml | 21 + .../nodesets/docker/ubuntu-16.04.yml | 19 + .../nodesets/ubuntu-server-1204-x64.yml | 15 + .../nodesets/ubuntu-server-12042-x64.yml | 12 - .../nodesets/ubuntu-server-1404-x64.yml | 15 + .../nodesets/ubuntu-server-1604-x64.yml | 15 + spec/classes/coverage_spec.rb | 3 + spec/default_facts.yml | 6 + spec/spec_helper.rb | 31 ++ 35 files changed, 1134 insertions(+), 144 deletions(-) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .msync.yml create mode 100644 .rspec create mode 100644 .rubocop.yml create mode 100644 .sync.yml create mode 100644 .yardopts create mode 100644 spec/acceptance/nodesets/centos-511-x64.yml delete mode 100644 spec/acceptance/nodesets/centos-64-x64.yml create mode 100644 spec/acceptance/nodesets/centos-66-x64-pe.yml create mode 100644 spec/acceptance/nodesets/centos-66-x64.yml create mode 100644 spec/acceptance/nodesets/centos-72-x64.yml create mode 100644 spec/acceptance/nodesets/debian-78-x64.yml create mode 100644 spec/acceptance/nodesets/debian-82-x64.yml delete mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/docker/centos-5.yml create mode 100644 spec/acceptance/nodesets/docker/centos-6.yml create mode 100644 spec/acceptance/nodesets/docker/centos-7.yml create mode 100644 spec/acceptance/nodesets/docker/debian-7.yml create mode 100644 spec/acceptance/nodesets/docker/debian-8.yml create mode 100644 spec/acceptance/nodesets/docker/ubuntu-12.04.yml create mode 100644 spec/acceptance/nodesets/docker/ubuntu-14.04.yml create mode 100644 spec/acceptance/nodesets/docker/ubuntu-16.04.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1204-x64.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-server-12042-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1604-x64.yml create mode 100644 spec/default_facts.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 000000000..5574191a6 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,100 @@ +This module has grown over time based on a range of contributions from +people using it. If you follow these contributing guidelines your patch +will likely make it into a release a little quicker. + +## Contributing + +Please note that this project is released with a Contributor Code of Conduct. +By participating in this project you agree to abide by its terms. +[Contributor Code of Conduct](https://voxpupuli.org/coc/). + +1. Fork the repo. + +1. Create a separate branch for your change. + +1. Run the tests. We only take pull requests with passing tests, and + documentation. + +1. Add a test for your change. Only refactoring and documentation + changes require no new tests. If you are adding functionality + or fixing a bug, please add a test. + +1. Squash your commits down into logical components. Make sure to rebase + against the current master. + +1. Push the branch to your fork and submit a pull request. + +Please be prepared to repeat some of these steps as our contributors review +your code. + +## Dependencies + +The testing and development tools have a bunch of dependencies, +all managed by [bundler](http://bundler.io/) according to the +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). + +By default the tests use a baseline version of Puppet. + +If you have Ruby 2.x or want a specific version of Puppet, +you must set an environment variable such as: + + export PUPPET_VERSION="~> 4.2.0" + +Install the dependencies like so... + + bundle install + +## Syntax and style + +The test suite will run [Puppet Lint](http://puppet-lint.com/) and +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to +check various syntax and style things. You can run these locally with: + + bundle exec rake lint + bundle exec rake validate + +It will also run some [Rubocop](http://batsov.com/rubocop/) tests +against it. You can run those locally ahead of time with: + + bundle exec rake rubocop + +## Running the unit tests + +The unit test suite covers most of the code, as mentioned above please +add tests if you're adding new functionality. If you've not used +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask +about how best to test your new feature. + +To run your all the unit tests + + bundle exec rake spec SPEC_OPTS='--format documentation' + +To run a specific spec test set the `SPEC` variable: + + bundle exec rake spec SPEC=spec/foo_spec.rb + +To run the linter, the syntax checker and the unit tests: + + bundle exec rake test + +## Integration tests + +The unit tests just check the code runs, not that it does exactly what +we want on a real machine. For that we're using +[beaker](https://github.com/puppetlabs/beaker). + +This fires up a new virtual machine (using vagrant) and runs a series of +simple tests against it after applying the module. You can run this +with: + + bundle exec rake acceptance + +This will run the tests on an Ubuntu 12.04 virtual machine. You can also +run the integration tests against Centos 6.6 with. + + BEAKER_set=centos-66-x64 bundle exec rake acceptances + +If you don't want to have to recreate the virtual machine every time you +can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will +at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile +for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..f6f4f86e7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,25 @@ + + +## Affected Puppet, Ruby, OS and module versions/distributions + +- Puppet: +- Ruby: +- Distribution: +- Module version: + +## How to reproduce (e.g Puppet code you use) + +## What are you seeing + +## What behaviour did you expect instead + +## Output log + +## Any additional information you'd like to impart diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..92f2e5983 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ + diff --git a/.gitignore b/.gitignore index 98cbccbb1..82426da6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,15 @@ -.*.sw? -pkg -spec/fixtures -.rspec_system -.vagrant -log/ - -# for a library or gem, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: +pkg/ Gemfile.lock -.ruby-version -.ruby-gemset - -# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -.rvmrc +Gemfile.local +vendor/ +.vendor/ +spec/fixtures/manifests/ +spec/fixtures/modules/ +.vagrant/ +.bundle/ +coverage/ +log/ +.idea/ +*.iml +.*.sw? +.yardoc/ diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 000000000..a7e7e88a6 --- /dev/null +++ b/.msync.yml @@ -0,0 +1 @@ +modulesync_config_version: '0.16.3' diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..8c18f1abd --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..f703c727c --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,512 @@ +require: rubocop-rspec +AllCops: + TargetRubyVersion: 1.9 + Include: + - ./**/*.rb + Exclude: + - files/**/* + - vendor/**/* + - .vendor/**/* + - pkg/**/* + - spec/fixtures/**/* +Lint/ConditionPosition: + Enabled: True + +Lint/ElseLayout: + Enabled: True + +Lint/UnreachableCode: + Enabled: True + +Lint/UselessComparison: + Enabled: True + +Lint/EnsureReturn: + Enabled: True + +Lint/HandleExceptions: + Enabled: True + +Lint/LiteralInCondition: + Enabled: True + +Lint/ShadowingOuterLocalVariable: + Enabled: True + +Lint/LiteralInInterpolation: + Enabled: True + +Style/HashSyntax: + Enabled: True + +Style/RedundantReturn: + Enabled: True + +Lint/AmbiguousOperator: + Enabled: True + +Lint/AssignmentInCondition: + Enabled: True + +Style/SpaceBeforeComment: + Enabled: True + +Style/AndOr: + Enabled: True + +Style/RedundantSelf: + Enabled: True + +Metrics/BlockLength: + Enabled: False + +# Method length is not necessarily an indicator of code quality +Metrics/MethodLength: + Enabled: False + +# Module length is not necessarily an indicator of code quality +Metrics/ModuleLength: + Enabled: False + +Style/WhileUntilModifier: + Enabled: True + +Lint/AmbiguousRegexpLiteral: + Enabled: True + +Lint/Eval: + Enabled: True + +Lint/BlockAlignment: + Enabled: True + +Lint/DefEndAlignment: + Enabled: True + +Lint/EndAlignment: + Enabled: True + +Lint/DeprecatedClassMethods: + Enabled: True + +Lint/Loop: + Enabled: True + +Lint/ParenthesesAsGroupedExpression: + Enabled: True + +Lint/RescueException: + Enabled: True + +Lint/StringConversionInInterpolation: + Enabled: True + +Lint/UnusedBlockArgument: + Enabled: True + +Lint/UnusedMethodArgument: + Enabled: True + +Lint/UselessAccessModifier: + Enabled: True + +Lint/UselessAssignment: + Enabled: True + +Lint/Void: + Enabled: True + +Style/AccessModifierIndentation: + Enabled: True + +Style/AccessorMethodName: + Enabled: True + +Style/Alias: + Enabled: True + +Style/AlignArray: + Enabled: True + +Style/AlignHash: + Enabled: True + +Style/AlignParameters: + Enabled: True + +Metrics/BlockNesting: + Enabled: True + +Style/AsciiComments: + Enabled: True + +Style/Attr: + Enabled: True + +Style/BracesAroundHashParameters: + Enabled: True + +Style/CaseEquality: + Enabled: True + +Style/CaseIndentation: + Enabled: True + +Style/CharacterLiteral: + Enabled: True + +Style/ClassAndModuleCamelCase: + Enabled: True + +Style/ClassAndModuleChildren: + Enabled: False + +Style/ClassCheck: + Enabled: True + +# Class length is not necessarily an indicator of code quality +Metrics/ClassLength: + Enabled: False + +Style/ClassMethods: + Enabled: True + +Style/ClassVars: + Enabled: True + +Style/WhenThen: + Enabled: True + +Style/WordArray: + Enabled: True + +Style/UnneededPercentQ: + Enabled: True + +Style/Tab: + Enabled: True + +Style/SpaceBeforeSemicolon: + Enabled: True + +Style/TrailingBlankLines: + Enabled: True + +Style/SpaceInsideBlockBraces: + Enabled: True + +Style/SpaceInsideBrackets: + Enabled: True + +Style/SpaceInsideHashLiteralBraces: + Enabled: True + +Style/SpaceInsideParens: + Enabled: True + +Style/LeadingCommentSpace: + Enabled: True + +Style/SpaceBeforeFirstArg: + Enabled: True + +Style/SpaceAfterColon: + Enabled: True + +Style/SpaceAfterComma: + Enabled: True + +Style/SpaceAfterMethodName: + Enabled: True + +Style/SpaceAfterNot: + Enabled: True + +Style/SpaceAfterSemicolon: + Enabled: True + +Style/SpaceAroundEqualsInParameterDefault: + Enabled: True + +Style/SpaceAroundOperators: + Enabled: True + +Style/SpaceBeforeBlockBraces: + Enabled: True + +Style/SpaceBeforeComma: + Enabled: True + +Style/CollectionMethods: + Enabled: True + +Style/CommentIndentation: + Enabled: True + +Style/ColonMethodCall: + Enabled: True + +Style/CommentAnnotation: + Enabled: True + +# 'Complexity' is very relative +Metrics/CyclomaticComplexity: + Enabled: False + +Style/ConstantName: + Enabled: True + +Style/Documentation: + Enabled: False + +Style/DefWithParentheses: + Enabled: True + +Style/PreferredHashMethods: + Enabled: True + +Style/DotPosition: + EnforcedStyle: trailing + +Style/DoubleNegation: + Enabled: True + +Style/EachWithObject: + Enabled: True + +Style/EmptyLineBetweenDefs: + Enabled: True + +Style/IndentArray: + Enabled: True + +Style/IndentHash: + Enabled: True + +Style/IndentationConsistency: + Enabled: True + +Style/IndentationWidth: + Enabled: True + +Style/EmptyLines: + Enabled: True + +Style/EmptyLinesAroundAccessModifier: + Enabled: True + +Style/EmptyLiteral: + Enabled: True + +# Configuration parameters: AllowURI, URISchemes. +Metrics/LineLength: + Enabled: False + +Style/MethodCallParentheses: + Enabled: True + +Style/MethodDefParentheses: + Enabled: True + +Style/LineEndConcatenation: + Enabled: True + +Style/TrailingWhitespace: + Enabled: True + +Style/StringLiterals: + Enabled: True + +Style/TrailingCommaInArguments: + Enabled: True + +Style/TrailingCommaInLiteral: + Enabled: True + +Style/GlobalVars: + Enabled: True + +Style/GuardClause: + Enabled: True + +Style/IfUnlessModifier: + Enabled: True + +Style/MultilineIfThen: + Enabled: True + +Style/NegatedIf: + Enabled: True + +Style/NegatedWhile: + Enabled: True + +Style/Next: + Enabled: True + +Style/SingleLineBlockParams: + Enabled: True + +Style/SingleLineMethods: + Enabled: True + +Style/SpecialGlobalVars: + Enabled: True + +Style/TrivialAccessors: + Enabled: True + +Style/UnlessElse: + Enabled: True + +Style/VariableInterpolation: + Enabled: True + +Style/VariableName: + Enabled: True + +Style/WhileUntilDo: + Enabled: True + +Style/EvenOdd: + Enabled: True + +Style/FileName: + Enabled: True + +Style/For: + Enabled: True + +Style/Lambda: + Enabled: True + +Style/MethodName: + Enabled: True + +Style/MultilineTernaryOperator: + Enabled: True + +Style/NestedTernaryOperator: + Enabled: True + +Style/NilComparison: + Enabled: True + +Style/FormatString: + Enabled: True + +Style/MultilineBlockChain: + Enabled: True + +Style/Semicolon: + Enabled: True + +Style/SignalException: + Enabled: True + +Style/NonNilCheck: + Enabled: True + +Style/Not: + Enabled: True + +Style/NumericLiterals: + Enabled: True + +Style/OneLineConditional: + Enabled: True + +Style/OpMethod: + Enabled: True + +Style/ParenthesesAroundCondition: + Enabled: True + +Style/PercentLiteralDelimiters: + Enabled: True + +Style/PerlBackrefs: + Enabled: True + +Style/PredicateName: + Enabled: True + +Style/RedundantException: + Enabled: True + +Style/SelfAssignment: + Enabled: True + +Style/Proc: + Enabled: True + +Style/RaiseArgs: + Enabled: True + +Style/RedundantBegin: + Enabled: True + +Style/RescueModifier: + Enabled: True + +# based on https://github.com/voxpupuli/modulesync_config/issues/168 +Style/RegexpLiteral: + EnforcedStyle: percent_r + Enabled: True + +Lint/UnderscorePrefixedVariableName: + Enabled: True + +Metrics/ParameterLists: + Enabled: False + +Lint/RequireParentheses: + Enabled: True + +Style/SpaceBeforeFirstArg: + Enabled: True + +Style/ModuleFunction: + Enabled: True + +Lint/Debugger: + Enabled: True + +Style/IfWithSemicolon: + Enabled: True + +Style/Encoding: + Enabled: True + +Style/BlockDelimiters: + Enabled: True + +Style/MultilineBlockLayout: + Enabled: True + +# 'Complexity' is very relative +Metrics/AbcSize: + Enabled: False + +# 'Complexity' is very relative +Metrics/PerceivedComplexity: + Enabled: False + +Lint/UselessAssignment: + Enabled: True + +Style/ClosingParenthesisIndentation: + Enabled: True + +# RSpec + +# We don't use rspec in this way +RSpec/DescribeClass: + Enabled: False + +# Example length is not necessarily an indicator of code quality +RSpec/ExampleLength: + Enabled: False + +RSpec/NamedSubject: + Enabled: False diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 000000000..928d81f77 --- /dev/null +++ b/.sync.yml @@ -0,0 +1,7 @@ +--- +.travis.yml: + secure: "qtLA1TPKaVgd9rvi0kkF2v0CP0QLls//lFHJ9IowTYNi5O+0dx7OxZCK3g4nkNWWbsujS464/YFJqVRWoXIeLIyFtfMKkaRAiuaukxOQqnzD+BsnpYYeo2zeZPCvMbB94+7G7JQ+jpuzlsHX6j+H6LQEj6+kXzd8NAj8rlygrL8XcFN3bA8XM/unCvqn2b2sduShExVl0mnNMIvZMHCbdrEzByXkz+FmyGYCay+feDIYbIbhzYLNnh6BcDkq24TxRmVOdEnUkPG6ZU0UJlNqBZB++zAIazR25NyX+b22/CFp6D6YJKkJvBNnywGUNNF21s4a6kPoEnUVBEO6yg5sDkKgp8nAvsmUnI8A1tfRFWKejxHZN3YqveY60xiNIUEHJU4MjEE6VVi9WpNW8CpJbfP/z3RtlU5n4ckSER7mb/ApxspUPJRzyMKjobDP12WU/bgXinzdNMu6PH9H56WkDpRNtIYnNhIAuirdfDr2Ok5z9/9yObUt/OQddM4wrOnMG7lyyUIzAO2OOJbIcOaZBedTKccpCu6k2mOkUHhMutf1D0bde5IGhrs7E54V2ZNxX5Dopv5eOrmVN2OxdcB9g8nmISxX6Tty/BNrTBvt7urthGjUJrjlnNE/K1595KmcWa6PGWUcYZyzdKeWqiA3+iWKSmnx1Ri0lsml5Z/a4QM=" +Gemfile: + optional: + ':test': + - gem: 'toml' diff --git a/.travis.yml b/.travis.yml index 74842aa2d..613b2c3c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,50 @@ -language: ruby +--- sudo: false -bundler_args: --without development -before_install: rm Gemfile.lock || true -rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 - - 2.1.0 -script: bundle exec rake test -env: - - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.2.0" - - PUPPET_GEM_VERSION="~> 3.3.0" - - PUPPET_GEM_VERSION="~> 3.4.0" - - PUPPET_GEM_VERSION="~> 3.5.0" - - PUPPET_GEM_VERSION="~> 3.6.0" - - PUPPET_GEM_VERSION="~> 3.7.0" +language: ruby +cache: bundler +bundler_args: --without system_tests development +before_install: + - bundle -v + - rm Gemfile.lock || true + - gem update --system + - gem update bundler + - gem --version + - bundle -v +script: + - 'bundle exec rake $CHECK' matrix: - allow_failures: - - rvm: 1.8.7 - exclude: + fast_finish: true + include: - rvm: 1.9.3 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 3.2.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 3.3.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 3.4.0" + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test + - rvm: 1.9.3 + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test + - rvm: 2.1.9 + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test + - rvm: 2.1.9 + env: PUPPET_VERSION="~> 4.0" CHECK=test + - rvm: 2.2.6 + env: PUPPET_VERSION="~> 4.0" CHECK=test + - rvm: 2.3.3 + env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes + - rvm: 2.3.3 + env: PUPPET_VERSION="~> 4.0" CHECK=rubocop + - rvm: 2.3.3 + env: PUPPET_VERSION="~> 4.0" CHECK=test + - rvm: 2.4.0-preview3 + env: PUPPET_VERSION="~> 4.0" CHECK=test + allow_failures: + - rvm: 2.4.0-preview3 +notifications: + email: false +deploy: + provider: puppetforge + user: puppet + password: + secure: "qtLA1TPKaVgd9rvi0kkF2v0CP0QLls//lFHJ9IowTYNi5O+0dx7OxZCK3g4nkNWWbsujS464/YFJqVRWoXIeLIyFtfMKkaRAiuaukxOQqnzD+BsnpYYeo2zeZPCvMbB94+7G7JQ+jpuzlsHX6j+H6LQEj6+kXzd8NAj8rlygrL8XcFN3bA8XM/unCvqn2b2sduShExVl0mnNMIvZMHCbdrEzByXkz+FmyGYCay+feDIYbIbhzYLNnh6BcDkq24TxRmVOdEnUkPG6ZU0UJlNqBZB++zAIazR25NyX+b22/CFp6D6YJKkJvBNnywGUNNF21s4a6kPoEnUVBEO6yg5sDkKgp8nAvsmUnI8A1tfRFWKejxHZN3YqveY60xiNIUEHJU4MjEE6VVi9WpNW8CpJbfP/z3RtlU5n4ckSER7mb/ApxspUPJRzyMKjobDP12WU/bgXinzdNMu6PH9H56WkDpRNtIYnNhIAuirdfDr2Ok5z9/9yObUt/OQddM4wrOnMG7lyyUIzAO2OOJbIcOaZBedTKccpCu6k2mOkUHhMutf1D0bde5IGhrs7E54V2ZNxX5Dopv5eOrmVN2OxdcB9g8nmISxX6Tty/BNrTBvt7urthGjUJrjlnNE/K1595KmcWa6PGWUcYZyzdKeWqiA3+iWKSmnx1Ri0lsml5Z/a4QM=" + on: + tags: true + # all_branches is required to use tags + all_branches: true + # Only publish the build marked with "DEPLOY_TO_FORGE" + condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts new file mode 100644 index 000000000..29c933bcf --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index d469af991..e3785e25d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,67 @@ -source "https://rubygems.org" +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +def location_for(place, fake_version = nil) + if place =~ /^(git[:@][^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end group :test do - gem "rake" - gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.6.0' - gem 'metadata-json-lint' - gem "puppet-lint" - gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' - gem "puppet-syntax" - gem "puppetlabs_spec_helper" - gem "toml" + gem 'puppetlabs_spec_helper', '~> 1.2.2', :require => false + gem 'rspec-puppet', '~> 2.5', :require => false + gem 'rspec-puppet-facts', :require => false + gem 'rspec-puppet-utils', :require => false + gem 'puppet-lint-absolute_classname-check', :require => false + gem 'puppet-lint-leading_zero-check', :require => false + gem 'puppet-lint-trailing_comma-check', :require => false + gem 'puppet-lint-version_comparison-check', :require => false + gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false + gem 'puppet-lint-unquoted_string-check', :require => false + gem 'puppet-lint-variable_contains_upcase', :require => false + gem 'metadata-json-lint', :require => false + gem 'puppet-blacksmith', :require => false + gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' + gem 'puppet-strings', '~> 0.99.0', :require => false + gem 'rubocop-rspec', '~> 1.6', :require => false if RUBY_VERSION >= '2.3.0' + gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0' + gem 'mocha', '>= 1.2.1', :require => false + gem 'coveralls', :require => false if RUBY_VERSION >= '2.0.0' + gem 'simplecov-console', :require => false if RUBY_VERSION >= '2.0.0' + gem 'toml', :require => false end group :development do - gem "travis" - gem "travis-lint" - gem "beaker" - gem "beaker-rspec" - gem "puppet-blacksmith" - gem "guard-rake" + gem 'travis', :require => false + gem 'travis-lint', :require => false + gem 'guard-rake', :require => false +end + +group :system_tests do + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + end + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end + gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false +end + + + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion.to_s, :require => false, :groups => [:test] +else + gem 'facter', :require => false, :groups => [:test] end + +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby diff --git a/Rakefile b/Rakefile index c94da6371..d00f2470a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,57 +1,33 @@ require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet-syntax/tasks/puppet-syntax' - -# These two gems aren't always present, for instance -# on Travis with --without development -begin - require 'puppet_blacksmith/rake_tasks' -rescue LoadError -end - -exclude_paths = [ - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] - -Rake::Task[:lint].clear -PuppetLint::RakeTask.new :lint do |config| - # Pattern of files to ignore - config.ignore_paths = exclude_paths - - # List of checks to disable - config.disable_checks = [ - '80chars', - 'autoloader_layout', - 'class_parameter_defaults', - 'class_inherits_from_params_class' - ] - - # Should the task fail if there were any warnings, defaults to false - config.fail_on_warnings = true - - # Print out the context for the problem, defaults to false - config.with_context = true - - # Format string for puppet-lint's output (see the puppet-lint help output - # for details - config.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" - - # Compare module layout relative to the module root - # config.relative = true -end - +require 'puppet_blacksmith/rake_tasks' +require 'voxpupuli/release/rake_tasks' +require 'puppet-strings/tasks' + +PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') + +exclude_paths = %w( + pkg/**/* + vendor/**/* + .vendor/**/* + spec/**/* +) +PuppetLint.configuration.ignore_paths = exclude_paths PuppetSyntax.exclude_paths = exclude_paths -desc "Run acceptance tests" +desc 'Run acceptance tests' RSpec::Core::RakeTask.new(:acceptance) do |t| t.pattern = 'spec/acceptance' end -desc "Run syntax, lint, and spec tests." -task :test => [ - :syntax, - :lint, - :spec, +desc 'Run tests metadata_lint, release_checks' +task test: [ + :metadata_lint, + :release_checks, ] +# vim: syntax=ruby diff --git a/spec/acceptance/nodesets/centos-511-x64.yml b/spec/acceptance/nodesets/centos-511-x64.yml new file mode 100644 index 000000000..089d646a5 --- /dev/null +++ b/spec/acceptance/nodesets/centos-511-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-511-x64: + roles: + - master + platform: el-5-x86_64 + box: puppetlabs/centos-5.11-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml deleted file mode 100644 index d19aa6951..000000000 --- a/spec/acceptance/nodesets/centos-64-x64.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - centos-64-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-64-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box - hypervisor : vagrant -CONFIG: - log_level: verbose - type: foss diff --git a/spec/acceptance/nodesets/centos-66-x64-pe.yml b/spec/acceptance/nodesets/centos-66-x64-pe.yml new file mode 100644 index 000000000..1e7aea6d4 --- /dev/null +++ b/spec/acceptance/nodesets/centos-66-x64-pe.yml @@ -0,0 +1,17 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-66-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box: puppetlabs/centos-6.6-64-puppet-enterprise + hypervisor: vagrant +CONFIG: + type: pe +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/centos-66-x64.yml b/spec/acceptance/nodesets/centos-66-x64.yml new file mode 100644 index 000000000..42455e7ae --- /dev/null +++ b/spec/acceptance/nodesets/centos-66-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-66-x64: + roles: + - master + platform: el-6-x86_64 + box: puppetlabs/centos-6.6-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/centos-72-x64.yml b/spec/acceptance/nodesets/centos-72-x64.yml new file mode 100644 index 000000000..85af89d3f --- /dev/null +++ b/spec/acceptance/nodesets/centos-72-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-72-x64: + roles: + - master + platform: el-7-x86_64 + box: puppetlabs/centos-7.2-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/debian-78-x64.yml b/spec/acceptance/nodesets/debian-78-x64.yml new file mode 100644 index 000000000..6ef6de8c8 --- /dev/null +++ b/spec/acceptance/nodesets/debian-78-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + debian-78-x64: + roles: + - master + platform: debian-7-amd64 + box: puppetlabs/debian-7.8-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/debian-82-x64.yml b/spec/acceptance/nodesets/debian-82-x64.yml new file mode 100644 index 000000000..9897a8fc7 --- /dev/null +++ b/spec/acceptance/nodesets/debian-82-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + debian-82-x64: + roles: + - master + platform: debian-8-amd64 + box: puppetlabs/debian-8.2-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 100644 index b392dab75..000000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - ubuntu-server-12042-x64: - roles: - - master - platform: ubuntu-server-12.04-amd64 - box: ubuntu-server-12042-x64-vbox4210-nocm - box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box - hypervisor: vagrant - -CONFIG: - log_level: verbose - type: foss diff --git a/spec/acceptance/nodesets/docker/centos-5.yml b/spec/acceptance/nodesets/docker/centos-5.yml new file mode 100644 index 000000000..c17bc3d00 --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-5.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-5-x64: + platform: el-5-x86_64 + hypervisor: docker + image: centos:5 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' + - 'sed -i -e "/mingetty/d" /etc/inittab' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-6.yml b/spec/acceptance/nodesets/docker/centos-6.yml new file mode 100644 index 000000000..d93f884cb --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-6.yml @@ -0,0 +1,20 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-6-x64: + platform: el-6-x86_64 + hypervisor: docker + image: centos:6 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm -rf /var/run/network/*' + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' + - 'rm /etc/init/tty.conf' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml new file mode 100644 index 000000000..886b1eeb3 --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-7.yml @@ -0,0 +1,18 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-7-x64: + platform: el-7-x86_64 + hypervisor: docker + image: centos:7 + docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-7.yml b/spec/acceptance/nodesets/docker/debian-7.yml new file mode 100644 index 000000000..071acbf90 --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-7.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + debian-7-x64: + platform: debian-7-amd64 + hypervisor: docker + image: debian:7 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'echo deb http://ftp.debian.org/debian wheezy-backports main >> /etc/apt/sources.list' + - 'apt-get update && apt-get install -y cron locales-all net-tools wget' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml new file mode 100644 index 000000000..500bee522 --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-8.yml @@ -0,0 +1,20 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + debian-8-x64: + platform: debian-8-amd64 + hypervisor: docker + image: debian:8 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'echo deb http://ftp.debian.org/debian jessie-backports main >> /etc/apt/sources.list' + - 'apt-get update && apt-get install -y cron locales-all net-tools wget' + - 'rm -f /usr/sbin/policy-rc.d' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-12.04.yml b/spec/acceptance/nodesets/docker/ubuntu-12.04.yml new file mode 100644 index 000000000..ab77cda48 --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-12.04.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-1204-x64: + platform: ubuntu-12.04-amd64 + hypervisor: docker + image: ubuntu:12.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml new file mode 100644 index 000000000..54d5e5a5b --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml @@ -0,0 +1,21 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-1404-x64: + platform: ubuntu-14.04-amd64 + hypervisor: docker + image: ubuntu:14.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm /usr/sbin/policy-rc.d' + - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml new file mode 100644 index 000000000..92a93cb73 --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-1604-x64: + platform: ubuntu-16.04-amd64 + hypervisor: docker + image: ubuntu:16.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ubuntu-server-1204-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1204-x64.yml new file mode 100644 index 000000000..29102c565 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1204-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-server-1204-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box: puppetlabs/ubuntu-12.04-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml deleted file mode 100644 index b392dab75..000000000 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ /dev/null @@ -1,12 +0,0 @@ -HOSTS: - ubuntu-server-12042-x64: - roles: - - master - platform: ubuntu-server-12.04-amd64 - box: ubuntu-server-12042-x64-vbox4210-nocm - box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box - hypervisor: vagrant - -CONFIG: - log_level: verbose - type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 000000000..054e65880 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box: puppetlabs/ubuntu-14.04-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml new file mode 100644 index 000000000..bc85e0e84 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-server-1604-x64: + roles: + - master + platform: ubuntu-16.04-amd64 + box: puppetlabs/ubuntu-16.04-64-nocm + hypervisor: vagrant +CONFIG: + type: foss +... +# vim: syntax=yaml diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb index 12513b83c..de446548b 100644 --- a/spec/classes/coverage_spec.rb +++ b/spec/classes/coverage_spec.rb @@ -1 +1,4 @@ +require 'rspec-puppet' + at_exit { RSpec::Puppet::Coverage.report! } +# vim: syntax=ruby diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 000000000..a3f52bfda --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,6 @@ +--- +concat_basedir: "/tmp" +ipaddress: "172.16.254.254" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" +selinux_config_mode: "disabled" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c6f56649..32709c814 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1 +1,32 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts + +if Dir.exist?(File.expand_path('../../lib', __FILE__)) && RUBY_VERSION !~ %r{^1.9} + require 'coveralls' + require 'simplecov' + require 'simplecov-console' + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console, + Coveralls::SimpleCov::Formatter + ] + SimpleCov.start do + track_files 'lib/**/*.rb' + add_filter '/spec' + add_filter '/vendor' + add_filter '/.vendor' + end +end + +RSpec.configure do |c| + default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version + } + default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) + default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) + c.default_facts = default_facts +end + +# vim: syntax=ruby From 2a5da8d6debc0493d427a08a84a40af7201445a1 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 09:06:02 +0100 Subject: [PATCH 002/146] Fix several Lint issues --- manifests/config.pp | 8 ++++---- manifests/init.pp | 10 +++++----- manifests/install.pp | 32 ++++++++++++++++---------------- manifests/service.pp | 8 ++++---- tests/init.pp | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 6974bb5c4..fa61d8f6d 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -9,7 +9,7 @@ $cfg = $::grafana::cfg file { $::grafana::cfg_location: - ensure => present, + ensure => file, content => template('grafana/config.ini.erb'), } } @@ -18,7 +18,7 @@ $cfg = $::grafana::cfg file { $::grafana::cfg_location: - ensure => present, + ensure => file, content => template('grafana/config.ini.erb'), } } @@ -26,7 +26,7 @@ $cfg = $::grafana::cfg file { "${::grafana::install_dir}/conf/custom.ini": - ensure => present, + ensure => file, content => template('grafana/config.ini.erb'), } } @@ -38,7 +38,7 @@ if $::grafana::ldap_cfg { $ldap_cfg = $::grafana::ldap_cfg file { '/etc/grafana/ldap.toml': - ensure => present, + ensure => file, content => inline_template("<%= require 'toml'; TOML::Generator.new(@ldap_cfg).body %>\n"), } } diff --git a/manifests/init.pp b/manifests/init.pp index ba14e9dd1..6b94aa0be 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -92,12 +92,12 @@ fail('cfg parameter must be a hash') } - class { 'grafana::install': } -> - class { 'grafana::config': } ~> - class { 'grafana::service': } + class { '::grafana::install': } -> + class { '::grafana::config': } ~> + class { '::grafana::service': } - contain 'grafana::install' - contain 'grafana::service' + contain '::grafana::install' + contain '::grafana::service' #Class['grafana'] } diff --git a/manifests/install.pp b/manifests/install.pp index e986b61e8..809b19230 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -18,43 +18,43 @@ default => $real_archive_source, } } - + case $::grafana::install_method { 'docker': { docker::image { 'grafana/grafana': image_tag => $::grafana::version, - require => Class['docker'] + require => Class['docker'], } } 'package': { case $::osfamily { 'Debian': { package { 'libfontconfig1': - ensure => present + ensure => present, } wget::fetch { 'grafana': source => $real_package_source, - destination => '/tmp/grafana.deb' + destination => '/tmp/grafana.deb', } package { $::grafana::package_name: ensure => present, provider => 'dpkg', source => '/tmp/grafana.deb', - require => [Wget::Fetch['grafana'],Package['libfontconfig1']] + require => [Wget::Fetch['grafana'],Package['libfontconfig1']], } } 'RedHat': { package { 'fontconfig': - ensure => present + ensure => present, } package { $::grafana::package_name: ensure => present, provider => 'rpm', source => $real_package_source, - require => Package['fontconfig'] + require => Package['fontconfig'], } } default: { @@ -66,12 +66,12 @@ case $::osfamily { 'Debian': { package { 'libfontconfig1': - ensure => present + ensure => present, } if ( $::grafana::manage_package_repo ){ if !defined( Class['apt'] ) { - class { 'apt': } + class { '::apt': } } apt::source { 'grafana': location => "https://packagecloud.io/grafana/${::grafana::repo_name}/debian", @@ -79,7 +79,7 @@ repos => 'main', key => { 'id' => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB', - 'source' => 'https://packagecloud.io/gpg.key' + 'source' => 'https://packagecloud.io/gpg.key', }, before => Package[$::grafana::package_name], } @@ -88,12 +88,12 @@ package { $::grafana::package_name: ensure => $::grafana::version, - require => Package['libfontconfig1'] + require => Package['libfontconfig1'], } } 'RedHat': { package { 'fontconfig': - ensure => present + ensure => present, } if ( $::grafana::manage_package_repo ){ @@ -109,7 +109,7 @@ package { $::grafana::package_name: ensure => "${::grafana::version}-${::grafana::rpm_iteration}", - require => Package['fontconfig'] + require => Package['fontconfig'], } } default: { @@ -123,7 +123,7 @@ if !defined(User['grafana']){ user { 'grafana': ensure => present, - home => $::grafana::install_dir + home => $::grafana::install_dir, } } @@ -131,7 +131,7 @@ ensure => directory, group => 'grafana', owner => 'grafana', - require => User['grafana'] + require => User['grafana'], } archive { '/tmp/grafana.tar.gz': @@ -143,7 +143,7 @@ user => 'grafana', group => 'grafana', cleanup => true, - require => File[$::grafana::install_dir] + require => File[$::grafana::install_dir], } } diff --git a/manifests/service.pp b/manifests/service.pp index 1a517c227..6b1b991c1 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -7,12 +7,12 @@ case $::grafana::install_method { 'docker': { $container = { - 'grafana' => $::grafana::container_params + 'grafana' => $::grafana::container_params, } $defaults = { image => "${::grafana::params::docker_image}:${::grafana::version}", - ports => $::grafana::params::docker_ports + ports => $::grafana::params::docker_ports, } create_resources(docker::run, $container, $defaults) @@ -21,7 +21,7 @@ service { $::grafana::service_name: ensure => running, enable => true, - subscribe => Package[$::grafana::package_name] + subscribe => Package[$::grafana::package_name], } } 'archive': { @@ -35,7 +35,7 @@ binary => "su - grafana -c '${service_path} -config=${service_config} -homepath=${::grafana::install_dir} web &'", hasrestart => false, hasstatus => false, - status => "ps -ef | grep ${::grafana::service_name} | grep -v grep" + status => "ps -ef | grep ${::grafana::service_name} | grep -v grep", } } } diff --git a/tests/init.pp b/tests/init.pp index 8043c17d1..ddf3cc944 100644 --- a/tests/init.pp +++ b/tests/init.pp @@ -9,4 +9,4 @@ # Learn more about module testing here: # http://docs.puppetlabs.com/guides/tests_smoke.html # -include grafana +include ::grafana From 5a12d93e0d64adea9d37b78c983d22c33a58fa12 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 10:03:02 +0100 Subject: [PATCH 003/146] Fix several Rubocop issues --- lib/puppet/provider/grafana.rb | 111 +++--- .../provider/grafana_dashboard/grafana.rb | 143 ++++---- .../provider/grafana_datasource/grafana.rb | 324 +++++++++--------- lib/puppet/type/grafana_dashboard.rb | 95 ++--- lib/puppet/type/grafana_datasource.rb | 134 ++++---- spec/acceptance/class_spec.rb | 13 +- spec/classes/grafana_spec.rb | 317 ++++++++++------- spec/spec_helper_acceptance.rb | 6 +- .../type/grafana_dashboard_type_spec.rb | 44 +-- .../type/grafana_datasource_type_spec.rb | 36 +- 10 files changed, 628 insertions(+), 595 deletions(-) diff --git a/lib/puppet/provider/grafana.rb b/lib/puppet/provider/grafana.rb index d1cfc47ab..2229f852b 100644 --- a/lib/puppet/provider/grafana.rb +++ b/lib/puppet/provider/grafana.rb @@ -17,72 +17,65 @@ require 'net/http' class Puppet::Provider::Grafana < Puppet::Provider - # Helper methods - def grafana_host - unless @grafana_host - @grafana_host = URI.parse(resource[:grafana_url]).host - end - @grafana_host - end + # Helper methods + def grafana_host + @grafana_host = URI.parse(resource[:grafana_url]).host unless @grafana_host + @grafana_host + end - def grafana_port - unless @grafana_port - @grafana_port = URI.parse(resource[:grafana_url]).port - end - @grafana_port - end + def grafana_port + @grafana_port = URI.parse(resource[:grafana_url]).port unless @grafana_port + @grafana_port + end - def grafana_scheme - unless @grafana_scheme - @grafana_scheme = URI.parse(resource[:grafana_url]).scheme - end - @grafana_scheme + def grafana_scheme + unless @grafana_scheme + @grafana_scheme = URI.parse(resource[:grafana_url]).scheme end + @grafana_scheme + end - # Return a Net::HTTP::Response object - def send_request(operation="GET", path="", data=nil, search_path={}) - request = nil - encoded_search = "" + # Return a Net::HTTP::Response object + def send_request(operation = 'GET', path = '', data = nil, search_path = {}) + request = nil + encoded_search = '' - if URI.respond_to?(:encode_www_form) - encoded_search = URI.encode_www_form(search_path) - else - # Ideally we would have use URI.encode_www_form but it isn't - # available with Ruby 1.8.x that ships with CentOS 6.5. - encoded_search = search_path.to_a.map do |x| - x.map{|y| CGI.escape(y.to_s)}.join('=') - end - encoded_search = encoded_search.join('&') - end - uri = URI.parse("%s://%s:%d%s?%s" % [ - self.grafana_scheme, self.grafana_host, self.grafana_port, - path, encoded_search]) + if URI.respond_to?(:encode_www_form) + encoded_search = URI.encode_www_form(search_path) + else + # Ideally we would have use URI.encode_www_form but it isn't + # available with Ruby 1.8.x that ships with CentOS 6.5. + encoded_search = search_path.to_a.map do |x| + x.map { |y| CGI.escape(y.to_s) }.join('=') + end + encoded_search = encoded_search.join('&') + end + uri = URI.parse format('%s://%s:%d%s?%s', grafana_scheme, grafana_host, grafana_port, path, encoded_search) - case operation.upcase - when 'POST' - request = Net::HTTP::Post.new(uri.request_uri) - request.body = data.to_json() - when 'PUT' - request = Net::HTTP::Put.new(uri.request_uri) - request.body = data.to_json() - when 'GET' - request = Net::HTTP::Get.new(uri.request_uri) - when 'DELETE' - request = Net::HTTP::Delete.new(uri.request_uri) - else - raise Puppet::Error, "Unsupported HTTP operation '%s'" % operation - end + case operation.upcase + when 'POST' + request = Net::HTTP::Post.new(uri.request_uri) + request.body = data.to_json + when 'PUT' + request = Net::HTTP::Put.new(uri.request_uri) + request.body = data.to_json + when 'GET' + request = Net::HTTP::Get.new(uri.request_uri) + when 'DELETE' + request = Net::HTTP::Delete.new(uri.request_uri) + else + raise Puppet::Error, format('Unsupported HTTP operation %s', operation) + end - request.content_type = 'application/json' - if resource[:grafana_user] and resource[:grafana_user] - request.basic_auth resource[:grafana_user], resource[:grafana_password] - end + request.content_type = 'application/json' + if resource[:grafana_user] && resource[:grafana_user] + request.basic_auth resource[:grafana_user], resource[:grafana_password] + end - return Net::HTTP.start(self.grafana_host, self.grafana_port, - :use_ssl => self.grafana_scheme == 'https', - :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| - http.request(request) - end + Net::HTTP.start(grafana_host, grafana_port, + use_ssl: grafana_scheme == 'https', + verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| + http.request(request) end + end end - diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index 30599b2fe..7f3157724 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -18,92 +18,79 @@ # Note: this class doesn't implement the self.instances and self.prefetch # methods because the Grafana API doesn't allow to retrieve the dashboards and # all their properties in a single call. -Puppet::Type.type(:grafana_dashboard).provide(:grafana, :parent => Puppet::Provider::Grafana) do - desc "Support for Grafana dashboards stored into Grafana" - - defaultfor :kernel => 'Linux' - - # Return the list of dashboards - def dashboards - response = self.send_request('GET', '/api/search', nil, {:q => '', :starred => false}) - if response.code != '200' - fail("Fail to retrieve the dashboards (HTTP response: %s/%s)" % - [response.code, response.body]) - end - - begin - JSON.parse(response.body) - rescue JSON::ParserError - fail("Fail to parse dashboards (HTTP response: %s/%s)" % - [response_code, response.body]) - end - end - - # Return the dashboard matching with the resource's title - def find_dashboard - if not self.dashboards.find{ |x| x['title'] == resource[:title] } - return - end - - response = self.send_request('GET', '/api/dashboards/db/%s' % self.slug) - if response.code != '200' - fail("Fail to retrieve dashboard '%s' (HTTP response: %s/%s)" % - [resource[:title], response.code, response.body]) - end - - begin - # Cache the dashboard's content - @dashboard = JSON.parse(response.body)["dashboard"] - rescue JSON::ParserError - fail("Fail to parse dashboard '%s': %s" % - [resource[:title], response.body]) - end - end - - def save_dashboard(dashboard) - data = { - :dashboard => dashboard.merge({ - 'title' => resource[:title], - 'id' => @dashboard ? @dashboard['id'] : nil, - 'version' => @dashboard ? @dashboard['version'] + 1 : 0 - }), - :overwrite => @dashboard != nil - } - - response = self.send_request('POST', '/api/dashboards/db', data) - if response.code != '200' - fail("Fail to save dashboard '%s' (HTTP response: %s/%s)" % - [resource[:name], response.code, response.body]) - end - end - - def slug - resource[:title].downcase.gsub(/[^\w\- ]/, '').gsub(/ +/, '-') - end +Puppet::Type.type(:grafana_dashboard).provide(:grafana, parent: Puppet::Provider::Grafana) do + desc 'Support for Grafana dashboards stored into Grafana' - def content - @dashboard - end + defaultfor kernel: 'Linux' - def content=(value) - self.save_dashboard(value) + # Return the list of dashboards + def dashboards + response = send_request('GET', '/api/search', nil, q: '', starred: false) + if response.code != '200' + raise format('Fail to retrieve the dashboards (HTTP response: %s/%s)', response.code, response.body) end - def create - self.save_dashboard(resource[:content]) + begin + JSON.parse(response.body) + rescue JSON::ParserError + raise format('Fail to parse dashboards (HTTP response: %s/%s)', response.code, response.body) end + end - def destroy - response = self.send_request('DELETE', '/api/dashboards/db/%s' % self.slug) + # Return the dashboard matching with the resource's title + def find_dashboard + return unless dashboards.find { |x| x['title'] == resource[:title] } - if response.code != '200' - raise Puppet::Error, "Failed to delete dashboard '%s' (HTTP "\ - "response: %s/'%s')" % [resource[:title], response.code, - response.body] - end + response = send_request format('GET, /api/dashboards/db/%s', slug) + if response.code != '200' + raise format('Fail to retrieve dashboard %s (HTTP response: %s/%s)', resource[:title], response.code, response.body) end - def exists? - self.find_dashboard() + begin + # Cache the dashboard's content + @dashboard = JSON.parse(response.body)['dashboard'] + rescue JSON::ParserError + raise format('Fail to parse dashboard %s: %s', resource[:title], response.body) end + end + + def save_dashboard(dashboard) + data = { + dashboard: dashboard.merge('title' => resource[:title], + 'id' => @dashboard ? @dashboard['id'] : nil, + 'version' => @dashboard ? @dashboard['version'] + 1 : 0), + overwrite: !@dashboard.nil? + } + + response = send_request('POST', '/api/dashboards/db', data) + return unless response.code != '200' + raise format('Fail to save dashboard %s (HTTP response: %s/%s', resource[:name], response.code, response.body) + end + + def slug + resource[:title].downcase.gsub(%r{[^\w\- ]}, '').gsub(%r{ +}, '-') + end + + def content + @dashboard + end + + def content=(value) + save_dashboard(value) + end + + def create + save_dashboard(resource[:content]) + end + + def destroy + response = send_request format('DELETE, /api/dashboards/db/%s', slug) + + return unless response.code != '200' + raise Puppet::Error, format('Failed to delete dashboard %s (HTTP response: %s/%s', resource[:title], response.code, response.body) + end + + def exists? + find_dashboard + end end diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 1e08b8805..94a74f4b5 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -16,177 +16,171 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'grafana')) -Puppet::Type.type(:grafana_datasource).provide(:grafana, :parent => Puppet::Provider::Grafana) do - desc "Support for Grafana datasources" +Puppet::Type.type(:grafana_datasource).provide(:grafana, parent: Puppet::Provider::Grafana) do + desc 'Support for Grafana datasources' - defaultfor :kernel => 'Linux' + defaultfor kernel: 'Linux' - def datasources - response = self.send_request('GET', '/api/datasources') - if response.code != '200' - fail("Fail to retrieve datasources (HTTP response: %s/%s)" % - [response.code, response.body]) - end - - begin - datasources = JSON.parse(response.body) - - datasources.collect{|x| x["id"]}.collect do |id| - response = self.send_request('GET', '/api/datasources/%s' % id) - if response.code != '200' - fail("Fail to retrieve datasource %d (HTTP response: %s/%s)" % - [id, response.code, response.body]) - end - - datasource = JSON.parse(response.body) - - { - :id => datasource["id"], - :name => datasource["name"], - :url => datasource["url"], - :type => datasource["type"], - :user => datasource["user"], - :password => datasource["password"], - :database => datasource["database"], - :access_mode => datasource["access"], - :is_default => datasource["isDefault"] ? :true : :false, - :json_data => datasource["jsonData"] - } - end - rescue JSON::ParserError - fail("Fail to parse response: %s" % response.body) - end - end - - def datasource - unless @datasource - @datasource = self.datasources.find { |x| x[:name] == resource[:name] } - end - @datasource - end - - def datasource=(value) - @datasource = value - end - - def type - self.datasource[:type] - end - - def type=(value) - resource[:type] = value - self.save_datasource() - end - - def url - self.datasource[:url] - end - - def url=(value) - resource[:url] = value - self.save_datasource() - end - - def access_mode - self.datasource[:access_mode] - end - - def access_mode=(value) - self.resource[:access_mode] = value - self.save_datasource() - end - - def database - self.datasource[:database] - end - - def database=(value) - resource[:database] = value - self.save_datasource() - end - - def user - self.datasource[:user] - end - - def user=(value) - resource[:user] = value - self.save_datasource() - end - - def password - self.datasource[:password] - end - - def password=(value) - resource[:password] = value - self.save_datasource() - end - - def is_default - self.datasource[:is_default] - end - - def is_default=(value) - resource[:is_default] = value - self.save_datasource() - end - - def json_data - self.datasource[:json_data] - end - - def json_data=(value) - resource[:json_data] = value - self.save_datasource() - end - - def save_datasource - data = { - :name => resource[:name], - :type => resource[:type], - :url => resource[:url], - :access => resource[:access_mode], - :database => resource[:database], - :user => resource[:user], - :password => resource[:password], - :isDefault => (resource[:is_default] == :true), - :jsonData => resource[:json_data], - } - - if self.datasource.nil? - response = self.send_request('POST', '/api/datasources', data) - else - data[:id] = self.datasource[:id] - response = self.send_request('PUT', '/api/datasources/%s' % self.datasource[:id], data) - end - - if response.code != '200' - fail("Failed to create save '%s' (HTTP response: %s/'%s')" % - [resource[:name], response.code, response.body]) - end - self.datasource = nil + def datasources + response = send_request('GET', '/api/datasources') + if response.code != '200' + raise format('Fail to retrieve datasources (HTTP response: %s/%s)', response.code, response.body) end - def delete_datasource - response = self.send_request('DELETE', '/api/datasources/%s' % self.datasource[:id]) + begin + datasources = JSON.parse(response.body) + datasources.map { |x| x['id'] }.map do |id| + response = send_request format('GET, /api/datasources/%s', id) if response.code != '200' - fail("Failed to delete datasource '%s' (HTTP response: %s/'%s')" % - [resource[:name], response.code, response.body]) + raise format('Fail to retrieve datasource %d (HTTP response: %s/%s)', id, response.code, response.body) end - self.datasource = nil - end - - def create - self.save_datasource() - end - def destroy - self.delete_datasource() - end - - def exists? - self.datasource - end + datasource = JSON.parse(response.body) + + { + id: datasource['id'], + name: datasource['name'], + url: datasource['url'], + type: datasource['type'], + user: datasource['user'], + password: datasource['password'], + database: datasource['database'], + access_mode: datasource['access'], + is_default: datasource['isDefault'] ? :true : :false, + json_data: datasource['jsonData'] + } + end + rescue JSON::ParserError + raise format('Fail to parse response: %s', response.body) + end + end + + def datasource + unless @datasource + @datasource = datasources.find { |x| x[:name] == resource[:name] } + end + @datasource + end + + attr_writer :datasource + + def type + datasource[:type] + end + + def type=(value) + resource[:type] = value + save_datasource + end + + def url + datasource[:url] + end + + def url=(value) + resource[:url] = value + save_datasource + end + + def access_mode + datasource[:access_mode] + end + + def access_mode=(value) + resource[:access_mode] = value + save_datasource + end + + def database + datasource[:database] + end + + def database=(value) + resource[:database] = value + save_datasource + end + + def user + datasource[:user] + end + + def user=(value) + resource[:user] = value + save_datasource + end + + def password + datasource[:password] + end + + def password=(value) + resource[:password] = value + save_datasource + end + + def default? + datasource[:is_default] + end + + def default=(value) + resource[:is_default] = value + save_datasource + end + + def json_data + datasource[:json_data] + end + + def json_data=(value) + resource[:json_data] = value + save_datasource + end + + def save_datasource + data = { + name: resource[:name], + type: resource[:type], + url: resource[:url], + access: resource[:access_mode], + database: resource[:database], + user: resource[:user], + password: resource[:password], + isDefault: (resource[:is_default] == :true), + jsonData: resource[:json_data] + } + + if datasource.nil? + response = send_request('POST', '/api/datasources', data) + else + data[:id] = datasource[:id] + response = send_request format('PUT, /api/datasources/%s', datasource[:id]) + end + + if response.code != '200' + raise format('Failed to create save %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) + end + self.datasource = nil + end + + def delete_datasource + response = send_request format('DELETE, /api/datasources/%s', datasource[:id]) + + if response.code != '200' + raise format('Failed to delete datasource %s (HTTP response: %s/%s', resource[:name], response.code, response.body) + end + self.datasource = nil + end + + def create + save_datasource + end + + def destroy + delete_datasource + end + + def exists? + datasource + end end diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index 51e2d2475..fceadb24d 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -14,65 +14,66 @@ require 'json' Puppet::Type.newtype(:grafana_dashboard) do - @doc = "Manage dashboards in Grafana" + @doc = 'Manage dashboards in Grafana' - ensurable + ensurable - newparam(:title, :namevar => true) do - desc "The title of the dashboard." - end + newparam(:title, namevar: true) do + desc 'The title of the dashboard.' + end - newproperty(:content) do - desc "The JSON representation of the dashboard." + newproperty(:content) do + desc 'The JSON representation of the dashboard.' - validate do |value| - begin - JSON.parse(value) - rescue JSON::ParserError - raise ArgumentError , "Invalid JSON string for content" - end - end + validate do |value| + begin + JSON.parse(value) + rescue JSON::ParserError + raise ArgumentError, 'Invalid JSON string for content' + end + end - munge do |value| - JSON.parse(value) - end + munge do |value| + JSON.parse(value) + end - def should_to_s(value) - if value.length > 12 - "#{value.to_s.slice(0,12)}..." - else - value - end - end + def should_to_s(value) + if value.length > 12 + "#{value.to_s.slice(0, 12)}..." + else + value + end + end - def is_to_s(value) - should_to_s(value) - end + def to_s(value) + should_to_s(value) end + end - newparam(:grafana_url) do - desc "The URL of the Grafana server" - defaultto "" + newparam(:grafana_url) do + desc 'The URL of the Grafana server' + defaultto '' - validate do |value| - unless value =~ /^https?:\/\// - raise ArgumentError , "'%s' is not a valid URL" % value - end - end + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end end + end - newparam(:grafana_user) do - desc "The username for the Grafana server (optional)" - end + newparam(:grafana_user) do + desc 'The username for the Grafana server (optional)' + end - newparam(:grafana_password) do - desc "The password for the Grafana server (optional)" - end + newparam(:grafana_password) do + desc 'The password for the Grafana server (optional)' + end - validate do - fail('content is required when ensure is present') if self[:ensure] == :present and self[:content].nil? - end - autorequire(:service) do - 'grafana-server' - end + # rubocop:disable Style/SignalException + validate do + fail('content is required when ensure is present') if self[:ensure] == :present && self[:content].nil? + end + autorequire(:service) do + 'grafana-server' + end end diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 4c4779afa..086386d35 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -13,82 +13,82 @@ # under the License. # Puppet::Type.newtype(:grafana_datasource) do - @doc = "Manage datasources in Grafana" + @doc = 'Manage datasources in Grafana' - ensurable + ensurable - newparam(:name, :namevar => true) do - desc "The name of the datasource." - end - - newparam(:grafana_url) do - desc "The URL of the Grafana server" - defaultto "" - - validate do |value| - unless value =~ /^https?:\/\// - raise ArgumentError , "'%s' is not a valid URL" % value - end - end - end - - newparam(:grafana_user) do - desc "The username for the Grafana server" - end - - newparam(:grafana_password) do - desc "The password for the Grafana server" - end - - newproperty(:url) do - desc "The URL of the datasource" + newparam(:name, namevar: true) do + desc 'The name of the datasource.' + end - validate do |value| - unless value =~ /^https?:\/\// - raise ArgumentError , "'%s' is not a valid URL" % value - end - end - end + newparam(:grafana_url) do + desc 'The URL of the Grafana server' + defaultto '' - newproperty(:type) do - desc "The datasource type" - newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus) + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end end + end - newproperty(:user) do - desc "The username for the datasource (optional)" - end + newparam(:grafana_user) do + desc 'The username for the Grafana server' + end - newproperty(:password) do - desc "The password for the datasource (optional)" - end - - newproperty(:database) do - desc "The name of the database (optional)" - end - - newproperty(:access_mode) do - desc "Whether the datasource is accessed directly or not by the clients" - newvalues(:direct, :proxy) - defaultto :direct - end - - newproperty(:is_default) do - desc "Whether the datasource is the default one" - newvalues(:true, :false) - defaultto :false - end + newparam(:grafana_password) do + desc 'The password for the Grafana server' + end - newproperty(:json_data) do - desc "Additional JSON data to configure the datasource (optional)" + newproperty(:url) do + desc 'The URL of the datasource' - validate do |value| - unless value.nil? or value.is_a?(Hash) then - raise ArgumentError , "json_data should be a Hash!" - end - end + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end end - autorequire(:service) do - 'grafana-server' + end + + newproperty(:type) do + desc 'The datasource type' + newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus) + end + + newproperty(:user) do + desc 'The username for the datasource (optional)' + end + + newproperty(:password) do + desc 'The password for the datasource (optional)' + end + + newproperty(:database) do + desc 'The name of the database (optional)' + end + + newproperty(:access_mode) do + desc 'Whether the datasource is accessed directly or not by the clients' + newvalues(:direct, :proxy) + defaultto :direct + end + + newproperty(:is_default) do + desc 'Whether the datasource is the default one' + newvalues(:true, :false) + defaultto :false + end + + newproperty(:json_data) do + desc 'Additional JSON data to configure the datasource (optional)' + + validate do |value| + unless value.nil? || value.is_a?(Hash) + raise ArgumentError, 'json_data should be a Hash!' + end end + end + autorequire(:service) do + 'grafana-server' + end end diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 1c5ad99af..759ad09f3 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,26 +1,25 @@ require 'spec_helper_acceptance' describe 'grafana class' do - context 'default parameters' do # Using puppet_apply as a helper - it 'should work idempotently with no errors' do + it 'works idempotently with no errors' do pp = <<-EOS class { 'grafana': } EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) end describe package('grafana') do - it { should be_installed } + it { is_expected.to be_installed } end describe service('grafana') do - it { should be_enabled } - it { should be_running } + it { is_expected.to be_enabled } + it { is_expected.to be_running } end end end diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 2f369c242..2790c6eea 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -2,271 +2,330 @@ describe 'grafana' do context 'supported operating systems' do - ['Debian', 'RedHat'].each do |osfamily| + %w(Debian RedHat).each do |osfamily| describe "grafana class without any parameters on #{osfamily}" do - let(:params) {{ }} - let(:facts) {{ - :osfamily => osfamily, - }} - - it { should contain_class('grafana::params') } - it { should contain_class('grafana::install').that_comes_before('grafana::config') } - it { should contain_class('grafana::config') } - it { should contain_class('grafana::service').that_subscribes_to('grafana::config') } - - it { should contain_service('grafana-server').with_ensure('running').with_enable(true) } - it { should contain_package('grafana').with_ensure('present') } + let(:params) { {} } + let(:facts) do + { + osfamily: osfamily + } + end + + it { is_expected.to contain_class('grafana::params') } + it { is_expected.to contain_class('grafana::install').that_comes_before('grafana::config') } + it { is_expected.to contain_class('grafana::config') } + it { is_expected.to contain_class('grafana::service').that_subscribes_to('grafana::config') } + + it { is_expected.to contain_service('grafana-server').with_ensure('running').with_enable(true) } + it { is_expected.to contain_package('grafana').with_ensure('present') } end end end context 'unsupported operating system' do describe 'grafana class without any parameters on Solaris/Nexenta' do - let(:facts) {{ - :osfamily => 'Solaris', - :operatingsystem => 'Nexenta', - }} + let(:facts) do + { + osfamily: 'Solaris', + operatingsystem: 'Nexenta' + } + end - it { expect { should contain_package('grafana') }.to raise_error(Puppet::Error, /Nexenta not supported/) } + it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{Nexenta not supported}) } end end context 'package install method' do context 'debian' do - let(:facts) {{ - :osfamily => 'Debian' - }} + let(:facts) do + { + osfamily: 'Debian' + } + end download_location = '/tmp/grafana.deb' describe 'use wget to fetch the package to a temporary location' do - it { should contain_wget__fetch('grafana').with_destination(download_location) } - it { should contain_wget__fetch('grafana').that_comes_before('Package[grafana]') } + it { is_expected.to contain_wget__fetch('grafana').with_destination(download_location) } + it { is_expected.to contain_wget__fetch('grafana').that_comes_before('Package[grafana]') } end describe 'install dependencies first' do - it { should contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } + it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } end describe 'install the package' do - it { should contain_package('grafana').with_provider('dpkg') } - it { should contain_package('grafana').with_source(download_location) } + it { is_expected.to contain_package('grafana').with_provider('dpkg') } + it { is_expected.to contain_package('grafana').with_source(download_location) } end end context 'redhat' do - let(:facts) {{ - :osfamily => 'RedHat' - }} + let(:facts) do + { + osfamily: 'RedHat' + } + end describe 'install dependencies first' do - it { should contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } + it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } end describe 'install the package' do - it { should contain_package('grafana').with_provider('rpm') } + it { is_expected.to contain_package('grafana').with_provider('rpm') } end end end context 'repo install method' do - let(:params) {{ - :install_method => 'repo', - :manage_package_repo => true - }} + let(:params) do + { + install_method: 'repo', + manage_package_repo: true + } + end context 'debian' do - let(:facts) {{ - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu' - }} + let(:facts) do + { + osfamily: 'Debian', + lsbdistid: 'Ubuntu' + } + end describe 'install apt repo dependencies first' do - it { should contain_class('apt') } - it { should contain_apt__source('grafana').with(:release => 'wheezy', :repos => 'main', :location => 'https://packagecloud.io/grafana/stable/debian') } - it { should contain_apt__source('grafana').that_comes_before('Package[grafana]') } + it { is_expected.to contain_class('apt') } + it { is_expected.to contain_apt__source('grafana').with(release: 'wheezy', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } + it { is_expected.to contain_apt__source('grafana').that_comes_before('Package[grafana]') } end describe 'install dependencies first' do - it { should contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } + it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } end describe 'install the package' do - it { should contain_package('grafana').with_ensure('2.5.0') } + it { is_expected.to contain_package('grafana').with_ensure('2.5.0') } end end context 'redhat' do - let(:facts) {{ - :osfamily => 'RedHat' - }} + let(:facts) do + { + osfamily: 'RedHat' + } + end describe 'yum repo dependencies first' do - it { should contain_yumrepo('grafana').with(:baseurl => 'https://packagecloud.io/grafana/stable/el/6/$basearch', :gpgkey => 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', :enabled => 1) } - it { should contain_yumrepo('grafana').that_comes_before('Package[grafana]') } + it { is_expected.to contain_yumrepo('grafana').with(baseurl: 'https://packagecloud.io/grafana/stable/el/6/$basearch', gpgkey: 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled: 1) } + it { is_expected.to contain_yumrepo('grafana').that_comes_before('Package[grafana]') } end describe 'install dependencies first' do - it { should contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } + it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } end describe 'install the package' do - it { should contain_package('grafana').with_ensure('2.5.0-1') } + it { is_expected.to contain_package('grafana').with_ensure('2.5.0-1') } end end end context 'repo install method without managing the package repo' do - let(:params) {{ - :install_method => 'repo', - :manage_package_repo => false, - :version => 'present' - }} + let(:params) do + { + install_method: 'repo', + manage_package_repo: false, + version: 'present' + } + end context 'debian' do - let(:facts) {{ - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu' - }} + let(:facts) do + { + osfamily: 'Debian', + lsbdistid: 'Ubuntu' + } + end - it { should compile.with_all_deps } + it { is_expected.to compile.with_all_deps } describe 'install dependencies first' do - it { should contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } + it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } end describe 'install the package' do - it { should contain_package('grafana').with_ensure('present') } + it { is_expected.to contain_package('grafana').with_ensure('present') } end end end context 'archive install method' do - let(:params) {{ - :install_method => 'archive' - }} + let(:params) do + { + install_method: 'archive' + } + end install_dir = '/usr/share/grafana' service_config = '/usr/share/grafana/conf/custom.ini' archive_source = 'https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0.linux-x64.tar.gz' describe 'extract archive to install_dir' do - it { should contain_archive('/tmp/grafana.tar.gz').with_ensure('present') } - it { should contain_archive('/tmp/grafana.tar.gz').with_source(archive_source) } - it { should contain_archive('/tmp/grafana.tar.gz').with_extract_path(install_dir) } + it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_ensure('present') } + it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_source(archive_source) } + it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_extract_path(install_dir) } end describe 'create grafana user' do - it { should contain_user('grafana').with_ensure('present').with_home(install_dir) } - it { should contain_user('grafana').that_comes_before('File[/usr/share/grafana]') } + it { is_expected.to contain_user('grafana').with_ensure('present').with_home(install_dir) } + it { is_expected.to contain_user('grafana').that_comes_before('File[/usr/share/grafana]') } end describe 'manage install_dir' do - it { should contain_file(install_dir).with_ensure('directory') } - it { should contain_file(install_dir).with_group('grafana').with_owner('grafana') } + it { is_expected.to contain_file(install_dir).with_ensure('directory') } + it { is_expected.to contain_file(install_dir).with_group('grafana').with_owner('grafana') } end describe 'configure grafana' do - it { should contain_file(service_config).with_ensure('present') } + it { is_expected.to contain_file(service_config).with_ensure('present') } end describe 'run grafana as service' do - it { should contain_service('grafana-server').with_ensure('running').with_provider('base') } - it { should contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } + it { is_expected.to contain_service('grafana-server').with_ensure('running').with_provider('base') } + it { is_expected.to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } end context 'when user already defined' do - let(:pre_condition) { + let(:pre_condition) do 'user{"grafana": ensure => present, }' - } + end describe 'do NOT create grafana user' do - it { should_not contain_user('grafana').with_ensure('present').with_home(install_dir) } + it { is_expected.not_to contain_user('grafana').with_ensure('present').with_home(install_dir) } end end context 'when service already defined' do - let(:pre_condition) { + let(:pre_condition) do 'service{"grafana-server": ensure => running, hasrestart => true, hasstatus => true, }' - } + end # let(:params) {{ :service_name => 'grafana-server'}} describe 'do NOT run service' do - it { should_not contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } + it { is_expected.not_to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } end end end context 'invalid parameters' do context 'cfg' do - let(:facts) {{ - :osfamily => 'Debian', - }} + let(:facts) do + { + osfamily: 'Debian' + } + end describe 'should raise an error when cfg parameter is not a hash' do - let(:params) {{ - :cfg => [], - }} + let(:params) do + { + cfg: [] + } + end - it { expect { should contain_package('grafana') }.to raise_error(Puppet::Error, /cfg parameter must be a hash/) } + it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{cfg parameter must be a hash}) } end describe 'should not raise an error when cfg parameter is a hash' do - let(:params) {{ - :cfg => {}, - }} + let(:params) do + { + cfg: {} + } + end - it { should contain_package('grafana') } + it { is_expected.to contain_package('grafana') } end end end context 'configuration file' do - let(:facts) {{ - :osfamily => 'Debian', - }} + let(:facts) do + { + osfamily: 'Debian' + } + end describe 'should not contain any configuration when cfg param is empty' do - it { should contain_file('/etc/grafana/grafana.ini').with_content("# This file is managed by Puppet, any changes will be overwritten\n\n") } + it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content("# This file is managed by Puppet, any changes will be overwritten\n\n") } end describe 'should correctly transform cfg param entries to Grafana configuration' do - let(:params) {{ - :cfg => { - 'app_mode' => 'production', - 'section' => { - 'string' => 'production', - 'number' => 8080, - 'boolean' => false, - 'empty' => '', + let(:params) do + { + cfg: { + 'app_mode' => 'production', + 'section' => { + 'string' => 'production', + 'number' => 8080, + 'boolean' => false, + 'empty' => '' + describe 'should correctly transform cfg param entries to Grafana configuration' do + let(:params) do + { + cfg: { + 'app_mode' => 'production', + 'section' => { + 'string' => 'production', + 'number' => 8080, + 'boolean' => false, + 'empty' => '' + } + }, + ldap_cfg: { + 'servers' => [ + { 'host' => 'server1', + 'use_ssl' => true, + 'search_filter' => '(sAMAccountName=%s)', + 'search_base_dns' => ['dc=domain1,dc=com'] }, + { 'host' => 'server2', + 'use_ssl' => true, + 'search_filter' => '(sAMAccountName=%s)', + 'search_base_dns' => ['dc=domain2,dc=com'] } + ], + 'servers.attributes' => { + 'name' => 'givenName', + 'surname' => 'sn', + 'username' => 'sAMAccountName', + 'member_of' => 'memberOf', + 'email' => 'email' + } + } + } }, - }, - :ldap_cfg => { - 'servers' => [ - { 'host' => 'server1', - 'use_ssl' => true, - 'search_filter' => '(sAMAccountName=%s)', - 'search_base_dns' => [ 'dc=domain1,dc=com' ], - }, - { 'host' => 'server2', - 'use_ssl' => true, - 'search_filter' => '(sAMAccountName=%s)', - 'search_base_dns' => [ 'dc=domain2,dc=com' ], - }, - ], - 'servers.attributes' => { - 'name' => 'givenName', - 'surname' => 'sn', - 'username' => 'sAMAccountName', - 'member_of' => 'memberOf', - 'email' => 'email', + ldap_cfg: { + 'servers' => [ + { 'host' => 'server1', + 'use_ssl' => true, + 'search_filter' => '(sAMAccountName=%s)', + 'search_base_dns' => ['dc=domain1,dc=com'] }, + { 'host' => 'server2', + 'use_ssl' => true, + 'search_filter' => '(sAMAccountName=%s)', + 'search_base_dns' => ['dc=domain2,dc=com'] } + ], + 'servers.attributes' => { + 'name' => 'givenName', + 'surname' => 'sn', + 'username' => 'sAMAccountName', + 'member_of' => 'memberOf', + 'email' => 'email' + } } - }, - }} + } + end expected = "# This file is managed by Puppet, any changes will be overwritten\n\n"\ "app_mode = production\n\n"\ @@ -276,7 +335,7 @@ "number = 8080\n"\ "string = production\n" - it { should contain_file('/etc/grafana/grafana.ini').with_content(expected) } + it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content(expected) } ldap_expected = "\n[[servers]]\n"\ "host = \"server1\"\n"\ @@ -298,7 +357,7 @@ "username = \"sAMAccountName\"\n"\ "\n" - it { should contain_file('/etc/grafana/ldap.toml').with_content(ldap_expected) } + it { is_expected.to contain_file('/etc/grafana/ldap.toml').with_content(ldap_expected) } end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 5c8573286..3d18c478b 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,7 +1,7 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' -hosts.each do |host| +hosts.each do |_host| # Install Puppet install_puppet end @@ -16,9 +16,9 @@ # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'grafana') + puppet_module_install(source: proj_root, module_name: 'grafana') hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1] end end end diff --git a/spec/unit/puppet/type/grafana_dashboard_type_spec.rb b/spec/unit/puppet/type/grafana_dashboard_type_spec.rb index de1325ab6..dc60cb3ae 100644 --- a/spec/unit/puppet/type/grafana_dashboard_type_spec.rb +++ b/spec/unit/puppet/type/grafana_dashboard_type_spec.rb @@ -14,46 +14,46 @@ require 'spec_helper' describe Puppet::Type.type(:grafana_dashboard) do - let(:gdashboard) { - described_class.new :name => "foo", :grafana_url => "http://example.com/", :content => "{}", :ensure => :present - } - context "when setting parameters" do - - it "should fail if grafana_url isn't HTTP-based" do - expect { - described_class.new :name => "foo", :grafana_url => "example.com", :content => "{}", :ensure => :present - }.to raise_error(Puppet::Error, /not a valid URL/) + let(:gdashboard) do + described_class.new name: 'foo', grafana_url: 'http://example.com/', content: '{}', ensure: :present + end + context 'when setting parameters' do + it "fails if grafana_url isn't HTTP-based" do + expect do + described_class.new name: 'foo', grafana_url: 'example.com', content: '{}', ensure: :present + end.to raise_error(Puppet::Error, %r{not a valid URL}) end - it "should fail if content isn't provided" do - expect { - described_class.new :name => "foo", :grafana_url => "http://example.com", :ensure => :present - }.to raise_error(Puppet::Error, /content is required/) + it "fails if content isn't provided" do + expect do + described_class.new name: 'foo', grafana_url: 'http://example.com', ensure: :present + end.to raise_error(Puppet::Error, %r{content is required}) end - it "should fail if content isn't JSON" do - expect { - described_class.new :name => "foo", :grafana_url => "http://example.com/", :content => "{invalid", :ensure => :present - }.to raise_error(Puppet::Error, /Invalid JSON/) + it "fails if content isn't JSON" do + expect do + described_class.new name: 'foo', grafana_url: 'http://example.com/', content: '{invalid', ensure: :present + end.to raise_error(Puppet::Error, %r{Invalid JSON}) end - it "should accept valid parameters" do + # rubocop:disable RSpec/MultipleExpectations + it 'accepts valid parameters' do expect(gdashboard[:name]).to eq('foo') expect(gdashboard[:grafana_url]).to eq('http://example.com/') expect(gdashboard[:content]).to eq({}) end - it "should autorequire the grafana-server for proper ordering" do + it 'autorequires the grafana-server for proper ordering' do catalog = Puppet::Resource::Catalog.new - service = Puppet::Type.type(:service).new(:name => "grafana-server") + service = Puppet::Type.type(:service).new(name: 'grafana-server') catalog.add_resource service catalog.add_resource gdashboard relationship = gdashboard.autorequire.find do |rel| - (rel.source.to_s == "Service[grafana-server]") and (rel.target.to_s == gdashboard.to_s) + (rel.source.to_s == 'Service[grafana-server]') && (rel.target.to_s == gdashboard.to_s) end expect(relationship).to be_a Puppet::Relationship end - it "should not autorequire the service it is not managed" do + it 'does not autorequire the service it is not managed' do catalog = Puppet::Resource::Catalog.new catalog.add_resource gdashboard expect(gdashboard.autorequire).to be_empty diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index 708d7c750..76397c748 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -14,40 +14,40 @@ require 'spec_helper' describe Puppet::Type.type(:grafana_datasource) do - let(:gdatasource) { - described_class.new :name => "foo", :grafana_url => "http://example.com", :url => 'http://influx.example.com' - } - context "when setting parameters" do - - it "should fail if grafana_url isn't HTTP-based" do - expect { - described_class.new :name => "foo", :grafana_url => "example.com", :content => "{}", :ensure => :present - }.to raise_error(Puppet::Error, /not a valid URL/) + let(:gdatasource) do + described_class.new name: 'foo', grafana_url: 'http://example.com', url: 'http://influx.example.com' + end + context 'when setting parameters' do + it "fails if grafana_url isn't HTTP-based" do + expect do + described_class.new name: 'foo', grafana_url: 'example.com', content: '{}', ensure: :present + end.to raise_error(Puppet::Error, %r{not a valid URL}) end - it "should fail if json_data isn't valid" do - expect { - described_class.new :name => "foo", :grafana_url => "http://example.com", :json_data => "invalid", :ensure => :present - }.to raise_error(Puppet::Error, /json_data should be a Hash/) + it "fails if json_data isn't valid" do + expect do + described_class.new name: 'foo', grafana_url: 'http://example.com', json_data: 'invalid', ensure: :present + end.to raise_error(Puppet::Error, %r{json_data should be a Hash}) end - it "should accept valid parameters" do + # rubocop:disable RSpec/MultipleExpectations + it 'accepts valid parameters' do expect(gdatasource[:name]).to eq('foo') expect(gdatasource[:grafana_url]).to eq('http://example.com') expect(gdatasource[:url]).to eq('http://influx.example.com') end - it "should autorequire the grafana-server for proper ordering" do + it 'autorequires the grafana-server for proper ordering' do catalog = Puppet::Resource::Catalog.new - service = Puppet::Type.type(:service).new(:name => "grafana-server") + service = Puppet::Type.type(:service).new(name: 'grafana-server') catalog.add_resource service catalog.add_resource gdatasource relationship = gdatasource.autorequire.find do |rel| - (rel.source.to_s == "Service[grafana-server]") and (rel.target.to_s == gdatasource.to_s) + (rel.source.to_s == 'Service[grafana-server]') && (rel.target.to_s == gdatasource.to_s) end expect(relationship).to be_a Puppet::Relationship end - it "should not autorequire the service it is not managed" do + it 'does not autorequire the service it is not managed' do catalog = Puppet::Resource::Catalog.new catalog.add_resource gdatasource expect(gdatasource.autorequire).to be_empty From c4686125c46f25d3c2c6413479e5dc2fb4512a0f Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 10:15:37 +0100 Subject: [PATCH 004/146] Fix open ended dependency for puppet/archive --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 2473131b2..73cb8c293 100644 --- a/metadata.json +++ b/metadata.json @@ -44,7 +44,7 @@ "dependencies": [ { "name": "puppet/archive", - "version_requirement": ">= 0.5.1" + "version_requirement": ">= 0.5.1 <2.0.0" }, { "name": "garethr/docker", From e4e15574a2679cee7c97686811fbf3753e21fbc9 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 12:06:36 +0100 Subject: [PATCH 005/146] Rename directory tests to examples --- {tests => examples}/init.pp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {tests => examples}/init.pp (100%) diff --git a/tests/init.pp b/examples/init.pp similarity index 100% rename from tests/init.pp rename to examples/init.pp From 3c9cefc3de69e5e78e7693fed9189a3427d13dad Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 15:58:34 +0100 Subject: [PATCH 006/146] Fix several Markdown issues --- README.md | 215 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 138 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index c556d45c9..e8b46b9b6 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,42 @@ -#grafana +# grafana [![Puppet Forge](http://img.shields.io/puppetforge/v/bfraser/grafana.svg)](https://forge.puppetlabs.com/bfraser/grafana) [![Build Status](http://img.shields.io/travis/bfraser/puppet-grafana.svg)](http://travis-ci.org/bfraser/puppet-grafana) -####Table of Contents +#### Table of Contents 1. [Overview](#overview) -2. [Module Description](#module-description) -3. [Setup](#setup) +1. [Module Description](#module-description) +1. [Setup](#setup) * [Beginning with Grafana](#beginning-with-grafana) -4. [Usage](#usage) +1. [Usage](#usage) * [Classes and Defined Types](#classes-and-defined-types) -5. [Limitations](#limitations) -6. [Copyright and License](#copyright-and-license) + * [Advanced usage](#advanced-usage) +1. [Limitations](#limitations) +1. [Copyright and License](#copyright-and-license) -##Overview +## Overview -This module installs Grafana, a dashboard and graph editor for Graphite, InfluxDB and OpenTSDB. +This module installs Grafana, a dashboard and graph editor for Graphite, +InfluxDB and OpenTSDB. -##Module Description +## Module Description -Version 2.x of this module is designed to work with version 2.x of Grafana. If you would like to continue to use Grafana 1.x, please use version 1.x of this module. +Version 2.x of this module is designed to work with version 2.x of Grafana. +If you would like to continue to use Grafana 1.x, please use version 1.x of +this module. -##Setup +## Setup This module will: -* Install Grafana using your preferred method: package (default), Docker container, or tar archive -* Allow you to override the version of Grafana to be installed, and / or the package source +* Install Grafana using your preferred method: package (default), Docker + container, or tar archive +* Allow you to override the version of Grafana to be installed, and / or the + package source * Perform basic configuration of Grafana -###Beginning with Grafana +### Beginning with Grafana To install Grafana with the default parameters: @@ -38,7 +44,8 @@ To install Grafana with the default parameters: class { 'grafana': } ``` -This assumes that you want to install Grafana using the 'package' method. To establish customized parameters: +This assumes that you want to install Grafana using the 'package' method. To +establish customized parameters: ```puppet class { 'grafana': @@ -46,32 +53,41 @@ This assumes that you want to install Grafana using the 'package' method. To est } ``` -##Usage +## Usage -###Classes and Defined Types +### Classes and Defined Types -####Class: `grafana` +#### Class: `grafana` -The Grafana module's primary class, `grafana`, guides the basic setup of Grafana on your system. +The Grafana module's primary class, `grafana`, guides the basic setup of Grafana +on your system. ```puppet class { 'grafana': } ``` + **Parameters within `grafana`:** -#####`archive_source` +##### `archive_source` -The download location of a tarball to use with the 'archive' install method. Defaults to the URL of the latest version of Grafana available at the time of module release. +The download location of a tarball to use with the 'archive' install method. +Defaults to the URL of the latest version of Grafana available at the time of +module release. -#####`cfg_location` +##### `cfg_location` -Configures the location to which the Grafana configuration is written. The default location is '/etc/grafana/grafana.ini'. +Configures the location to which the Grafana configuration is written. The +default location is '/etc/grafana/grafana.ini'. -#####`cfg` +##### `cfg` -Manages the Grafana configuration file. Grafana comes with its own default settings in a different configuration file (/opt/grafana/current/conf/defaults.ini), therefore this module does not supply any defaults. +Manages the Grafana configuration file. Grafana comes with its own default +settings in a different configuration file (/opt/grafana/current/conf/defaults.ini), +therefore this module does not supply any defaults. -This parameter only accepts a hash as its value. Keys with hashes as values will generate sections, any other values are just plain values. The example below will result in... +This parameter only accepts a hash as its value. Keys with hashes as values will +generate sections, any other values are just plain values. The example below will +result in... ```puppet class { 'grafana': @@ -117,14 +133,23 @@ allow_sign_up = false Some minor notes: - - If you want empty values, just use an empty string. - - Keys that contains dots (like auth.google) need to be quoted. - - The order of the keys in this hash is the same as they will be written to the configuration file. So settings that do not fall under a section will have to come before any sections in the hash. +* If you want empty values, just use an empty string. +* Keys that contains dots (like auth.google) need to be quoted. +* The order of the keys in this hash is the same as they will be written to the + configuration file. So settings that do not fall under a section will have to + come before any sections in the hash. + +#### `ldap_cfg` + +##### TOML note -####`ldap_cfg` +This option **requires** the [toml](https://github.com/toml-lang/toml) gem. Either +install the gem using puppet's native gem provider, +[puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/puppetserver_gem), +[pe_gem](https://forge.puppetlabs.com/puppetlabs/pe_gem), +[pe_puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/pe_puppetserver_gem), +or manually using one of the following: -#####TOML note -This option **requires** the [toml](https://github.com/toml-lang/toml) gem. Either install the gem using puppet's native gem provider, [puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/puppetserver_gem), [pe_gem](https://forge.puppetlabs.com/puppetlabs/pe_gem), [pe_puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/pe_puppetserver_gem), or manually using one of the following: ``` # apply or puppet-master gem install toml @@ -134,8 +159,10 @@ This option **requires** the [toml](https://github.com/toml-lang/toml) gem. Eith /opt/puppet/bin/puppetserver gem install toml ``` -#####cfg note -This option by itself is not sufficient to enable LDAP configuration as it must be enabled in the main configuration file. Enable it in cfg with: +##### cfg note + +This option by itself is not sufficient to enable LDAP configuration as it must +be enabled in the main configuration file. Enable it in cfg with: ``` 'auth.ldap' => { @@ -144,19 +171,25 @@ This option by itself is not sufficient to enable LDAP configuration as it must }, ``` -####Integer note -Puppet may convert integers into strings while parsing the hash and converting into toml. This can be worked around by appending 0 to an integer. +#### Integer note + +Puppet may convert integers into strings while parsing the hash and converting +into toml. This can be worked around by appending 0 to an integer. Example: + ``` port => 636+0, ``` -Manages the Grafana LDAP configuration file. This hash is directly translated into the corresponding TOML file, allowing for full flexibility in generating the configuration. +Manages the Grafana LDAP configuration file. This hash is directly translated +into the corresponding TOML file, allowing for full flexibility in generating +the configuration. -See the [LDAP documentation](http://docs.grafana.org/v2.1/installation/ldap/) for more information. +See the [LDAP documentation](http://docs.grafana.org/v2.1/installation/ldap/) +for more information. -####Example LDAP config +#### Example LDAP config ``` ldap_cfg => { @@ -180,14 +213,18 @@ ldap_cfg => { }, ``` +##### `container_cfg` -#####`container_cfg` - -Boolean to control whether a configuration file should be generated when using the 'docker' install method. If 'true', use the 'cfg' and 'cfg_location' parameters to control creation of the file. Defaults to false. +Boolean to control whether a configuration file should be generated when using +the 'docker' install method. If 'true', use the 'cfg' and 'cfg_location' +parameters to control creation of the file. Defaults to false. -#####`container_params` +##### `container_params` -A hash of parameters to use when creating the Docker container. For use with the 'docker' install method. Refer to documentation of the 'docker::run' resource in the [garethr-docker](https://github.com/garethr/garethr-docker) module for details of available parameters. Defaults to: +A hash of parameters to use when creating the Docker container. For use with the +'docker' install method. Refer to documentation of the 'docker::run' resource in +the [garethr-docker](https://github.com/garethr/garethr-docker) module for details +of available parameters. Defaults to: ```puppet container_params => { @@ -196,49 +233,69 @@ container_params => { } ``` -#####`data_dir` +##### `data_dir` The directory Grafana will use for storing its data. Defaults to '/var/lib/grafana'. -#####`install_dir` +##### `install_dir` -The installation directory to be used with the 'archive' install method. Defaults to '/usr/share/grafana'. +The installation directory to be used with the 'archive' install method. Defaults +to '/usr/share/grafana'. -#####`install_method` +##### `install_method` -Controls which method to use for installing Grafana. Valid options are: 'archive', 'docker', 'repo' and 'package'. The default is 'package'. If you wish to use the 'docker' installation method, you will need to include the 'docker' class in your node's manifest / profile. If you wish to use the 'repo' installation method, you can control whether the official Grafana repositories will be used. See `manage_package_repo` below for details. +Controls which method to use for installing Grafana. Valid options are: 'archive', +'docker', 'repo' and 'package'. The default is 'package'. If you wish to use the +'docker' installation method, you will need to include the 'docker' class in your +node's manifest / profile. If you wish to use the 'repo' installation method, you +can control whether the official Grafana repositories will be used. See +`manage_package_repo` below for details. -#####`manage_package_repo` +##### `manage_package_repo` -Boolean. When using the 'repo' installation method, controls whether the official Grafana repositories are enabled on your host. If true, the official Grafana repositories will be enabled. If false, the module assumes you are managing your own package repository and will not set one up for you. Defaults to true. +Boolean. When using the 'repo' installation method, controls whether the official +Grafana repositories are enabled on your host. If true, the official Grafana +repositories will be enabled. If false, the module assumes you are managing your +own package repository and will not set one up for you. Defaults to true. -#####`package_name` +##### `package_name` -The name of the package managed with the 'package' install method. Defaults to 'grafana'. +The name of the package managed with the 'package' install method. Defaults to +'grafana'. -#####`package_source` +##### `package_source` -The download location of a package to be used with the 'package' install method. Defaults to the URL of the latest version of Grafana available at the time of module release. +The download location of a package to be used with the 'package' install method. +Defaults to the URL of the latest version of Grafana available at the time of +module release. -#####`rpm_iteration` +##### `rpm_iteration` -Used when installing Grafana from package ('package' or 'repo' install methods) on Red Hat based systems. Defaults to '1'. It should not be necessary to change this in most cases. +Used when installing Grafana from package ('package' or 'repo' install methods) +on Red Hat based systems. Defaults to '1'. It should not be necessary to change +this in most cases. -#####`service_name` +##### `service_name` -The name of the service managed with the 'archive' and 'package' install methods. Defaults to 'grafana-server'. +The name of the service managed with the 'archive' and 'package' install methods. +Defaults to 'grafana-server'. -#####`version` +##### `version` -The version of Grafana to install and manage. Defaults to the latest version of Grafana available at the time of module release. +The version of Grafana to install and manage. Defaults to the latest version of +Grafana available at the time of module release. -##Advanced usage: +### Advanced usage -The archive install method will create the user and a "command line" service by default. -There are no extra parameters to manage user/service for archive. However, both check to see if they are defined before defining. This way you can create your own user and service with your own specifications. (sort of overriding) -The service can be a bit tricky, in this example below, the class sensu_install::grafana::service creates a startup script and a service{'grafana-server':} +The archive install method will create the user and a "command line" service by +default. There are no extra parameters to manage user/service for archive. +However, both check to see if they are defined before defining. This way you can +create your own user and service with your own specifications. (sort of overriding) +The service can be a bit tricky, in this example below, the class +sensu_install::grafana::service creates a startup script and a service{'grafana-server':} Example: + ```puppet user { 'grafana': ensure => present, @@ -260,11 +317,11 @@ Example: ``` -####Custom Types and Providers +#### Custom Types and Providers The module includes two custom types: `grafana_dashboard` and `grafana_datasource` -#####`grafana_dashboard` +##### `grafana_dashboard` In order to use the dashboard resource, add the following to your manifest: @@ -278,9 +335,10 @@ grafana_dashboard { 'example_dashboard': ``` `content` must be valid JSON, and is parsed before imported. -`grafana_user` and `grafana_password` are optional, and required when authentication is enabled in Grafana. +`grafana_user` and `grafana_password` are optional, and required when +authentication is enabled in Grafana. -#####`grafana_datasource` +##### `grafana_datasource` In order to use the datasource resource, add the following to your manifest: @@ -302,16 +360,19 @@ grafana_datasource { 'influxdb': Available types are: influxdb, elasticsearch, graphite, kairosdb, opentsdb, prometheus -Access mode determines how Grafana connects to the datasource, either `direct` from the browser, or `proxy` to send requests via grafana. - -Authentication is optional, as is `database`; additional `json_data` can be provided to allow custom configuration options. +Access mode determines how Grafana connects to the datasource, either `direct` +from the browser, or `proxy` to send requests via grafana. +Authentication is optional, as is `database`; additional `json_data` can be +provided to allow custom configuration options. -##Limitations +## Limitations -This module has been tested on Ubuntu 14.04, using each of the 'archive', docker' and 'package' installation methods. Other configurations should work with minimal, if any, additional effort. +This module has been tested on Ubuntu 14.04, using each of the 'archive', 'docker' +and 'package' installation methods. Other configurations should work with minimal, +if any, additional effort. -##Copyright and License +## Copyright and License Copyright (C) 2015 Bill Fraser @@ -321,7 +382,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, From ee195967a099d3a235a61d2eb0d125f15ec416bf Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 16:04:43 +0100 Subject: [PATCH 007/146] Fix namespace --- README.md | 8 +++-- metadata.json | 87 ++++++++++++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index e8b46b9b6..362c70c09 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # grafana -[![Puppet Forge](http://img.shields.io/puppetforge/v/bfraser/grafana.svg)](https://forge.puppetlabs.com/bfraser/grafana) -[![Build Status](http://img.shields.io/travis/bfraser/puppet-grafana.svg)](http://travis-ci.org/bfraser/puppet-grafana) +[![Build Status](https://travis-ci.org/voxpupuli/puppet-grafana.png?branch=master)](https://travis-ci.org/voxpupuli/puppet-grafana) +[![Code Coverage](https://coveralls.io/repos/github/voxpupuli/puppet-grafana/badge.svg?branch=master)](https://coveralls.io/github/voxpupuli/puppet-grafana) +[![Puppet Forge](https://img.shields.io/puppetforge/v/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana) +[![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana) +[![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana) +[![Puppet Forge - scores](https://img.shields.io/puppetforge/f/puppet/grafana.svg)](https://forge.puppetlabs.com/puppet/grafana) #### Table of Contents diff --git a/metadata.json b/metadata.json index 73cb8c293..13d407ce1 100644 --- a/metadata.json +++ b/metadata.json @@ -1,67 +1,74 @@ { - "name": "bfraser-grafana", + "name": "puppet-grafana", "version": "2.5.0", - "author": "bfraser", + "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", - "source": "https://github.com/bfraser/puppet-grafana.git", - "project_page": "https://github.com/bfraser/puppet-grafana", - "issues_url": "https://github.com/bfraser/puppet-grafana/issues", - "tags": [ - "grafana", - "graphite", - "influxdb", - "monitoring" - ], - "operatingsystem_support": [ + "source": "https://github.com/voxpupuli/puppet-grafana.git", + "project_page": "https://github.com/voxpupuli/puppet-grafana", + "issue_url": "https://github.com/voxpupuli/puppet-grafana/issues", + "dependencies": [ { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ "6.0" ] + "name": "garethr/docker", + "version_requirement": ">= 3.5.0 <6.0.0" }, { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ "6.0" ] + "name": "maestrodev/wget", + "version_requirement": ">= 1.6.0 <2.0.0" }, { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ "14.04" ] + "name": "puppet/archive", + "version_requirement": ">= 0.5.1 <2.0.0" }, { - "operatingsystem": "Debian", - "operatingsystemrelease": [ "7.0" ] - } - ], - "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.2.0" + "name": "puppetlabs/apt", + "version_requirement": ">=2.0.0 <3.0.0" }, { - "name": "puppet", - "version_requirement": ">= 3.4.0" + "name": "puppetlabs/stdlib", + "version_requirement": ">=3.2.0 <5.0.0" } ], - "dependencies": [ + "operatingsystem_support": [ { - "name": "puppet/archive", - "version_requirement": ">= 0.5.1 <2.0.0" + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "7" + ] }, { - "name": "garethr/docker", - "version_requirement": ">= 3.5.0 <6.0.0" + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "14.04" + ] }, { - "name": "maestrodev/wget", - "version_requirement": ">= 1.6.0 <2.0.0" + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "6" + ] }, { - "name": "puppetlabs-stdlib", - "version_requirement": ">=3.2.0 <5.0.0" + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "6" + ] + } + ], + "requirements": [ + { + "name": "pe", + "version_requirement": ">= 3.2.0" }, { - "name": "puppetlabs-apt", - "version_requirement": ">=2.0.0 <3.0.0" + "name": "puppet", + "version_requirement": ">= 3.4.0" } - + ], + "tags": [ + "grafana", + "graphite", + "influxdb", + "monitoring" ] } From 0ccaac83c2430b3e52e40c6743418a1847416d86 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 17:49:57 +0100 Subject: [PATCH 008/146] Add support for rspec-puppet-facts --- spec/classes/grafana_spec.rb | 499 +++++++++++++++-------------------- 1 file changed, 206 insertions(+), 293 deletions(-) diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 2790c6eea..8d9b2ea72 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -1,277 +1,209 @@ require 'spec_helper' describe 'grafana' do - context 'supported operating systems' do - %w(Debian RedHat).each do |osfamily| - describe "grafana class without any parameters on #{osfamily}" do - let(:params) { {} } - let(:facts) do - { - osfamily: osfamily - } - end - - it { is_expected.to contain_class('grafana::params') } - it { is_expected.to contain_class('grafana::install').that_comes_before('grafana::config') } - it { is_expected.to contain_class('grafana::config') } - it { is_expected.to contain_class('grafana::service').that_subscribes_to('grafana::config') } - - it { is_expected.to contain_service('grafana-server').with_ensure('running').with_enable(true) } - it { is_expected.to contain_package('grafana').with_ensure('present') } - end - end - end - - context 'unsupported operating system' do - describe 'grafana class without any parameters on Solaris/Nexenta' do + on_supported_os.each do |os, facts| + context "on #{os}" do let(:facts) do - { - osfamily: 'Solaris', - operatingsystem: 'Nexenta' - } + facts end - it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{Nexenta not supported}) } - end - end - - context 'package install method' do - context 'debian' do - let(:facts) do - { - osfamily: 'Debian' - } - end - - download_location = '/tmp/grafana.deb' - - describe 'use wget to fetch the package to a temporary location' do - it { is_expected.to contain_wget__fetch('grafana').with_destination(download_location) } - it { is_expected.to contain_wget__fetch('grafana').that_comes_before('Package[grafana]') } - end - - describe 'install dependencies first' do - it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } - end - - describe 'install the package' do - it { is_expected.to contain_package('grafana').with_provider('dpkg') } - it { is_expected.to contain_package('grafana').with_source(download_location) } - end - end - - context 'redhat' do - let(:facts) do - { - osfamily: 'RedHat' - } - end - - describe 'install dependencies first' do - it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } + context 'with default values' do + it { is_expected.to compile } + it { is_expected.to contain_anchor('grafana::begin') } + it { is_expected.to contain_class('grafana::params') } + it { is_expected.to contain_class('grafana::install') } + it { is_expected.to contain_class('grafana::config') } + it { is_expected.to contain_class('grafana::service') } + it { is_expected.to contain_anchor('grafana::end') } end - describe 'install the package' do - it { is_expected.to contain_package('grafana').with_provider('rpm') } + context 'with parameter install_method is set to package' do + case facts[:osfamily] + when 'Debian' + download_location = '/tmp/grafana.deb' + + describe 'use wget to fetch the package to a temporary location' do + it { is_expected.to contain_wget__fetch('grafana').with_destination(download_location) } + it { is_expected.to contain_wget__fetch('grafana').that_comes_before('Package[grafana]') } + end + + describe 'install dependencies first' do + it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } + end + + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_provider('dpkg') } + it { is_expected.to contain_package('grafana').with_source(download_location) } + end + when 'RedHat' + describe 'install dependencies first' do + it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } + end + + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_provider('rpm') } + end + end end - end - end - context 'repo install method' do - let(:params) do - { - install_method: 'repo', - manage_package_repo: true - } - end - - context 'debian' do - let(:facts) do - { - osfamily: 'Debian', - lsbdistid: 'Ubuntu' - } - end + context 'with parameter install_method is set to repo' do + let(:params) do + { + install_method: 'repo' + } + end - describe 'install apt repo dependencies first' do - it { is_expected.to contain_class('apt') } - it { is_expected.to contain_apt__source('grafana').with(release: 'wheezy', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } - it { is_expected.to contain_apt__source('grafana').that_comes_before('Package[grafana]') } + case facts[:osfamily] + when 'Debian' + describe 'install apt repo dependencies first' do + it { is_expected.to contain_class('apt') } + it { is_expected.to contain_apt__source('grafana').with(release: 'wheezy', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } + it { is_expected.to contain_apt__source('grafana').that_comes_before('Package[grafana]') } + end + + describe 'install dependencies first' do + it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } + end + + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_ensure('2.5.0') } + end + when 'RedHat' + describe 'yum repo dependencies first' do + it { is_expected.to contain_yumrepo('grafana').with(baseurl: 'https://packagecloud.io/grafana/stable/el/6/$basearch', gpgkey: 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled: 1) } + it { is_expected.to contain_yumrepo('grafana').that_comes_before('Package[grafana]') } + end + + describe 'install dependencies first' do + it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } + end + + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_ensure('2.5.0-1') } + end + end end - describe 'install dependencies first' do - it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } - end + context 'with parameter install_method is set to repo and manage_package_repo is set to false' do + let(:params) do + { + install_method: 'repo', + manage_package_repo: false, + version: 'present' + } + end - describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('2.5.0') } + case facts[:osfamily] + when 'Debian' + describe 'install dependencies first' do + it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } + end + + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_ensure('present') } + end + when 'RedHat' + describe 'install dependencies first' do + it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } + end + + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_ensure('present') } + end + end end - end - context 'redhat' do - let(:facts) do - { - osfamily: 'RedHat' - } - end + context 'with parameter install_method is set to archive' do + let(:params) do + { + install_method: 'archive' + } + end - describe 'yum repo dependencies first' do - it { is_expected.to contain_yumrepo('grafana').with(baseurl: 'https://packagecloud.io/grafana/stable/el/6/$basearch', gpgkey: 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled: 1) } - it { is_expected.to contain_yumrepo('grafana').that_comes_before('Package[grafana]') } - end + install_dir = '/usr/share/grafana' + service_config = '/usr/share/grafana/conf/custom.ini' + archive_source = 'https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0.linux-x64.tar.gz' - describe 'install dependencies first' do - it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } - end + describe 'extract archive to install_dir' do + it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_ensure('present') } + it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_source(archive_source) } + it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_extract_path(install_dir) } + end - describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('2.5.0-1') } - end - end - end + describe 'create grafana user' do + it { is_expected.to contain_user('grafana').with_ensure('present').with_home(install_dir) } + it { is_expected.to contain_user('grafana').that_comes_before('File[/usr/share/grafana]') } + end - context 'repo install method without managing the package repo' do - let(:params) do - { - install_method: 'repo', - manage_package_repo: false, - version: 'present' - } - end + describe 'manage install_dir' do + it { is_expected.to contain_file(install_dir).with_ensure('directory') } + it { is_expected.to contain_file(install_dir).with_group('grafana').with_owner('grafana') } + end - context 'debian' do - let(:facts) do - { - osfamily: 'Debian', - lsbdistid: 'Ubuntu' - } - end + describe 'configure grafana' do + it { is_expected.to contain_file(service_config).with_ensure('file') } + end - it { is_expected.to compile.with_all_deps } + describe 'run grafana as service' do + it { is_expected.to contain_service('grafana-server').with_ensure('running').with_provider('base') } + it { is_expected.to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } + end - describe 'install dependencies first' do - it { is_expected.to contain_package('libfontconfig1').with_ensure('present').that_comes_before('Package[grafana]') } - end + context 'when user already defined' do + let(:pre_condition) do + 'user{"grafana": + ensure => present, + }' + end + describe 'do NOT create grafana user' do + it { is_expected.not_to contain_user('grafana').with_ensure('present').with_home(install_dir) } + end + end - describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('present') } + context 'when service already defined' do + let(:pre_condition) do + 'service{"grafana-server": + ensure => running, + hasrestart => true, + hasstatus => true, + }' + end + # let(:params) {{ :service_name => 'grafana-server'}} + describe 'do NOT run service' do + it { is_expected.not_to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } + end + end end - end - end - context 'archive install method' do - let(:params) do - { - install_method: 'archive' - } - end - - install_dir = '/usr/share/grafana' - service_config = '/usr/share/grafana/conf/custom.ini' - archive_source = 'https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0.linux-x64.tar.gz' - - describe 'extract archive to install_dir' do - it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_ensure('present') } - it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_source(archive_source) } - it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_extract_path(install_dir) } - end - - describe 'create grafana user' do - it { is_expected.to contain_user('grafana').with_ensure('present').with_home(install_dir) } - it { is_expected.to contain_user('grafana').that_comes_before('File[/usr/share/grafana]') } - end - - describe 'manage install_dir' do - it { is_expected.to contain_file(install_dir).with_ensure('directory') } - it { is_expected.to contain_file(install_dir).with_group('grafana').with_owner('grafana') } - end - - describe 'configure grafana' do - it { is_expected.to contain_file(service_config).with_ensure('present') } - end - - describe 'run grafana as service' do - it { is_expected.to contain_service('grafana-server').with_ensure('running').with_provider('base') } - it { is_expected.to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } - end - - context 'when user already defined' do - let(:pre_condition) do - 'user{"grafana": - ensure => present, - }' - end - describe 'do NOT create grafana user' do - it { is_expected.not_to contain_user('grafana').with_ensure('present').with_home(install_dir) } - end - end + context 'invalid parameters' do + context 'cfg' do + describe 'should raise an error when cfg parameter is not a hash' do + let(:params) do + { + cfg: [] + } + end - context 'when service already defined' do - let(:pre_condition) do - 'service{"grafana-server": - ensure => running, - hasrestart => true, - hasstatus => true, - }' - end - # let(:params) {{ :service_name => 'grafana-server'}} - describe 'do NOT run service' do - it { is_expected.not_to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } - end - end - end + it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{cfg parameter must be a hash}) } + end - context 'invalid parameters' do - context 'cfg' do - let(:facts) do - { - osfamily: 'Debian' - } - end + describe 'should not raise an error when cfg parameter is a hash' do + let(:params) do + { + cfg: {} + } + end - describe 'should raise an error when cfg parameter is not a hash' do - let(:params) do - { - cfg: [] - } + it { is_expected.to contain_package('grafana') } + end end - - it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{cfg parameter must be a hash}) } end - describe 'should not raise an error when cfg parameter is a hash' do - let(:params) do - { - cfg: {} - } + context 'configuration file' do + describe 'should not contain any configuration when cfg param is empty' do + it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content("# This file is managed by Puppet, any changes will be overwritten\n\n") } end - it { is_expected.to contain_package('grafana') } - end - end - end - - context 'configuration file' do - let(:facts) do - { - osfamily: 'Debian' - } - end - - describe 'should not contain any configuration when cfg param is empty' do - it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content("# This file is managed by Puppet, any changes will be overwritten\n\n") } - end - - describe 'should correctly transform cfg param entries to Grafana configuration' do - let(:params) do - { - cfg: { - 'app_mode' => 'production', - 'section' => { - 'string' => 'production', - 'number' => 8080, - 'boolean' => false, - 'empty' => '' describe 'should correctly transform cfg param entries to Grafana configuration' do let(:params) do { @@ -304,60 +236,41 @@ } } } - }, - ldap_cfg: { - 'servers' => [ - { 'host' => 'server1', - 'use_ssl' => true, - 'search_filter' => '(sAMAccountName=%s)', - 'search_base_dns' => ['dc=domain1,dc=com'] }, - { 'host' => 'server2', - 'use_ssl' => true, - 'search_filter' => '(sAMAccountName=%s)', - 'search_base_dns' => ['dc=domain2,dc=com'] } - ], - 'servers.attributes' => { - 'name' => 'givenName', - 'surname' => 'sn', - 'username' => 'sAMAccountName', - 'member_of' => 'memberOf', - 'email' => 'email' - } - } - } + end + + expected = "# This file is managed by Puppet, any changes will be overwritten\n\n"\ + "app_mode = production\n\n"\ + "[section]\n"\ + "boolean = false\n"\ + "empty = \n"\ + "number = 8080\n"\ + "string = production\n" + + it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content(expected) } + + ldap_expected = "\n[[servers]]\n"\ + "host = \"server1\"\n"\ + "search_base_dns = [\"dc=domain1,dc=com\"]\n"\ + "search_filter = \"(sAMAccountName=%s)\"\n"\ + "use_ssl = true\n"\ + "\n"\ + "[[servers]]\n"\ + "host = \"server2\"\n"\ + "search_base_dns = [\"dc=domain2,dc=com\"]\n"\ + "search_filter = \"(sAMAccountName=%s)\"\n"\ + "use_ssl = true\n"\ + "\n"\ + "[servers.attributes]\n"\ + "email = \"email\"\n"\ + "member_of = \"memberOf\"\n"\ + "name = \"givenName\"\n"\ + "surname = \"sn\"\n"\ + "username = \"sAMAccountName\"\n"\ + "\n" + + it { is_expected.to contain_file('/etc/grafana/ldap.toml').with_content(ldap_expected) } + end end - - expected = "# This file is managed by Puppet, any changes will be overwritten\n\n"\ - "app_mode = production\n\n"\ - "[section]\n"\ - "boolean = false\n"\ - "empty = \n"\ - "number = 8080\n"\ - "string = production\n" - - it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content(expected) } - - ldap_expected = "\n[[servers]]\n"\ - "host = \"server1\"\n"\ - "search_base_dns = [\"dc=domain1,dc=com\"]\n"\ - "search_filter = \"(sAMAccountName=%s)\"\n"\ - "use_ssl = true\n"\ - "\n"\ - "[[servers]]\n"\ - "host = \"server2\"\n"\ - "search_base_dns = [\"dc=domain2,dc=com\"]\n"\ - "search_filter = \"(sAMAccountName=%s)\"\n"\ - "use_ssl = true\n"\ - "\n"\ - "[servers.attributes]\n"\ - "email = \"email\"\n"\ - "member_of = \"memberOf\"\n"\ - "name = \"givenName\"\n"\ - "surname = \"sn\"\n"\ - "username = \"sAMAccountName\"\n"\ - "\n" - - it { is_expected.to contain_file('/etc/grafana/ldap.toml').with_content(ldap_expected) } end end end From 1f3d0efcd673194c7f8b21d96fe228aa0f36670f Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 18:47:33 +0100 Subject: [PATCH 009/146] Fix issue regarding non numeric versions --- manifests/install.pp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index 809b19230..8ab4b1e30 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -107,8 +107,14 @@ } } + if $::grafana::version =~ /(installed|latest|present)/ { + $real_version = $::grafana::version + } else { + $real_version = "${::grafana::version}-${::grafana::rpm_iteration}" + } + package { $::grafana::package_name: - ensure => "${::grafana::version}-${::grafana::rpm_iteration}", + ensure => $real_version, require => Package['fontconfig'], } } From 27f9cb89f93a7084d747d768b94b27e15a3e4d4e Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 7 Dec 2016 19:05:40 +0100 Subject: [PATCH 010/146] Add support for anchor pattern --- manifests/init.pp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 6b94aa0be..c2a5a51af 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -92,12 +92,9 @@ fail('cfg parameter must be a hash') } + anchor { 'grafana::begin': } -> class { '::grafana::install': } -> class { '::grafana::config': } ~> - class { '::grafana::service': } - - contain '::grafana::install' - contain '::grafana::service' - - #Class['grafana'] + class { '::grafana::service': } -> + anchor { 'grafana::end': } } From 9a36f66d137e76d22bad71d4f013d013f6e57122 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 21 Dec 2016 14:32:49 +0100 Subject: [PATCH 011/146] modulesync 0.16.4 --- .github/ISSUE_TEMPLATE.md | 1 + .github/PULL_REQUEST_TEMPLATE.md | 1 + .msync.yml | 2 +- .travis.yml | 7 +++++-- spec/default_facts.yml | 1 - 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f6f4f86e7..593e7aa83 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,6 +4,7 @@ Thank you for contributing to this project! - This project has a Contributor Code of Conduct: https://voxpupuli.org/coc/ - Please check that here is no existing issue or PR that addresses your problem. - Please fill the following form to enable us to help you. +- Our vulnerabilities reporting process is at https://voxpupuli.org/security/ --> diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 92f2e5983..66f80444c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,5 +3,6 @@ Thank you for contributing to this project! - This project has a Contributor Code of Conduct: https://voxpupuli.org/coc/ - Please check that here is no existing issue or PR that addresses your problem. +- Our vulnerabilities reporting process is at https://voxpupuli.org/security/ --> diff --git a/.msync.yml b/.msync.yml index a7e7e88a6..f01073354 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.16.3' +modulesync_config_version: '0.16.4' diff --git a/.travis.yml b/.travis.yml index 613b2c3c2..d74b190fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,10 +31,13 @@ matrix: env: PUPPET_VERSION="~> 4.0" CHECK=rubocop - rvm: 2.3.3 env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.0-preview3 + - rvm: 2.4.0-rc1 env: PUPPET_VERSION="~> 4.0" CHECK=test allow_failures: - - rvm: 2.4.0-preview3 + - rvm: 2.4.0-rc1 +branches: + only: + - master notifications: email: false deploy: diff --git a/spec/default_facts.yml b/spec/default_facts.yml index a3f52bfda..4f365061b 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -3,4 +3,3 @@ concat_basedir: "/tmp" ipaddress: "172.16.254.254" is_pe: false macaddress: "AA:AA:AA:AA:AA:AA" -selinux_config_mode: "disabled" From 1835009a5f74c25264edcb5cb9d99a03a664e8c7 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 25 Dec 2016 01:20:47 +0100 Subject: [PATCH 012/146] modulesync 0.16.6 --- .msync.yml | 2 +- .travis.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.msync.yml b/.msync.yml index f01073354..0f438ad5e 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.16.4' +modulesync_config_version: '0.16.6' diff --git a/.travis.yml b/.travis.yml index d74b190fa..201d173f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ matrix: branches: only: - master + - /^v\d/ notifications: email: false deploy: From 6cdb444581ed35c6033bdf8bad89e10cb9eab01f Mon Sep 17 00:00:00 2001 From: juniorsysadmin Date: Mon, 26 Dec 2016 13:29:58 +1100 Subject: [PATCH 013/146] Bump min version_requirement for Puppet + deps We currently only run automated tests against Puppet 3 latest and therefore cannot guarantee that this module works as is expected with earlier Puppet versions Bump dependencies to the minimum version that should work under Puppet 4, based on the metadata Also remove deprecated pe version_requirement field --- metadata.json | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/metadata.json b/metadata.json index 13d407ce1..c05eea0d2 100644 --- a/metadata.json +++ b/metadata.json @@ -10,23 +10,23 @@ "dependencies": [ { "name": "garethr/docker", - "version_requirement": ">= 3.5.0 <6.0.0" + "version_requirement": ">= 5.0.0 < 6.0.0" }, { "name": "maestrodev/wget", - "version_requirement": ">= 1.6.0 <2.0.0" + "version_requirement": ">= 1.7.3 < 2.0.0" }, { "name": "puppet/archive", - "version_requirement": ">= 0.5.1 <2.0.0" + "version_requirement": ">= 1.0.1 < 2.0.0" }, { "name": "puppetlabs/apt", - "version_requirement": ">=2.0.0 <3.0.0" + "version_requirement": ">=2.1.0 < 3.0.0" }, { "name": "puppetlabs/stdlib", - "version_requirement": ">=3.2.0 <5.0.0" + "version_requirement": ">=4.6.0 < 5.0.0" } ], "operatingsystem_support": [ @@ -56,13 +56,9 @@ } ], "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.2.0" - }, { "name": "puppet", - "version_requirement": ">= 3.4.0" + "version_requirement": ">= 3.8.7 < 5.0.0" } ], "tags": [ From bef3d75c4a7b33111b7c68b95cbb79a28d9cbdf6 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jan 2017 18:46:30 +0100 Subject: [PATCH 014/146] modulesync 0.16.7 --- .msync.yml | 2 +- .rubocop.yml | 8 ++++++++ .travis.yml | 4 ++-- Gemfile | 4 ++-- spec/acceptance/nodesets/fedora-24-x64.yml | 15 +++++++++++++++ spec/acceptance/nodesets/fedora-25-x64.yml | 18 ++++++++++++++++++ spec/default_facts.yml | 9 +++++++++ 7 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 spec/acceptance/nodesets/fedora-24-x64.yml create mode 100644 spec/acceptance/nodesets/fedora-25-x64.yml diff --git a/.msync.yml b/.msync.yml index 0f438ad5e..d505802eb 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.16.6' +modulesync_config_version: '0.16.7' diff --git a/.rubocop.yml b/.rubocop.yml index f703c727c..0e2866701 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -510,3 +510,11 @@ RSpec/ExampleLength: RSpec/NamedSubject: Enabled: False + +# disabled for now since they cause a lot of issues +# these issues aren't easy to fix +RSpec/RepeatedDescription: + Enabled: False + +RSpec/NestedGroups: + Enabled: False diff --git a/.travis.yml b/.travis.yml index 201d173f6..fd69c49cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,10 +31,10 @@ matrix: env: PUPPET_VERSION="~> 4.0" CHECK=rubocop - rvm: 2.3.3 env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.0-rc1 + - rvm: 2.4.0 env: PUPPET_VERSION="~> 4.0" CHECK=test allow_failures: - - rvm: 2.4.0-rc1 + - rvm: 2.4.0 branches: only: - master diff --git a/Gemfile b/Gemfile index e3785e25d..5b1eb7228 100644 --- a/Gemfile +++ b/Gemfile @@ -25,8 +25,8 @@ group :test do gem 'metadata-json-lint', :require => false gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' - gem 'puppet-strings', '~> 0.99.0', :require => false - gem 'rubocop-rspec', '~> 1.6', :require => false if RUBY_VERSION >= '2.3.0' + gem 'puppet-strings', '~> 1.0.0', :require => false + gem 'rubocop-rspec', '~> 1.9.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0' gem 'mocha', '>= 1.2.1', :require => false gem 'coveralls', :require => false if RUBY_VERSION >= '2.0.0' diff --git a/spec/acceptance/nodesets/fedora-24-x64.yml b/spec/acceptance/nodesets/fedora-24-x64.yml new file mode 100644 index 000000000..820b62d26 --- /dev/null +++ b/spec/acceptance/nodesets/fedora-24-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + fedora-24-x64: + roles: + - master + platform: fedora-24-x86_64 + box: fedora/24-cloud-base + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/fedora-25-x64.yml b/spec/acceptance/nodesets/fedora-25-x64.yml new file mode 100644 index 000000000..c3a3cbf59 --- /dev/null +++ b/spec/acceptance/nodesets/fedora-25-x64.yml @@ -0,0 +1,18 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# platform is fedora 24 because there is no +# puppet-agent for fedora 25 by 2016-12-30 +HOSTS: + fedora-25-x64: + roles: + - master + platform: fedora-24-x86_64 + box: fedora/25-cloud-base + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 4f365061b..13c416576 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -1,3 +1,12 @@ +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# use default_module_facts.yaml for module specific +# facts. +# +# Hint if using with rspec-puppet-facts ("on_supported_os.each"): +# if a same named fact exists in facterdb it will be overridden. --- concat_basedir: "/tmp" ipaddress: "172.16.254.254" From 370d75fb03fc0262237dd2cc2c23f2dabafb226f Mon Sep 17 00:00:00 2001 From: Andy Royle Date: Wed, 14 Dec 2016 17:44:20 +0000 Subject: [PATCH 015/146] fix function calls to send_request in datasource provider --- lib/puppet/provider/grafana_datasource/grafana.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 94a74f4b5..325d03b4c 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -31,7 +31,7 @@ def datasources datasources = JSON.parse(response.body) datasources.map { |x| x['id'] }.map do |id| - response = send_request format('GET, /api/datasources/%s', id) + response = send_request 'GET', format('/api/datasources/%s', id) if response.code != '200' raise format('Fail to retrieve datasource %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -154,7 +154,7 @@ def save_datasource response = send_request('POST', '/api/datasources', data) else data[:id] = datasource[:id] - response = send_request format('PUT, /api/datasources/%s', datasource[:id]) + response = send_request 'PUT', format('/api/datasources/%s', datasource[:id]) end if response.code != '200' @@ -164,7 +164,7 @@ def save_datasource end def delete_datasource - response = send_request format('DELETE, /api/datasources/%s', datasource[:id]) + response = send_request 'DELETE', format('/api/datasources/%s', datasource[:id]) if response.code != '200' raise format('Failed to delete datasource %s (HTTP response: %s/%s', resource[:name], response.code, response.body) From 22ef0a7ca2d64ed6f88764475eafb387f9d97a03 Mon Sep 17 00:00:00 2001 From: Andy Royle Date: Wed, 4 Jan 2017 15:49:32 +0000 Subject: [PATCH 016/146] fix missing parameter on send_request method call --- lib/puppet/provider/grafana_datasource/grafana.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 325d03b4c..25daeb2c6 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -154,7 +154,7 @@ def save_datasource response = send_request('POST', '/api/datasources', data) else data[:id] = datasource[:id] - response = send_request 'PUT', format('/api/datasources/%s', datasource[:id]) + response = send_request 'PUT', format('/api/datasources/%s', datasource[:id]), data end if response.code != '200' From a1824123d6380b02a63fb158cdd128c41f46c859 Mon Sep 17 00:00:00 2001 From: Andy Royle Date: Wed, 4 Jan 2017 15:49:57 +0000 Subject: [PATCH 017/146] name methods to match property 'is_default' --- lib/puppet/provider/grafana_datasource/grafana.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 25daeb2c6..1ccf84fd0 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -119,11 +119,11 @@ def password=(value) save_datasource end - def default? + def is_default datasource[:is_default] end - def default=(value) + def is_default=(value) resource[:is_default] = value save_datasource end From 7e9cde09d751b8754eff78e2f6adf7f78937fd9e Mon Sep 17 00:00:00 2001 From: Andy Royle Date: Wed, 4 Jan 2017 16:12:37 +0000 Subject: [PATCH 018/146] disable the predicateName rule for grafana_datasource.rb --- .rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 0e2866701..1ff29d3c1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -430,6 +430,8 @@ Style/PerlBackrefs: Style/PredicateName: Enabled: True + Exclude: + - lib/puppet/provider/grafana_datasource/grafana.rb Style/RedundantException: Enabled: True From 599cb978697bd947b3eb7ae4b47d5658b8fff13b Mon Sep 17 00:00:00 2001 From: Andy Royle Date: Mon, 9 Jan 2017 09:25:54 +0000 Subject: [PATCH 019/146] only suppress the predicateName rule for the given methods --- .rubocop.yml | 2 -- lib/puppet/provider/grafana_datasource/grafana.rb | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1ff29d3c1..0e2866701 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -430,8 +430,6 @@ Style/PerlBackrefs: Style/PredicateName: Enabled: True - Exclude: - - lib/puppet/provider/grafana_datasource/grafana.rb Style/RedundantException: Enabled: True diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 1ccf84fd0..79d7d5dea 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -119,6 +119,7 @@ def password=(value) save_datasource end + # rubocop:disable Style/PredicateName def is_default datasource[:is_default] end @@ -127,6 +128,7 @@ def is_default=(value) resource[:is_default] = value save_datasource end + # rubocop:enable Style/PredicateName def json_data datasource[:json_data] From 9f4dfb7695addb02ee29ce95711c441f756769d7 Mon Sep 17 00:00:00 2001 From: doomnuggets Date: Mon, 16 Jan 2017 12:02:24 +0100 Subject: [PATCH 020/146] Update config.ini.erb --- templates/config.ini.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/config.ini.erb b/templates/config.ini.erb index ae2743168..f29c57db0 100644 --- a/templates/config.ini.erb +++ b/templates/config.ini.erb @@ -1,5 +1,10 @@ # This file is managed by Puppet, any changes will be overwritten +<%- @cfg.keys.sort.each do |key| + if not @cfg[key].is_a?(Hash) -%> +<%= key %> = <%= @cfg[key] %> + <%- end +end -%> <%- @cfg.keys.sort.each do |key| if @cfg[key].is_a?(Hash) -%> @@ -7,7 +12,5 @@ <%- @cfg[key].keys.sort.each do |valkey| -%> <%= valkey %> = <%= @cfg[key][valkey] %> <%- end -%> - <%- else -%> -<%= key %> = <%= @cfg[key] %> <%- end end -%> From 80411d1d823f819f1a29d7962ec4cf66896abb47 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 18 Jan 2017 00:06:38 +0100 Subject: [PATCH 021/146] modulesync 0.16.8 --- .msync.yml | 2 +- .rubocop.yml | 4 ++-- Gemfile | 4 +++- spec/spec_helper.rb | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.msync.yml b/.msync.yml index d505802eb..1bc592bdc 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.16.7' +modulesync_config_version: '0.16.8' diff --git a/.rubocop.yml b/.rubocop.yml index 0e2866701..37416918a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -74,7 +74,7 @@ Style/WhileUntilModifier: Lint/AmbiguousRegexpLiteral: Enabled: True -Lint/Eval: +Security/Eval: Enabled: True Lint/BlockAlignment: @@ -302,7 +302,7 @@ Style/EmptyLiteral: Metrics/LineLength: Enabled: False -Style/MethodCallParentheses: +Style/MethodCallWithoutArgsParentheses: Enabled: True Style/MethodDefParentheses: diff --git a/Gemfile b/Gemfile index 5b1eb7228..1a5676410 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,9 @@ group :test do gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' gem 'puppet-strings', '~> 1.0.0', :require => false - gem 'rubocop-rspec', '~> 1.9.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'redcarpet', :require => false + gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0' gem 'mocha', '>= 1.2.1', :require => false gem 'coveralls', :require => false if RUBY_VERSION >= '2.0.0' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 32709c814..ec02c1a63 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,8 +24,8 @@ puppetversion: Puppet.version, facterversion: Facter.version } - default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) - default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) + default_facts.merge!(YAML.safe_load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) + default_facts.merge!(YAML.safe_load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) c.default_facts = default_facts end From 9e0384b37b7c673a54c563a3dd4ed67b1bd56735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Wed, 18 Jan 2017 15:29:00 +0100 Subject: [PATCH 022/146] Add changelog entries for changes since 2.5.0 this includes our changes since the fork --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47581cc93..9dc784dd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +# Releasing v2.6.0 (2017-01-18) + +**Enhancements** + +* add two types & provider: `grafana_datasource` & `grafana_dashboard` these + type allow configuration of the datasource and the dashboard against the API +* allow configuration of `repo_name` for all installation methods +* be more conservative when installing from docker, while also allowing users to + override our `stable` choice + +**Fixes** + +* ensure correct ownership of downloaded artefact +* fix use-before definition of `$version`: https://github.com/bfraser/puppet-grafana/issues/87 + +**Behind The Scenes** + +* switch to voxpupuli/archive from camptocamp + +**Changes since forking from bfraser/puppet-grafana** + +* Add CONTRIBUTING.MD as well as our issues, spec etc… templates +* update README and other files to point to forked repository +* Rubocop and ruby-lint style-fixes! +* test with puppet > 4.x + # 2.5.0 (2015-10-31) **Enhancements** From 434d645b7b9fdbf84b970e71a4cc8e7588f81248 Mon Sep 17 00:00:00 2001 From: goya151 Date: Wed, 18 Jan 2017 16:23:43 +0100 Subject: [PATCH 023/146] Update metadata.json Release 2.6.0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index c05eea0d2..322921cbc 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.5.0", + "version": "2.6.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From a9eee4e0fc39711899192ed658e8e58498c6baba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Wed, 18 Jan 2017 16:59:45 +0100 Subject: [PATCH 024/146] [blacksmith] Bump version to 2.6.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 322921cbc..8e680e54a 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.6.0", + "version": "2.6.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From d86741d7910c320b0c23d19d446a297cd245d6d1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 18 Jan 2017 21:40:21 +0100 Subject: [PATCH 025/146] release 2.6.1 --- CHANGELOG.md | 5 +++++ metadata.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dc784dd1..b197d0601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Releasing v2.6.1 (2017-01-18) + +Just a notice: The next release will be a major one without Puppet 3 support! +This is the last Release that supports it! + # Releasing v2.6.0 (2017-01-18) **Enhancements** diff --git a/metadata.json b/metadata.json index 8e680e54a..9b6167d0c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.6.1-rc0", + "version": "2.6.1", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 9733b0666313569056a2ab27fa7361fdd8952570 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 18 Jan 2017 21:48:18 +0100 Subject: [PATCH 026/146] bump required puppet version to 4.6.1 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 9b6167d0c..b6476266e 100644 --- a/metadata.json +++ b/metadata.json @@ -58,7 +58,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.8.7 < 5.0.0" + "version_requirement": ">= 4.6.1 < 5.0.0" } ], "tags": [ From 16e78dd4b283210f06ad498718466788add70311 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 18 Jan 2017 21:51:30 +0100 Subject: [PATCH 027/146] modulesync 0.19.3 --- .gitignore | 3 +++ .msync.yml | 2 +- .pmtignore | 1 + .rubocop.yml | 4 ++++ .travis.yml | 17 +++++------------ .yardopts | 1 + Gemfile | 8 +++++--- Rakefile | 11 +++++++++++ spec/spec_helper.rb | 6 +++--- 9 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 .pmtignore diff --git a/.gitignore b/.gitignore index 82426da6e..b5217490b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ spec/fixtures/modules/ coverage/ log/ .idea/ +.dependencies/ +.librarian/ +Puppetfile.lock *.iml .*.sw? .yardoc/ diff --git a/.msync.yml b/.msync.yml index 1bc592bdc..b42c48761 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.16.8' +modulesync_config_version: '0.19.3' diff --git a/.pmtignore b/.pmtignore new file mode 100644 index 000000000..77f12ae2e --- /dev/null +++ b/.pmtignore @@ -0,0 +1 @@ +docs/ diff --git a/.rubocop.yml b/.rubocop.yml index 37416918a..ef85ceb41 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -518,3 +518,7 @@ RSpec/RepeatedDescription: RSpec/NestedGroups: Enabled: False + +# disable Yaml safe_load. This is needed to support ruby2.0.0 development envs +Security/YAMLLoad: + Enabled: false diff --git a/.travis.yml b/.travis.yml index fd69c49cc..de8b79ceb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ --- sudo: false +dist: trusty language: ruby cache: bundler bundler_args: --without system_tests development @@ -15,26 +16,18 @@ script: matrix: fast_finish: true include: - - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test - - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test - - rvm: 2.1.9 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test - rvm: 2.1.9 env: PUPPET_VERSION="~> 4.0" CHECK=test - rvm: 2.2.6 env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.3.3 - env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes - - rvm: 2.3.3 - env: PUPPET_VERSION="~> 4.0" CHECK=rubocop - rvm: 2.3.3 env: PUPPET_VERSION="~> 4.0" CHECK=test - rvm: 2.4.0 env: PUPPET_VERSION="~> 4.0" CHECK=test - allow_failures: - - rvm: 2.4.0 + - rvm: 2.4.0 + env: PUPPET_VERSION="~> 4.0" CHECK=rubocop + - rvm: 2.4.0 + env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: - master diff --git a/.yardopts b/.yardopts index 29c933bcf..3687f5184 100644 --- a/.yardopts +++ b/.yardopts @@ -1 +1,2 @@ --markup markdown +--output-dir docs/ diff --git a/Gemfile b/Gemfile index 1a5676410..180964fbb 100644 --- a/Gemfile +++ b/Gemfile @@ -29,10 +29,12 @@ group :test do gem 'redcarpet', :require => false gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0' - gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0' gem 'mocha', '>= 1.2.1', :require => false - gem 'coveralls', :require => false if RUBY_VERSION >= '2.0.0' - gem 'simplecov-console', :require => false if RUBY_VERSION >= '2.0.0' + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'github_changelog_generator', '~> 1.13.0', :require => false if RUBY_VERSION < '2.2.2' + gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' + gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2' gem 'toml', :require => false end diff --git a/Rakefile b/Rakefile index d00f2470a..2def02fad 100644 --- a/Rakefile +++ b/Rakefile @@ -30,4 +30,15 @@ task test: [ :metadata_lint, :release_checks, ] + +begin + require 'github_changelog_generator/task' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + version = (Blacksmith::Modulefile.new).version + config.future_release = "#{version}" + config.header = "# Change log\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not impact the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix modulesync} + end +rescue LoadError +end # vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ec02c1a63..2aa9da74c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,7 @@ require 'rspec-puppet-facts' include RspecPuppetFacts -if Dir.exist?(File.expand_path('../../lib', __FILE__)) && RUBY_VERSION !~ %r{^1.9} +if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'coveralls' require 'simplecov' require 'simplecov-console' @@ -24,8 +24,8 @@ puppetversion: Puppet.version, facterversion: Facter.version } - default_facts.merge!(YAML.safe_load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) - default_facts.merge!(YAML.safe_load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) + default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) + default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) c.default_facts = default_facts end From 256f723029b06d9372d7e8eea88216f98b58d84b Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Wed, 18 Jan 2017 22:30:43 +0000 Subject: [PATCH 028/146] [blacksmith] Bump version to 2.6.2-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index b6476266e..57d444839 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.6.1", + "version": "2.6.2-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From c1bd713df45522aa6929488aaac5ee24696fc0e3 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Wed, 18 Jan 2017 22:31:39 +0000 Subject: [PATCH 029/146] Revert "[blacksmith] Bump version to 2.6.2-rc0" This reverts commit 256f723029b06d9372d7e8eea88216f98b58d84b. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 57d444839..b6476266e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.6.2-rc0", + "version": "2.6.1", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 14ad2161a0c2e6555f51dc5abf2c2981d0ce7ce2 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Wed, 18 Jan 2017 22:31:47 +0000 Subject: [PATCH 030/146] [blacksmith] Bump version to 2.6.2-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index b6476266e..57d444839 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.6.1", + "version": "2.6.2-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 12ec86dee9e0c267ccc2da888f80fae9dc2e6b9d Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Wed, 18 Jan 2017 23:04:25 +0000 Subject: [PATCH 031/146] The puppet 4-only release will start at 3.0.0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 57d444839..8f8794ed9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "2.6.2-rc0", + "version": "3.0.0-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 1a1f20c052e32dd1159cfb7ccfc0f4f3b213f06a Mon Sep 17 00:00:00 2001 From: Mirek Bauer Date: Tue, 31 Jan 2017 14:36:15 +0100 Subject: [PATCH 032/146] Use operatingsystemmajrelease fact in el repo url --- manifests/install.pp | 2 +- spec/classes/grafana_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 8ab4b1e30..191509643 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -99,7 +99,7 @@ if ( $::grafana::manage_package_repo ){ yumrepo { 'grafana': descr => 'grafana repo', - baseurl => 'https://packagecloud.io/grafana/stable/el/6/$basearch', + baseurl => "https://packagecloud.io/grafana/stable/el/${::operatingsystemmajrelease}/\$basearch", gpgcheck => 1, gpgkey => 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled => 1, diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 8d9b2ea72..f0606c203 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -70,7 +70,7 @@ end when 'RedHat' describe 'yum repo dependencies first' do - it { is_expected.to contain_yumrepo('grafana').with(baseurl: 'https://packagecloud.io/grafana/stable/el/6/$basearch', gpgkey: 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled: 1) } + it { is_expected.to contain_yumrepo('grafana').with(baseurl: 'https://packagecloud.io/grafana/stable/el/' + facts[:operatingsystemmajrelease] + '/$basearch', gpgkey: 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled: 1) } it { is_expected.to contain_yumrepo('grafana').that_comes_before('Package[grafana]') } end From 322862411b718e9e5704f86e8600a6e31c629806 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 12 Feb 2017 01:04:41 +0100 Subject: [PATCH 033/146] modulesync 0.20.0 --- .gitignore | 1 + .msync.yml | 2 +- .pmtignore | 19 +++++++++++ Gemfile | 3 +- spec/acceptance/nodesets/centos-6-x64.yml | 15 ++++++++ spec/acceptance/nodesets/centos-7-x64.yml | 15 ++++++++ spec/acceptance/nodesets/docker/centos-7.yml | 2 +- .../nodesets/ec2/amazonlinux-2016091.yml | 31 +++++++++++++++++ .../nodesets/ec2/image_templates.yaml | 34 +++++++++++++++++++ spec/acceptance/nodesets/ec2/rhel-73-x64.yml | 29 ++++++++++++++++ .../nodesets/ec2/sles-12sp2-x64.yml | 29 ++++++++++++++++ .../nodesets/ec2/ubuntu-1604-x64.yml | 29 ++++++++++++++++ .../nodesets/ec2/windows-2016-base-x64.yml | 29 ++++++++++++++++ spec/acceptance/nodesets/fedora-25-x64.yml | 2 +- 14 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 spec/acceptance/nodesets/centos-6-x64.yml create mode 100644 spec/acceptance/nodesets/centos-7-x64.yml create mode 100644 spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml create mode 100644 spec/acceptance/nodesets/ec2/image_templates.yaml create mode 100644 spec/acceptance/nodesets/ec2/rhel-73-x64.yml create mode 100644 spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml create mode 100644 spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml create mode 100644 spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml diff --git a/.gitignore b/.gitignore index b5217490b..0d629b0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ spec/fixtures/manifests/ spec/fixtures/modules/ .vagrant/ .bundle/ +.ruby-version coverage/ log/ .idea/ diff --git a/.msync.yml b/.msync.yml index b42c48761..d03e57009 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.19.3' +modulesync_config_version: '0.20.0' diff --git a/.pmtignore b/.pmtignore index 77f12ae2e..fb5895753 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1 +1,20 @@ docs/ +pkg/ +Gemfile.lock +Gemfile.local +vendor/ +.vendor/ +spec/fixtures/manifests/ +spec/fixtures/modules/ +.vagrant/ +.bundle/ +.ruby-version +coverage/ +log/ +.idea/ +.dependencies/ +.librarian/ +Puppetfile.lock +*.iml +.*.sw? +.yardoc/ diff --git a/Gemfile b/Gemfile index 180964fbb..6321c0e22 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,8 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 1.2.2', :require => false + gem 'puppetlabs_spec_helper', '~> 2.0.1', :require => false + gem 'parallel_tests', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false diff --git a/spec/acceptance/nodesets/centos-6-x64.yml b/spec/acceptance/nodesets/centos-6-x64.yml new file mode 100644 index 000000000..16abc8f1c --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-6-x64: + roles: + - master + platform: el-6-x86_64 + box: centos/6 + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml new file mode 100644 index 000000000..e05a3ae16 --- /dev/null +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-7-x64: + roles: + - master + platform: el-7-x86_64 + box: centos/7 + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml index 886b1eeb3..85e9d63c3 100644 --- a/spec/acceptance/nodesets/docker/centos-7.yml +++ b/spec/acceptance/nodesets/docker/centos-7.yml @@ -10,7 +10,7 @@ HOSTS: docker_preserve_image: true docker_cmd: '["/usr/sbin/init"]' docker_image_commands: - - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which ss' CONFIG: trace_limit: 200 masterless: true diff --git a/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml b/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml new file mode 100644 index 000000000..3f064f0a9 --- /dev/null +++ b/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml @@ -0,0 +1,31 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +# Amazon Linux is not a RHEL clone. +# +HOSTS: + amazonlinux-2016091-x64: + roles: + - master + platform: centos-6-x86_64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: amazonlinux-2016091-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/image_templates.yaml b/spec/acceptance/nodesets/ec2/image_templates.yaml new file mode 100644 index 000000000..9a277d812 --- /dev/null +++ b/spec/acceptance/nodesets/ec2/image_templates.yaml @@ -0,0 +1,34 @@ +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# see also: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +# Hint: image IDs (ami-*) for the same image are different per location. +# +AMI: + # Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type + amazonlinux-2016091-eu-central-1: + :image: + :aio: ami-af0fc0c0 + :region: eu-central-1 + # Red Hat Enterprise Linux 7.3 (HVM), SSD Volume Type + rhel-73-eu-central-1: + :image: + :aio: ami-e4c63e8b + :region: eu-central-1 + # SUSE Linux Enterprise Server 12 SP2 (HVM), SSD Volume Type + sles-12sp2-eu-central-1: + :image: + :aio: ami-c425e4ab + :region: eu-central-1 + # Ubuntu Server 16.04 LTS (HVM), SSD Volume Type + ubuntu-1604-eu-central-1: + :image: + :aio: ami-fe408091 + :region: eu-central-1 + # Microsoft Windows Server 2016 Base + windows-2016-base-eu-central-1: + :image: + :aio: ami-88ec20e7 + :region: eu-central-1 diff --git a/spec/acceptance/nodesets/ec2/rhel-73-x64.yml b/spec/acceptance/nodesets/ec2/rhel-73-x64.yml new file mode 100644 index 000000000..cd0521e7c --- /dev/null +++ b/spec/acceptance/nodesets/ec2/rhel-73-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + rhel-73-x64: + roles: + - master + platform: el-7-x86_64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: rhel-73-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml b/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml new file mode 100644 index 000000000..a14bea6cd --- /dev/null +++ b/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + sles-12sp2-x64: + roles: + - master + platform: sles-12-x86_64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: sles-12sp2-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml b/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml new file mode 100644 index 000000000..21ce560ac --- /dev/null +++ b/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + ubuntu-1604-x64: + roles: + - master + platform: ubuntu-16.04-amd64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: ubuntu-1604-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ubuntu +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml b/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml new file mode 100644 index 000000000..36bd9891f --- /dev/null +++ b/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + windows-2016-base-x64: + roles: + - master + platform: windows-2016-64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: windows-2016-base-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/fedora-25-x64.yml b/spec/acceptance/nodesets/fedora-25-x64.yml index c3a3cbf59..60ae01179 100644 --- a/spec/acceptance/nodesets/fedora-25-x64.yml +++ b/spec/acceptance/nodesets/fedora-25-x64.yml @@ -9,7 +9,7 @@ HOSTS: fedora-25-x64: roles: - master - platform: fedora-24-x86_64 + platform: fedora-25-x86_64 box: fedora/25-cloud-base hypervisor: vagrant CONFIG: From e3a564838e70a8bd8ef6e325936d01dd333d53c3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 12 Feb 2017 01:21:22 +0100 Subject: [PATCH 034/146] delete unneeded spec.opts file --- spec/spec.opts | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 spec/spec.opts diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 91cd6427e..000000000 --- a/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace From 73436c506e7a3fa5a30e2ccc4f8e760c5d5ee81c Mon Sep 17 00:00:00 2001 From: Roman Pertl Date: Wed, 1 Mar 2017 15:15:34 +0100 Subject: [PATCH 035/146] supoort jessie for install method repo --- manifests/install.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index 191509643..91e5b8868 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -75,7 +75,7 @@ } apt::source { 'grafana': location => "https://packagecloud.io/grafana/${::grafana::repo_name}/debian", - release => 'wheezy', + release => $::lsbdistcodename, repos => 'main', key => { 'id' => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB', From 0036b15052f72039875cda02ebea687def12af49 Mon Sep 17 00:00:00 2001 From: Cassiano Leal Date: Thu, 2 Mar 2017 12:16:26 +0000 Subject: [PATCH 036/146] FIX configuration file ownership Depending on the default ownership and permissions of the Puppet run, the configuration might be unreadable by the grafana user, causing the service startup to fail. One such possible cause is if the file type has default permissions such as: File { owner => 'root', group => 'root', mode => '0600', } --- manifests/config.pp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index fa61d8f6d..725b10d9b 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -11,6 +11,8 @@ file { $::grafana::cfg_location: ensure => file, content => template('grafana/config.ini.erb'), + owner => 'grafana', + group => 'grafana', } } } @@ -20,6 +22,8 @@ file { $::grafana::cfg_location: ensure => file, content => template('grafana/config.ini.erb'), + owner => 'grafana', + group => 'grafana', } } 'archive': { @@ -28,6 +32,8 @@ file { "${::grafana::install_dir}/conf/custom.ini": ensure => file, content => template('grafana/config.ini.erb'), + owner => 'grafana', + group => 'grafana', } } default: { @@ -40,6 +46,8 @@ file { '/etc/grafana/ldap.toml': ensure => file, content => inline_template("<%= require 'toml'; TOML::Generator.new(@ldap_cfg).body %>\n"), + owner => 'grafana', + group => 'grafana', } } } From 863f60302f401d31aed6a1b51371ba337155ffad Mon Sep 17 00:00:00 2001 From: Cassiano Leal Date: Thu, 2 Mar 2017 17:36:59 +0000 Subject: [PATCH 037/146] FIX grafana_dashboards crash This commit fixes the crash on the to_s method. It also fixes the API endpoint for dashboards with + character in the name --- lib/puppet/provider/grafana_dashboard/grafana.rb | 2 +- lib/puppet/type/grafana_dashboard.rb | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index 7f3157724..3b2f98881 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -68,7 +68,7 @@ def save_dashboard(dashboard) end def slug - resource[:title].downcase.gsub(%r{[^\w\- ]}, '').gsub(%r{ +}, '-') + resource[:title].downcase.gsub(%r{[ \+]+}, '-').gsub(%r{[^\w\- ]}, '') end def content diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index fceadb24d..7158ccc81 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -44,10 +44,6 @@ def should_to_s(value) value end end - - def to_s(value) - should_to_s(value) - end end newparam(:grafana_url) do From 0fda6212390b279407f90359a2a338c32a43f97a Mon Sep 17 00:00:00 2001 From: Cassiano Leal Date: Thu, 2 Mar 2017 17:43:46 +0000 Subject: [PATCH 038/146] FIX API requests --- lib/puppet/provider/grafana_dashboard/grafana.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index 3b2f98881..970e1b63e 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -41,7 +41,7 @@ def dashboards def find_dashboard return unless dashboards.find { |x| x['title'] == resource[:title] } - response = send_request format('GET, /api/dashboards/db/%s', slug) + response = send_request('GET', format('/api/dashboards/db/%s', slug)) if response.code != '200' raise format('Fail to retrieve dashboard %s (HTTP response: %s/%s)', resource[:title], response.code, response.body) end @@ -84,7 +84,7 @@ def create end def destroy - response = send_request format('DELETE, /api/dashboards/db/%s', slug) + response = send_request('DELETE', format('/api/dashboards/db/%s', slug)) return unless response.code != '200' raise Puppet::Error, format('Failed to delete dashboard %s (HTTP response: %s/%s', resource[:title], response.code, response.body) From 96dde95b2e67b7f99b0518272b75b744d5bc449a Mon Sep 17 00:00:00 2001 From: Cassiano Leal Date: Thu, 2 Mar 2017 17:46:01 +0000 Subject: [PATCH 039/146] FIX idempotency of grafana_dashboard --- lib/puppet/provider/grafana_dashboard/grafana.rb | 2 +- lib/puppet/type/grafana_dashboard.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index 970e1b63e..fb215d987 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -72,7 +72,7 @@ def slug end def content - @dashboard + @dashboard.reject { |k, _| k =~ %r{^id|version|title$} } end def content=(value) diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index 7158ccc81..96cdd9b99 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -34,7 +34,8 @@ end munge do |value| - JSON.parse(value) + new_value = JSON.parse(value).reject { |k, _| k =~ %r{^id|version|title$} } + new_value.sort.to_h end def should_to_s(value) From 9953a496e83836d44c6e0458f75c60bf2ec5185f Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 24 Jul 2016 01:15:00 +0200 Subject: [PATCH 040/146] add initial archlinux support --- manifests/install.pp | 8 ++++++++ manifests/params.pp | 20 +++++++++++++++----- metadata.json | 3 +++ spec/classes/grafana_spec.rb | 25 +++++++++++++++++++++---- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 191509643..741ea5939 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -118,6 +118,14 @@ require => Package['fontconfig'], } } + 'Archlinux': { + if $::grafana::manage_package_repo { + fail('manage_package_repo is not supported on Archlinux') + } + package { $::grafana::package_name: + ensure => $::grafana::version, # pacman provider doesn't have feature versionable + } + } default: { fail("${::operatingsystem} not supported") } diff --git a/manifests/params.pp b/manifests/params.pp index 5f6405597..4c58f4248 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,6 @@ # class grafana::params { $archive_source = undef - $cfg_location = '/etc/grafana/grafana.ini' $cfg = {} $container_cfg = false $container_params = {} @@ -13,13 +12,24 @@ $docker_image = 'grafana/grafana' $docker_ports = '3000:3000' $install_dir = '/usr/share/grafana' - $install_method = 'package' $ldap_cfg = false - $manage_package_repo = true $package_name = 'grafana' $package_source = undef $rpm_iteration = '1' - $service_name = 'grafana-server' - $version = '2.5.0' $repo_name = 'stable' + $version = '2.5.0' + case $::osfamily { + 'Archlinux': { + $manage_package_repo = false + $install_method = 'repo' + $cfg_location = '/etc/grafana.ini' + $service_name = 'grafana' + } + default: { + $manage_package_repo = true + $install_method = 'package' + $cfg_location = '/etc/grafana/grafana.ini' + $service_name = 'grafana-server' + } + } } diff --git a/metadata.json b/metadata.json index 8f8794ed9..e0b4f42e3 100644 --- a/metadata.json +++ b/metadata.json @@ -53,6 +53,9 @@ "operatingsystemrelease": [ "6" ] + }, + { + "operatingsystem": "Archlinux" } ], "requirements": [ diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index f0606c203..bd772c19c 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -7,6 +7,23 @@ facts end + let :service_name do + case facts[:osfamily] + when 'Archlinux' + 'grafana' + else + 'grafana-server' + end + end + + let :config_path do + case facts[:osfamily] + when 'Archlinux' + '/etc/grafana.ini' + else + '/etc/grafana/grafana.ini' + end + end context 'with default values' do it { is_expected.to compile } it { is_expected.to contain_anchor('grafana::begin') } @@ -145,8 +162,8 @@ end describe 'run grafana as service' do - it { is_expected.to contain_service('grafana-server').with_ensure('running').with_provider('base') } - it { is_expected.to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } + it { is_expected.to contain_service(service_name).with_ensure('running').with_provider('base') } + it { is_expected.to contain_service(service_name).with_hasrestart(false).with_hasstatus(false) } end context 'when user already defined' do @@ -201,7 +218,7 @@ context 'configuration file' do describe 'should not contain any configuration when cfg param is empty' do - it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content("# This file is managed by Puppet, any changes will be overwritten\n\n") } + it { is_expected.to contain_file(config_path).with_content("# This file is managed by Puppet, any changes will be overwritten\n\n") } end describe 'should correctly transform cfg param entries to Grafana configuration' do @@ -246,7 +263,7 @@ "number = 8080\n"\ "string = production\n" - it { is_expected.to contain_file('/etc/grafana/grafana.ini').with_content(expected) } + it { is_expected.to contain_file(config_path).with_content(expected) } ldap_expected = "\n[[servers]]\n"\ "host = \"server1\"\n"\ From 180f405491291cab92f90ee6a8e83ce281b6b231 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Mar 2017 22:36:37 +0100 Subject: [PATCH 041/146] enhance spec tests --- spec/classes/grafana_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index bd772c19c..4a80026d3 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -25,7 +25,7 @@ end end context 'with default values' do - it { is_expected.to compile } + it { is_expected.to compile.with_all_deps } it { is_expected.to contain_anchor('grafana::begin') } it { is_expected.to contain_class('grafana::params') } it { is_expected.to contain_class('grafana::install') } From 21139e464b1b5e8608f462ee1f2bead5d6556147 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 11 Mar 2017 00:51:17 +0100 Subject: [PATCH 042/146] modulesync 0.20.1 --- .msync.yml | 2 +- Rakefile | 2 +- spec/acceptance/nodesets/docker/centos-7.yml | 1 + spec/acceptance/nodesets/docker/debian-8.yml | 1 + spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml | 2 +- spec/acceptance/nodesets/ec2/image_templates.yaml | 2 +- spec/acceptance/nodesets/ec2/rhel-73-x64.yml | 2 +- spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml | 2 +- spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml | 2 +- spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml | 2 +- 10 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.msync.yml b/.msync.yml index d03e57009..a8e6a4ee7 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.20.0' +modulesync_config_version: '0.20.1' diff --git a/Rakefile b/Rakefile index 2def02fad..82c896088 100644 --- a/Rakefile +++ b/Rakefile @@ -35,7 +35,7 @@ begin require 'github_changelog_generator/task' GitHubChangelogGenerator::RakeTask.new :changelog do |config| version = (Blacksmith::Modulefile.new).version - config.future_release = "#{version}" + config.future_release = "v#{version}" config.header = "# Change log\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not impact the functionality of the module." config.exclude_labels = %w{duplicate question invalid wontfix modulesync} end diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml index 85e9d63c3..41e924b50 100644 --- a/spec/acceptance/nodesets/docker/centos-7.yml +++ b/spec/acceptance/nodesets/docker/centos-7.yml @@ -11,6 +11,7 @@ HOSTS: docker_cmd: '["/usr/sbin/init"]' docker_image_commands: - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which ss' + - 'systemctl mask getty@tty1.service' CONFIG: trace_limit: 200 masterless: true diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml index 500bee522..7a1f35c37 100644 --- a/spec/acceptance/nodesets/docker/debian-8.yml +++ b/spec/acceptance/nodesets/docker/debian-8.yml @@ -13,6 +13,7 @@ HOSTS: - 'echo deb http://ftp.debian.org/debian jessie-backports main >> /etc/apt/sources.list' - 'apt-get update && apt-get install -y cron locales-all net-tools wget' - 'rm -f /usr/sbin/policy-rc.d' + - 'systemctl mask getty@tty1.service getty-static.service' CONFIG: trace_limit: 200 masterless: true diff --git a/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml b/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml index 3f064f0a9..19dd43ed7 100644 --- a/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml +++ b/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml @@ -2,7 +2,7 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config -# +# # Additional ~/.fog config file with AWS EC2 credentials # required. # diff --git a/spec/acceptance/nodesets/ec2/image_templates.yaml b/spec/acceptance/nodesets/ec2/image_templates.yaml index 9a277d812..e50593ee0 100644 --- a/spec/acceptance/nodesets/ec2/image_templates.yaml +++ b/spec/acceptance/nodesets/ec2/image_templates.yaml @@ -7,7 +7,7 @@ # Hint: image IDs (ami-*) for the same image are different per location. # AMI: - # Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type + # Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type amazonlinux-2016091-eu-central-1: :image: :aio: ami-af0fc0c0 diff --git a/spec/acceptance/nodesets/ec2/rhel-73-x64.yml b/spec/acceptance/nodesets/ec2/rhel-73-x64.yml index cd0521e7c..7fac8236a 100644 --- a/spec/acceptance/nodesets/ec2/rhel-73-x64.yml +++ b/spec/acceptance/nodesets/ec2/rhel-73-x64.yml @@ -2,7 +2,7 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config -# +# # Additional ~/.fog config file with AWS EC2 credentials # required. # diff --git a/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml b/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml index a14bea6cd..8542154df 100644 --- a/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml +++ b/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml @@ -2,7 +2,7 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config -# +# # Additional ~/.fog config file with AWS EC2 credentials # required. # diff --git a/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml b/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml index 21ce560ac..9cf59d59e 100644 --- a/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml +++ b/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml @@ -2,7 +2,7 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config -# +# # Additional ~/.fog config file with AWS EC2 credentials # required. # diff --git a/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml b/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml index 36bd9891f..0932e29c8 100644 --- a/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml +++ b/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml @@ -2,7 +2,7 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config -# +# # Additional ~/.fog config file with AWS EC2 credentials # required. # From 9415b40d6a01818695bfd0c9afc50b1eda49f2d3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 11 Mar 2017 13:38:52 +0100 Subject: [PATCH 043/146] fix package ensure for Archlinux we can't pass the grafana version to the archlinux package provider. it has no versionable feature. this adds a workaround to provide 'present' to it. --- manifests/install.pp | 2 +- spec/classes/grafana_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index 741ea5939..339c754f7 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -123,7 +123,7 @@ fail('manage_package_repo is not supported on Archlinux') } package { $::grafana::package_name: - ensure => $::grafana::version, # pacman provider doesn't have feature versionable + ensure => 'present', # pacman provider doesn't have feature versionable } } default: { diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 4a80026d3..4ada06544 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -124,6 +124,10 @@ it { is_expected.to contain_package('fontconfig').with_ensure('present').that_comes_before('Package[grafana]') } end + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_ensure('present') } + end + when 'Archlinux' describe 'install the package' do it { is_expected.to contain_package('grafana').with_ensure('present') } end From aa6dcec7b6c6c398d95aa1d16871b8a3eb68c041 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 12 Mar 2017 20:38:32 +0100 Subject: [PATCH 044/146] increase spec coverage --- spec/classes/grafana_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 4ada06544..d1b3a4c93 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -26,6 +26,7 @@ end context 'with default values' do it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('grafana') } it { is_expected.to contain_anchor('grafana::begin') } it { is_expected.to contain_class('grafana::params') } it { is_expected.to contain_class('grafana::install') } From 84bf5718a3700b6b8dfecf78f239f105b6213782 Mon Sep 17 00:00:00 2001 From: Roman Pertl Date: Thu, 23 Mar 2017 18:09:19 +0100 Subject: [PATCH 045/146] update spec definitions for debian apt repo --- spec/classes/grafana_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index d1b3a4c93..4f5ca9e78 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -75,7 +75,7 @@ when 'Debian' describe 'install apt repo dependencies first' do it { is_expected.to contain_class('apt') } - it { is_expected.to contain_apt__source('grafana').with(release: 'wheezy', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } + it { is_expected.to contain_apt__source('grafana').with(release: facts[:lsbdistcodename], repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } it { is_expected.to contain_apt__source('grafana').that_comes_before('Package[grafana]') } end From 9766075d630f9eda809911deab25c00877205baa Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Sun, 26 Mar 2017 19:48:22 +0200 Subject: [PATCH 046/146] Debian and RedHat based operating systems should use the repository by default --- manifests/install.pp | 2 +- manifests/params.pp | 6 ++++++ spec/classes/grafana_spec.rb | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index f90ff281e..acaf0a620 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -99,7 +99,7 @@ if ( $::grafana::manage_package_repo ){ yumrepo { 'grafana': descr => 'grafana repo', - baseurl => "https://packagecloud.io/grafana/stable/el/${::operatingsystemmajrelease}/\$basearch", + baseurl => "https://packagecloud.io/grafana/${::grafana::repo_name}/el/${::operatingsystemmajrelease}/\$basearch", gpgcheck => 1, gpgkey => 'https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana', enabled => 1, diff --git a/manifests/params.pp b/manifests/params.pp index 4c58f4248..fb8aa07a0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -25,6 +25,12 @@ $cfg_location = '/etc/grafana.ini' $service_name = 'grafana' } + 'Debian', 'RedHat': { + $manage_package_repo = true + $install_method = 'repo' + $cfg_location = '/etc/grafana/grafana.ini' + $service_name = 'grafana-server' + } default: { $manage_package_repo = true $install_method = 'package' diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 4f5ca9e78..d524a6d2a 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -36,6 +36,12 @@ end context 'with parameter install_method is set to package' do + let(:params) do + { + install_method: 'package' + } + end + case facts[:osfamily] when 'Debian' download_location = '/tmp/grafana.deb' From 217cf1dc11794a0ea0ec211bfa68ad440bfb4652 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 29 Mar 2017 23:06:05 +0200 Subject: [PATCH 047/146] Bump version, Update changelog --- CHANGELOG.md | 24 ++++++++++++++++++++++++ metadata.json | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b197d0601..70cd7f6b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +# Releasing v3.0.0 (2017-03-29) + +**Implemented enhancements:** + +- Implement package\_ensure param for Arch Linux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) + +**Fixed bugs:** + +- FIX configuration file ownership [\#30](https://github.com/voxpupuli/puppet-grafana/pull/30) ([cassianoleal](https://github.com/cassianoleal)) + +**Closed issues:** + +- Configured Grafana Debian repo should contain current distribution [\#27](https://github.com/voxpupuli/puppet-grafana/issues/27) +- Error while creating dashboard [\#25](https://github.com/voxpupuli/puppet-grafana/issues/25) + +**Merged pull requests:** + +- Debian and RedHat based operating systems should use the repository by default [\#36](https://github.com/voxpupuli/puppet-grafana/pull/36) ([dhoppe](https://github.com/dhoppe)) +- Add support for Arch Linux [\#32](https://github.com/voxpupuli/puppet-grafana/pull/32) ([bastelfreak](https://github.com/bastelfreak)) +- Fix grafana\_dashboards [\#31](https://github.com/voxpupuli/puppet-grafana/pull/31) ([cassianoleal](https://github.com/cassianoleal)) +- Supoort jessie for install method repo [\#28](https://github.com/voxpupuli/puppet-grafana/pull/28) ([roock](https://github.com/roock)) +- Use operatinsystemmajrelease fact in repo url [\#24](https://github.com/voxpupuli/puppet-grafana/pull/24) ([mirekys](https://github.com/mirekys)) +- The puppet 4-only release will start at 3.0.0 [\#21](https://github.com/voxpupuli/puppet-grafana/pull/21) ([rnelson0](https://github.com/rnelson0)) + # Releasing v2.6.1 (2017-01-18) Just a notice: The next release will be a major one without Puppet 3 support! diff --git a/metadata.json b/metadata.json index e0b4f42e3..866fe794c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "3.0.0-rc0", + "version": "3.0.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From dbf207a2d95e1ec7843ead8169b4d76155bd3e20 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 29 Mar 2017 23:22:27 +0200 Subject: [PATCH 048/146] Fix serveral lint issues --- manifests/init.pp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c2a5a51af..d68a39283 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -92,9 +92,9 @@ fail('cfg parameter must be a hash') } - anchor { 'grafana::begin': } -> - class { '::grafana::install': } -> - class { '::grafana::config': } ~> - class { '::grafana::service': } -> - anchor { 'grafana::end': } + anchor { 'grafana::begin': } + -> class { '::grafana::install': } + -> class { '::grafana::config': } + ~> class { '::grafana::service': } + -> anchor { 'grafana::end': } } From 18b98bb7f263deccf0381d4dbd3a3ef18887a5e4 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 5 Apr 2017 14:38:15 +0200 Subject: [PATCH 049/146] Always use jessie apt repo, even if even if you are on Ubuntu or another Debian version, according to docs.grafana.org/installation/debian. --- manifests/install.pp | 2 +- spec/classes/grafana_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index acaf0a620..872c76973 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -75,7 +75,7 @@ } apt::source { 'grafana': location => "https://packagecloud.io/grafana/${::grafana::repo_name}/debian", - release => $::lsbdistcodename, + release => 'jessie', repos => 'main', key => { 'id' => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB', diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index d524a6d2a..abc1566cd 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -81,7 +81,7 @@ when 'Debian' describe 'install apt repo dependencies first' do it { is_expected.to contain_class('apt') } - it { is_expected.to contain_apt__source('grafana').with(release: facts[:lsbdistcodename], repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } + it { is_expected.to contain_apt__source('grafana').with(release: 'jessie', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } it { is_expected.to contain_apt__source('grafana').that_comes_before('Package[grafana]') } end From 76d7db0756bd888fd5f903b2c950db5070475f82 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 15 Apr 2017 16:20:38 +0200 Subject: [PATCH 050/146] modulesync 0.21.0 --- .github/CONTRIBUTING.md | 4 +++ .msync.yml | 2 +- .overcommit.yml | 63 +++++++++++++++++++++++++++++++++++++++++ .rubocop.yml | 2 ++ .travis.yml | 17 +++++++---- Gemfile | 16 +++++------ 6 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 .overcommit.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5574191a6..602f324b9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -98,3 +98,7 @@ If you don't want to have to recreate the virtual machine every time you can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`. + +The easiest way to debug in a docker container is to open a shell: + + docker exec -it -u root ${container_id_or_name} bash diff --git a/.msync.yml b/.msync.yml index a8e6a4ee7..540f0cea4 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.20.1' +modulesync_config_version: '0.21.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 000000000..31699e747 --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,63 @@ +# Managed by https://github.com/voxpupuli/modulesync_configs +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + PuppetLint: + enabled: true + description: 'Runs puppet-lint on modified files only' + command: ['bundle', 'exec', 'puppet-lint'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'test' + - 'rubocop' + command: [ 'bundle', 'exec', 'rake' ] diff --git a/.rubocop.yml b/.rubocop.yml index ef85ceb41..4e113f037 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,6 +9,8 @@ AllCops: - .vendor/**/* - pkg/**/* - spec/fixtures/**/* + - Gemfile + - Rakefile Lint/ConditionPosition: Enabled: True diff --git a/.travis.yml b/.travis.yml index de8b79ceb..3784ed449 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ sudo: false dist: trusty language: ruby cache: bundler -bundler_args: --without system_tests development before_install: - bundle -v - rm Gemfile.lock || true @@ -17,16 +16,22 @@ matrix: fast_finish: true include: - rvm: 2.1.9 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.2.6 + - rvm: 2.2.7 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.3.3 + - rvm: 2.3.4 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.0 + - rvm: 2.4.1 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.0 + - rvm: 2.4.1 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=rubocop - - rvm: 2.4.0 + - rvm: 2.4.1 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: diff --git a/Gemfile b/Gemfile index 6321c0e22..d8713fa2a 100644 --- a/Gemfile +++ b/Gemfile @@ -11,8 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.0.1', :require => false - gem 'parallel_tests', :require => false + gem 'puppetlabs_spec_helper', '~> 2.1.1', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false @@ -26,10 +25,10 @@ group :test do gem 'metadata-json-lint', :require => false gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' - gem 'puppet-strings', '~> 1.0.0', :require => false + gem 'puppet-strings', '~> 1.0', :require => false gem 'redcarpet', :require => false - gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0' - gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop', '~> 0.48.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'mocha', '>= 1.2.1', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false @@ -40,9 +39,10 @@ group :test do end group :development do - gem 'travis', :require => false - gem 'travis-lint', :require => false - gem 'guard-rake', :require => false + gem 'travis', :require => false + gem 'travis-lint', :require => false + gem 'guard-rake', :require => false + gem 'overcommit', '~> 0.39.1', :require => false end group :system_tests do From fbfb9df7c96407360c40419767cc09cd9dd6006e Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 15 Apr 2017 16:20:50 +0200 Subject: [PATCH 051/146] rubocop: autofixes --- spec/classes/grafana_spec.rb | 3 +++ spec/unit/puppet/type/grafana_dashboard_type_spec.rb | 1 + spec/unit/puppet/type/grafana_datasource_type_spec.rb | 1 + 3 files changed, 5 insertions(+) diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index abc1566cd..4f1e152ab 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -24,6 +24,7 @@ '/etc/grafana/grafana.ini' end end + context 'with default values' do it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('grafana') } @@ -183,6 +184,7 @@ ensure => present, }' end + describe 'do NOT create grafana user' do it { is_expected.not_to contain_user('grafana').with_ensure('present').with_home(install_dir) } end @@ -196,6 +198,7 @@ hasstatus => true, }' end + # let(:params) {{ :service_name => 'grafana-server'}} describe 'do NOT run service' do it { is_expected.not_to contain_service('grafana-server').with_hasrestart(false).with_hasstatus(false) } diff --git a/spec/unit/puppet/type/grafana_dashboard_type_spec.rb b/spec/unit/puppet/type/grafana_dashboard_type_spec.rb index dc60cb3ae..18f9a88e6 100644 --- a/spec/unit/puppet/type/grafana_dashboard_type_spec.rb +++ b/spec/unit/puppet/type/grafana_dashboard_type_spec.rb @@ -17,6 +17,7 @@ let(:gdashboard) do described_class.new name: 'foo', grafana_url: 'http://example.com/', content: '{}', ensure: :present end + context 'when setting parameters' do it "fails if grafana_url isn't HTTP-based" do expect do diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index 76397c748..8688f4b35 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -17,6 +17,7 @@ let(:gdatasource) do described_class.new name: 'foo', grafana_url: 'http://example.com', url: 'http://influx.example.com' end + context 'when setting parameters' do it "fails if grafana_url isn't HTTP-based" do expect do From 6f3f48d8daf2a16702922e2d22b5713f8d728a00 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 30 Apr 2017 01:23:14 +0200 Subject: [PATCH 052/146] drop newvalues for type property in datasource We want to support custom plugins, they may add new datasources, so a hardcoded list is a bad idea. --- lib/puppet/type/grafana_datasource.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 086386d35..6cb413243 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -52,7 +52,6 @@ newproperty(:type) do desc 'The datasource type' - newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus) end newproperty(:user) do From 7e4f1ee8032267d1ae4fa98c9a1b321431513e40 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 30 Apr 2017 01:24:20 +0200 Subject: [PATCH 053/146] Add defined resource for custom plugins This is a simple wrapper around the grafana CLI. It allows us to install custom plugins. --- manifests/plugin.pp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 manifests/plugin.pp diff --git a/manifests/plugin.pp b/manifests/plugin.pp new file mode 100644 index 000000000..ff10a9079 --- /dev/null +++ b/manifests/plugin.pp @@ -0,0 +1,10 @@ +# defined resource to add plugins to grafana via CLI +# this won't work with the docker installation method +define grafana::plugin( + String $plugin = $title, +){ + exec{"install ${plugin}": + command => "/usr/bin/grafana-cli plugins install ${plugin}", + creates => "/var/lib/grafana/plugins/${plugin}", + } +} From 5215d210212b4965c42477887acdd854cd4d30d1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 30 Apr 2017 01:28:42 +0200 Subject: [PATCH 054/146] update README.md for grafana::plugin --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 362c70c09..9b8a5a77a 100644 --- a/README.md +++ b/README.md @@ -362,7 +362,7 @@ grafana_datasource { 'influxdb': } ``` -Available types are: influxdb, elasticsearch, graphite, kairosdb, opentsdb, prometheus +Available default types are: influxdb, elasticsearch, graphite, kairosdb, opentsdb, prometheus Access mode determines how Grafana connects to the datasource, either `direct` from the browser, or `proxy` to send requests via grafana. @@ -370,6 +370,15 @@ from the browser, or `proxy` to send requests via grafana. Authentication is optional, as is `database`; additional `json_data` can be provided to allow custom configuration options. +##### `grafana::plugin` + +There exists a custom defined resource which wraps grafana-cli to install +plugins. Deinstallation isn't supported right now, also docker support +completely missing. Example usage: + +```puppet +grafana::plugin{'grafana-simple-json-datasource':} +``` ## Limitations This module has been tested on Ubuntu 14.04, using each of the 'archive', 'docker' From f25b4c5c129bfc50fc02688c00ee92282b50a709 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 30 Apr 2017 01:36:37 +0200 Subject: [PATCH 055/146] add tests for grafana:plugin --- spec/defines/plugin_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spec/defines/plugin_spec.rb diff --git a/spec/defines/plugin_spec.rb b/spec/defines/plugin_spec.rb new file mode 100644 index 000000000..6b1fb9950 --- /dev/null +++ b/spec/defines/plugin_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'grafana::plugin', type: :define do + on_supported_os.each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + let :title do + 'grafana-simple-json-datasource' + end + + context 'with all defaults' do + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_exec("install #{title}") } + end + end + end +end From 20585cd26badc943d174684465e3d219daed8bfd Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 11 Jun 2017 13:48:51 +0200 Subject: [PATCH 056/146] modulesync 0.21.3 --- .gitignore | 1 + .msync.yml | 2 +- .rspec_parallel | 1 + .rubocop.yml | 9 +++++++++ Gemfile | 1 + spec/acceptance/nodesets/archlinux-2-x64.yml | 13 +++++++++++++ spec/acceptance/nodesets/docker/ubuntu-16.04.yml | 2 +- 7 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .rspec_parallel create mode 100644 spec/acceptance/nodesets/archlinux-2-x64.yml diff --git a/.gitignore b/.gitignore index 0d629b0c1..e9b3cf4bc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ Puppetfile.lock *.iml .*.sw? .yardoc/ +Guardfile diff --git a/.msync.yml b/.msync.yml index 540f0cea4..4abde2202 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.21.0' +modulesync_config_version: '0.21.3' diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 000000000..e4d136b75 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1 @@ +--format progress diff --git a/.rubocop.yml b/.rubocop.yml index 4e113f037..d92e4e456 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,7 @@ AllCops: - spec/fixtures/**/* - Gemfile - Rakefile + - Guardfile Lint/ConditionPosition: Enabled: True @@ -502,6 +503,10 @@ Style/ClosingParenthesisIndentation: # RSpec +RSpec/BeforeAfterAll: + Exclude: + - spec/acceptance/**/* + # We don't use rspec in this way RSpec/DescribeClass: Enabled: False @@ -521,6 +526,10 @@ RSpec/RepeatedDescription: RSpec/NestedGroups: Enabled: False +# this is broken on ruby1.9 +Style/IndentHeredoc: + Enabled: False + # disable Yaml safe_load. This is needed to support ruby2.0.0 development envs Security/YAMLLoad: Enabled: false diff --git a/Gemfile b/Gemfile index d8713fa2a..425e49415 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ group :test do gem 'github_changelog_generator', '~> 1.13.0', :require => false if RUBY_VERSION < '2.2.2' gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2' + gem 'parallel_tests', :require => false gem 'toml', :require => false end diff --git a/spec/acceptance/nodesets/archlinux-2-x64.yml b/spec/acceptance/nodesets/archlinux-2-x64.yml new file mode 100644 index 000000000..89b63003f --- /dev/null +++ b/spec/acceptance/nodesets/archlinux-2-x64.yml @@ -0,0 +1,13 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + archlinux-2-x64: + roles: + - master + platform: archlinux-2-x64 + box: archlinux/archlinux + hypervisor: vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml index 92a93cb73..bac2d5b34 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml @@ -10,7 +10,7 @@ HOSTS: docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: - - 'apt-get install -y net-tools wget' + - 'apt-get install -y net-tools wget locales' - 'locale-gen en_US.UTF-8' CONFIG: trace_limit: 200 From 6851a88267524dca0f622d4759464b226dd08b41 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 11 Jun 2017 16:46:24 +0200 Subject: [PATCH 057/146] disable rubocop false/positive --- spec/spec_helper_acceptance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 3d18c478b..3882833de 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,7 +1,7 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' -hosts.each do |_host| +hosts.each do |_host| # rubocop: disable RSpec/IteratedExpectation # Install Puppet install_puppet end From 9d601c1b5e433e3f5d60716c27962471ab1a1a88 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Sun, 6 Aug 2017 17:34:15 -0700 Subject: [PATCH 058/146] Support newer versions of puppetlabs/apt module --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 866fe794c..934975e75 100644 --- a/metadata.json +++ b/metadata.json @@ -22,7 +22,7 @@ }, { "name": "puppetlabs/apt", - "version_requirement": ">=2.1.0 < 3.0.0" + "version_requirement": ">=2.1.0 < 5.0.0" }, { "name": "puppetlabs/stdlib", From e5b06c250cbbe04c91230ad36b5a004142691ba2 Mon Sep 17 00:00:00 2001 From: David Hollinger Date: Fri, 15 Sep 2017 16:28:47 -0500 Subject: [PATCH 059/146] modulesync 2017-09-15 --- .msync.yml | 2 +- .rubocop.yml | 77 +++++++++---------- .travis.yml | 12 +-- Gemfile | 13 ++-- Rakefile | 7 +- .../nodesets/docker/ubuntu-14.04.yml | 2 +- .../nodesets/docker/ubuntu-16.04.yml | 2 +- 7 files changed, 53 insertions(+), 62 deletions(-) diff --git a/.msync.yml b/.msync.yml index 4abde2202..0a4a57db7 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.21.3' +modulesync_config_version: '1.1.0' diff --git a/.rubocop.yml b/.rubocop.yml index d92e4e456..b1a952131 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,7 +51,7 @@ Lint/AmbiguousOperator: Lint/AssignmentInCondition: Enabled: True -Style/SpaceBeforeComment: +Layout/SpaceBeforeComment: Enabled: True Style/AndOr: @@ -119,7 +119,7 @@ Lint/UselessAssignment: Lint/Void: Enabled: True -Style/AccessModifierIndentation: +Layout/AccessModifierIndentation: Enabled: True Style/AccessorMethodName: @@ -128,13 +128,13 @@ Style/AccessorMethodName: Style/Alias: Enabled: True -Style/AlignArray: +Layout/AlignArray: Enabled: True -Style/AlignHash: +Layout/AlignHash: Enabled: True -Style/AlignParameters: +Layout/AlignParameters: Enabled: True Metrics/BlockNesting: @@ -152,7 +152,7 @@ Style/BracesAroundHashParameters: Style/CaseEquality: Enabled: True -Style/CaseIndentation: +Layout/CaseIndentation: Enabled: True Style/CharacterLiteral: @@ -186,64 +186,64 @@ Style/WordArray: Style/UnneededPercentQ: Enabled: True -Style/Tab: +Layout/Tab: Enabled: True -Style/SpaceBeforeSemicolon: +Layout/SpaceBeforeSemicolon: Enabled: True -Style/TrailingBlankLines: +Layout/TrailingBlankLines: Enabled: True -Style/SpaceInsideBlockBraces: +Layout/SpaceInsideBlockBraces: Enabled: True -Style/SpaceInsideBrackets: +Layout/SpaceInsideBrackets: Enabled: True -Style/SpaceInsideHashLiteralBraces: +Layout/SpaceInsideHashLiteralBraces: Enabled: True -Style/SpaceInsideParens: +Layout/SpaceInsideParens: Enabled: True -Style/LeadingCommentSpace: +Layout/LeadingCommentSpace: Enabled: True -Style/SpaceBeforeFirstArg: +Layout/SpaceBeforeFirstArg: Enabled: True -Style/SpaceAfterColon: +Layout/SpaceAfterColon: Enabled: True -Style/SpaceAfterComma: +Layout/SpaceAfterComma: Enabled: True -Style/SpaceAfterMethodName: +Layout/SpaceAfterMethodName: Enabled: True -Style/SpaceAfterNot: +Layout/SpaceAfterNot: Enabled: True -Style/SpaceAfterSemicolon: +Layout/SpaceAfterSemicolon: Enabled: True -Style/SpaceAroundEqualsInParameterDefault: +Layout/SpaceAroundEqualsInParameterDefault: Enabled: True -Style/SpaceAroundOperators: +Layout/SpaceAroundOperators: Enabled: True -Style/SpaceBeforeBlockBraces: +Layout/SpaceBeforeBlockBraces: Enabled: True -Style/SpaceBeforeComma: +Layout/SpaceBeforeComma: Enabled: True Style/CollectionMethods: Enabled: True -Style/CommentIndentation: +Layout/CommentIndentation: Enabled: True Style/ColonMethodCall: @@ -268,7 +268,7 @@ Style/DefWithParentheses: Style/PreferredHashMethods: Enabled: True -Style/DotPosition: +Layout/DotPosition: EnforcedStyle: trailing Style/DoubleNegation: @@ -277,25 +277,25 @@ Style/DoubleNegation: Style/EachWithObject: Enabled: True -Style/EmptyLineBetweenDefs: +Layout/EmptyLineBetweenDefs: Enabled: True -Style/IndentArray: +Layout/IndentArray: Enabled: True -Style/IndentHash: +Layout/IndentHash: Enabled: True -Style/IndentationConsistency: +Layout/IndentationConsistency: Enabled: True -Style/IndentationWidth: +Layout/IndentationWidth: Enabled: True -Style/EmptyLines: +Layout/EmptyLines: Enabled: True -Style/EmptyLinesAroundAccessModifier: +Layout/EmptyLinesAroundAccessModifier: Enabled: True Style/EmptyLiteral: @@ -314,7 +314,7 @@ Style/MethodDefParentheses: Style/LineEndConcatenation: Enabled: True -Style/TrailingWhitespace: +Layout/TrailingWhitespace: Enabled: True Style/StringLiterals: @@ -466,9 +466,6 @@ Metrics/ParameterLists: Lint/RequireParentheses: Enabled: True -Style/SpaceBeforeFirstArg: - Enabled: True - Style/ModuleFunction: Enabled: True @@ -484,7 +481,7 @@ Style/Encoding: Style/BlockDelimiters: Enabled: True -Style/MultilineBlockLayout: +Layout/MultilineBlockLayout: Enabled: True # 'Complexity' is very relative @@ -498,7 +495,7 @@ Metrics/PerceivedComplexity: Lint/UselessAssignment: Enabled: True -Style/ClosingParenthesisIndentation: +Layout/ClosingParenthesisIndentation: Enabled: True # RSpec @@ -527,7 +524,7 @@ RSpec/NestedGroups: Enabled: False # this is broken on ruby1.9 -Style/IndentHeredoc: +Layout/IndentHeredoc: Enabled: False # disable Yaml safe_load. This is needed to support ruby2.0.0 development envs diff --git a/.travis.yml b/.travis.yml index 3784ed449..003f0acd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,21 +18,15 @@ matrix: - rvm: 2.1.9 bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.2.7 - bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.3.4 - bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 4.0" CHECK=test - rvm: 2.4.1 bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 4.0" CHECK=test + env: PUPPET_VERSION="~> 5.0" CHECK=test - rvm: 2.4.1 bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 4.0" CHECK=rubocop + env: PUPPET_VERSION="~> 5.0" CHECK=rubocop - rvm: 2.4.1 bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes + env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: - master diff --git a/Gemfile b/Gemfile index 425e49415..9e331c59e 100644 --- a/Gemfile +++ b/Gemfile @@ -11,11 +11,10 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.1.1', :require => false + gem 'puppetlabs_spec_helper', '~> 2.2.0', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false - gem 'puppet-lint-absolute_classname-check', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-version_comparison-check', :require => false @@ -24,10 +23,10 @@ group :test do gem 'puppet-lint-variable_contains_upcase', :require => false gem 'metadata-json-lint', :require => false gem 'puppet-blacksmith', :require => false - gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' + gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' gem 'puppet-strings', '~> 1.0', :require => false gem 'redcarpet', :require => false - gem 'rubocop', '~> 0.48.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0' gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'mocha', '>= 1.2.1', :require => false gem 'coveralls', :require => false @@ -43,7 +42,7 @@ group :development do gem 'travis', :require => false gem 'travis-lint', :require => false gem 'guard-rake', :require => false - gem 'overcommit', '~> 0.39.1', :require => false + gem 'overcommit', '>= 0.39.1', :require => false end group :system_tests do @@ -64,10 +63,10 @@ end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else - gem 'facter', :require => false, :groups => [:test] +gem 'facter', :require => false, :groups => [:test] end -ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 82c896088..ab9411ba2 100644 --- a/Rakefile +++ b/Rakefile @@ -35,9 +35,10 @@ begin require 'github_changelog_generator/task' GitHubChangelogGenerator::RakeTask.new :changelog do |config| version = (Blacksmith::Modulefile.new).version - config.future_release = "v#{version}" - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not impact the functionality of the module." - config.exclude_labels = %w{duplicate question invalid wontfix modulesync} + config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/ + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} + config.user = 'voxpupuli' end rescue LoadError end diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml index 54d5e5a5b..ae4530444 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml @@ -12,7 +12,7 @@ HOSTS: docker_image_commands: - 'rm /usr/sbin/policy-rc.d' - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' - - 'apt-get install -y net-tools wget' + - 'apt-get install -y net-tools wget apt-transport-https' - 'locale-gen en_US.UTF-8' CONFIG: trace_limit: 200 diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml index bac2d5b34..2d173c5b9 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml @@ -10,7 +10,7 @@ HOSTS: docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: - - 'apt-get install -y net-tools wget locales' + - 'apt-get install -y net-tools wget locales apt-transport-https' - 'locale-gen en_US.UTF-8' CONFIG: trace_limit: 200 From df07d08951f57768e9d98fb1a810e6d3e8135f6b Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Wed, 20 Sep 2017 15:00:19 +1000 Subject: [PATCH 060/146] Fix typo in provider --- lib/puppet/provider/grafana.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/grafana.rb b/lib/puppet/provider/grafana.rb index 2229f852b..0ebb0ad99 100644 --- a/lib/puppet/provider/grafana.rb +++ b/lib/puppet/provider/grafana.rb @@ -68,7 +68,7 @@ def send_request(operation = 'GET', path = '', data = nil, search_path = {}) end request.content_type = 'application/json' - if resource[:grafana_user] && resource[:grafana_user] + if resource[:grafana_user] && resource[:grafana_password] request.basic_auth resource[:grafana_user], resource[:grafana_password] end From 7c155e253d4602ce3afafc03b6a42db5cf47bb4c Mon Sep 17 00:00:00 2001 From: William Yardley Date: Tue, 19 Sep 2017 23:32:00 -0700 Subject: [PATCH 061/146] Bump version to 4.5.1. --- manifests/install.pp | 7 ++++--- manifests/params.pp | 2 +- spec/classes/grafana_spec.rb | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 872c76973..ef6cdeebd 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,11 +1,12 @@ # == Class grafana::install # class grafana::install { + $base_url = 'https://s3-us-west-2.amazonaws.com/grafana-releases/release' if $::grafana::archive_source != undef { $real_archive_source = $::grafana::archive_source } else { - $real_archive_source = "https://grafanarel.s3.amazonaws.com/builds/grafana-${::grafana::version}.linux-x64.tar.gz" + $real_archive_source = "${base_url}/grafana-${::grafana::version}.linux-x64.tar.gz" } if $::grafana::package_source != undef { @@ -13,8 +14,8 @@ } else { $real_package_source = $::osfamily ? { - /(RedHat|Amazon)/ => "https://grafanarel.s3.amazonaws.com/builds/grafana-${::grafana::version}-${::grafana::rpm_iteration}.x86_64.rpm", - 'Debian' => "https://grafanarel.s3.amazonaws.com/builds/grafana_${::grafana::version}_amd64.deb", + /(RedHat|Amazon)/ => "${base_url}/grafana-${::grafana::version}-${::grafana::rpm_iteration}.x86_64.rpm", + 'Debian' => "${base_url}/builds/grafana_${::grafana::version}_amd64.deb", default => $real_archive_source, } } diff --git a/manifests/params.pp b/manifests/params.pp index fb8aa07a0..4407a1c5e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,7 +17,7 @@ $package_source = undef $rpm_iteration = '1' $repo_name = 'stable' - $version = '2.5.0' + $version = '4.5.1' case $::osfamily { 'Archlinux': { $manage_package_repo = false diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 4f1e152ab..83decb6d8 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -91,7 +91,7 @@ end describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('2.5.0') } + it { is_expected.to contain_package('grafana').with_ensure('4.5.1') } end when 'RedHat' describe 'yum repo dependencies first' do @@ -104,7 +104,7 @@ end describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('2.5.0-1') } + it { is_expected.to contain_package('grafana').with_ensure('4.5.1-1') } end end end @@ -151,7 +151,7 @@ install_dir = '/usr/share/grafana' service_config = '/usr/share/grafana/conf/custom.ini' - archive_source = 'https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0.linux-x64.tar.gz' + archive_source = 'https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.5.1.linux-x64.tar.gz' describe 'extract archive to install_dir' do it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_ensure('present') } From e064b4c7d8096f2d71fd78a79ed159e5c6edf097 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Wed, 20 Sep 2017 16:58:36 +1000 Subject: [PATCH 062/146] grafana_user custom resource --- README.md | 16 ++ lib/puppet/provider/grafana_user/grafana.rb | 161 ++++++++++++++++++ lib/puppet/type/grafana_user.rb | 66 +++++++ .../puppet/type/grafana_user_type_spec.rb | 50 ++++++ 4 files changed, 293 insertions(+) create mode 100644 lib/puppet/provider/grafana_user/grafana.rb create mode 100644 lib/puppet/type/grafana_user.rb create mode 100644 spec/unit/puppet/type/grafana_user_type_spec.rb diff --git a/README.md b/README.md index 9b8a5a77a..6f6973968 100644 --- a/README.md +++ b/README.md @@ -379,6 +379,22 @@ completely missing. Example usage: ```puppet grafana::plugin{'grafana-simple-json-datasource':} ``` + +##### `grafana::user` + +Creates and manages a global grafana user via the API. + +```puppet +grafana_user { 'username': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => '5ecretPassw0rd', + full_name => 'John Doe', + password => 'Us3r5ecret', + email => 'john@example.com', +} +``` + ## Limitations This module has been tested on Ubuntu 14.04, using each of the 'archive', 'docker' diff --git a/lib/puppet/provider/grafana_user/grafana.rb b/lib/puppet/provider/grafana_user/grafana.rb new file mode 100644 index 000000000..da0eeffdf --- /dev/null +++ b/lib/puppet/provider/grafana_user/grafana.rb @@ -0,0 +1,161 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +require 'json' + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'grafana')) + +Puppet::Type.type(:grafana_user).provide(:grafana, parent: Puppet::Provider::Grafana) do + desc 'Support for Grafana users' + + defaultfor kernel: 'Linux' + + def users + response = send_request('GET', '/api/users') + if response.code != '200' + raise format('Fail to retrieve users (HTTP response: %s/%s)', response.code, response.body) + end + + begin + users = JSON.parse(response.body) + + users.map { |x| x['id'] }.map do |id| + response = send_request 'GET', format('/api/users/%s', id) + if response.code != '200' + raise format('Fail to retrieve user %d (HTTP response: %s/%s)', id, response.code, response.body) + end + + user = JSON.parse(response.body) + { + id: id, + name: user['login'], + full_name: user['name'], + email: user['email'], + theme: user['theme'], + password: nil, + is_admin: user['isGrafanaAdmin'] ? :true : :false + } + end + rescue JSON::ParserError + raise format('Fail to parse response: %s', response.body) + end + end + + def user + @user = users.find { |x| x[:name] == resource[:name] } unless @user + @user + end + + attr_writer :user + + def name + user[:name] + end + + def name=(value) + resource[:name] = value + save_user + end + + def full_name + user[:full_name] + end + + def full_name=(value) + resource[:full_name] = value + save_user + end + + def email + user[:email] + end + + def email=(value) + resource[:email] = value + save_user + end + + def theme + user[:theme] + end + + def theme=(value) + resource[:theme] = value + save_user + end + + def password + user[:password] + end + + def password=(value) + resource[:password] = value + save_user + end + + # rubocop:disable Style/PredicateName + def is_admin + user[:is_admin] + end + + def is_admin=(value) + resource[:is_admin] = value + save_user + end + # rubocop:enable Style/PredicateName + + def save_user + data = { + login: resource[:name], + name: resource[:full_name], + email: resource[:email], + password: resource[:password], + theme: resource[:theme], + isGrafanaAdmin: (resource[:is_admin] == :true) + } + + if user.nil? + response = send_request('POST', '/api/admin/users', data) + else + data[:id] = user[:id] + send_request 'PUT', format('/api/admin/users/%s/password', user[:id]), password: data.delete(:password) + send_request 'PUT', format('/api/admin/users/%s/permissions', user[:id]), isGrafanaAdmin: data.delete(:isGrafanaAdmin) + response = send_request 'PUT', format('/api/users/%s', user[:id]), data + end + + if response.code != '200' + raise format('Failed to create user %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) + end + self.user = nil + end + + def delete_user + response = send_request 'DELETE', format('/api/admin/users/%s', user[:id]) + + if response.code != '200' + raise format('Failed to delete user %s (HTTP response: %s/%s', resource[:name], response.code, response.body) + end + self.user = nil + end + + def create + save_user + end + + def destroy + delete_user + end + + def exists? + user + end +end diff --git a/lib/puppet/type/grafana_user.rb b/lib/puppet/type/grafana_user.rb new file mode 100644 index 000000000..8b15bb010 --- /dev/null +++ b/lib/puppet/type/grafana_user.rb @@ -0,0 +1,66 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +Puppet::Type.newtype(:grafana_user) do + @doc = 'Manage users in Grafana' + + ensurable + + newparam(:name, namevar: true) do + desc 'The username of the user.' + end + + newparam(:grafana_url) do + desc 'The URL of the Grafana server' + defaultto '' + + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end + end + end + + newparam(:grafana_user) do + desc 'The username for the Grafana server' + end + + newparam(:grafana_password) do + desc 'The password for the Grafana server' + end + + newparam(:full_name) do + desc 'The full name of the user.' + end + + newproperty(:password) do + desc 'The password for the user' + end + + newproperty(:email) do + desc 'The email for the user' + end + + newproperty(:theme) do + desc 'The theme for the user' + end + + newproperty(:is_admin) do + desc 'Whether the user is a grafana admin' + newvalues(:true, :false) + defaultto :false + end + + autorequire(:service) do + 'grafana-server' + end +end diff --git a/spec/unit/puppet/type/grafana_user_type_spec.rb b/spec/unit/puppet/type/grafana_user_type_spec.rb new file mode 100644 index 000000000..f8f63b999 --- /dev/null +++ b/spec/unit/puppet/type/grafana_user_type_spec.rb @@ -0,0 +1,50 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +require 'spec_helper' + +describe Puppet::Type.type(:grafana_user) do + let(:guser) do + described_class.new name: 'test', full_name: 'Mr tester', password: 't3st', grafana_url: 'http://example.com/' + end + + context 'when setting parameters' do + it "fails if grafana_url isn't HTTP-based" do + expect do + described_class.new name: 'test', grafana_url: 'example.com' + end.to raise_error(Puppet::Error, %r{not a valid URL}) + end + + # rubocop:disable RSpec/MultipleExpectations + it 'accepts valid parameters' do + expect(guser[:name]).to eq('test') + expect(guser[:full_name]).to eq('Mr tester') + expect(guser[:password]).to eq('t3st') + expect(guser[:grafana_url]).to eq('http://example.com/') + end + it 'autorequires the grafana-server for proper ordering' do + catalog = Puppet::Resource::Catalog.new + service = Puppet::Type.type(:service).new(name: 'grafana-server') + catalog.add_resource service + catalog.add_resource guser + + relationship = guser.autorequire.find do |rel| + (rel.source.to_s == 'Service[grafana-server]') && (rel.target.to_s == guser.to_s) + end + expect(relationship).to be_a Puppet::Relationship + end + it 'does not autorequire the service it is not managed' do + catalog = Puppet::Resource::Catalog.new + catalog.add_resource guser + expect(guser.autorequire).to be_empty + end + end +end From d09835a9453c50ea4c803a15fe2f44f1e57542e3 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Tue, 19 Sep 2017 23:33:18 -0700 Subject: [PATCH 063/146] Add acceptance tests to run in Travis. --- .sync.yml | 3 +++ .travis.yml | 12 ++++++++++++ Gemfile | 3 ++- spec/acceptance/class_spec.rb | 2 +- spec/spec_helper_acceptance.rb | 27 +++++++++------------------ 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.sync.yml b/.sync.yml index 928d81f77..578b586c8 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,6 +1,9 @@ --- .travis.yml: secure: "qtLA1TPKaVgd9rvi0kkF2v0CP0QLls//lFHJ9IowTYNi5O+0dx7OxZCK3g4nkNWWbsujS464/YFJqVRWoXIeLIyFtfMKkaRAiuaukxOQqnzD+BsnpYYeo2zeZPCvMbB94+7G7JQ+jpuzlsHX6j+H6LQEj6+kXzd8NAj8rlygrL8XcFN3bA8XM/unCvqn2b2sduShExVl0mnNMIvZMHCbdrEzByXkz+FmyGYCay+feDIYbIbhzYLNnh6BcDkq24TxRmVOdEnUkPG6ZU0UJlNqBZB++zAIazR25NyX+b22/CFp6D6YJKkJvBNnywGUNNF21s4a6kPoEnUVBEO6yg5sDkKgp8nAvsmUnI8A1tfRFWKejxHZN3YqveY60xiNIUEHJU4MjEE6VVi9WpNW8CpJbfP/z3RtlU5n4ckSER7mb/ApxspUPJRzyMKjobDP12WU/bgXinzdNMu6PH9H56WkDpRNtIYnNhIAuirdfDr2Ok5z9/9yObUt/OQddM4wrOnMG7lyyUIzAO2OOJbIcOaZBedTKccpCu6k2mOkUHhMutf1D0bde5IGhrs7E54V2ZNxX5Dopv5eOrmVN2OxdcB9g8nmISxX6Tty/BNrTBvt7urthGjUJrjlnNE/K1595KmcWa6PGWUcYZyzdKeWqiA3+iWKSmnx1Ri0lsml5Z/a4QM=" + docker_sets: + - set: docker/ubuntu-16.04 + - set: docker/centos-7 Gemfile: optional: ':test': diff --git a/.travis.yml b/.travis.yml index 003f0acd7..7392419f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,18 @@ script: matrix: fast_finish: true include: + - rvm: 2.4.1 + bundler_args: --without development + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 CHECK=beaker + services: docker + sudo: required + - rvm: 2.4.1 + bundler_args: --without development + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker + services: docker + sudo: required - rvm: 2.1.9 bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test diff --git a/Gemfile b/Gemfile index 9e331c59e..2579f05db 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,7 @@ group :system_tests do end gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false end @@ -63,7 +64,7 @@ end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else -gem 'facter', :require => false, :groups => [:test] + gem 'facter', :require => false, :groups => [:test] end ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 759ad09f3..4e65250a9 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -17,7 +17,7 @@ class { 'grafana': } it { is_expected.to be_installed } end - describe service('grafana') do + describe service('grafana-server') do it { is_expected.to be_enabled } it { is_expected.to be_running } end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 3882833de..f60ee4a59 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,24 +1,15 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' +require 'beaker-rspec' +require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' -hosts.each do |_host| # rubocop: disable RSpec/IteratedExpectation - # Install Puppet - install_puppet -end +run_puppet_install_helper +install_module +install_module_dependencies -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) +# Install additional modules for soft deps +install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 5.0.0') +RSpec.configure do |c| # Readable test descriptions c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - # Install module and dependencies - puppet_module_install(source: proj_root, module_name: 'grafana') - hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1] - end - end end From c7bc5071087877d93d058e5c057b087817941391 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Tue, 19 Sep 2017 23:46:43 -0700 Subject: [PATCH 064/146] Rework how classes are ordered --- manifests/init.pp | 12 +++++++----- spec/classes/grafana_spec.rb | 6 ++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index d68a39283..467ffc5c5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -92,9 +92,11 @@ fail('cfg parameter must be a hash') } - anchor { 'grafana::begin': } - -> class { '::grafana::install': } - -> class { '::grafana::config': } - ~> class { '::grafana::service': } - -> anchor { 'grafana::end': } + contain grafana::install + contain grafana::config + contain grafana::service + + Class['grafana::install'] + -> Class['grafana::config'] + ~> Class['grafana::service'] } diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 83decb6d8..c66c95879 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -28,12 +28,10 @@ context 'with default values' do it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('grafana') } - it { is_expected.to contain_anchor('grafana::begin') } it { is_expected.to contain_class('grafana::params') } - it { is_expected.to contain_class('grafana::install') } - it { is_expected.to contain_class('grafana::config') } + it { is_expected.to contain_class('grafana::install').that_comes_before('Class[grafana::config]') } + it { is_expected.to contain_class('grafana::config').that_notifies('Class[grafana::service]') } it { is_expected.to contain_class('grafana::service') } - it { is_expected.to contain_anchor('grafana::end') } end context 'with parameter install_method is set to package' do From 7c9a00a8461f2623fb4cf4be75757bc5a19fab2c Mon Sep 17 00:00:00 2001 From: William Yardley Date: Tue, 19 Sep 2017 23:59:28 -0700 Subject: [PATCH 065/146] updates to metadata --- README.md | 10 ++++++++++ metadata.json | 17 ++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9b8a5a77a..73e3bd6f8 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ 1. [Overview](#overview) 1. [Module Description](#module-description) 1. [Setup](#setup) + * [Requirements](#requirements) * [Beginning with Grafana](#beginning-with-grafana) 1. [Usage](#usage) * [Classes and Defined Types](#classes-and-defined-types) @@ -40,6 +41,15 @@ This module will: package source * Perform basic configuration of Grafana +### Requirements + +* If using an operating system of the Debian-based family, and the "repo" +`install_method`, you will need to ensure that +[puppetlabs-apt](https://forge.puppet.com/puppetlabs/apt) version 4.x is +installed. +* If using Docker, you will need the +[garethr/docker](https://forge.puppet.com/garethr/docker) module version 5.x + ### Beginning with Grafana To install Grafana with the default parameters: diff --git a/metadata.json b/metadata.json index 934975e75..ca080ef7c 100644 --- a/metadata.json +++ b/metadata.json @@ -8,10 +8,6 @@ "project_page": "https://github.com/voxpupuli/puppet-grafana", "issue_url": "https://github.com/voxpupuli/puppet-grafana/issues", "dependencies": [ - { - "name": "garethr/docker", - "version_requirement": ">= 5.0.0 < 6.0.0" - }, { "name": "maestrodev/wget", "version_requirement": ">= 1.7.3 < 2.0.0" @@ -20,10 +16,6 @@ "name": "puppet/archive", "version_requirement": ">= 1.0.1 < 2.0.0" }, - { - "name": "puppetlabs/apt", - "version_requirement": ">=2.1.0 < 5.0.0" - }, { "name": "puppetlabs/stdlib", "version_requirement": ">=4.6.0 < 5.0.0" @@ -39,19 +31,22 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "14.04" + "14.04", + "16.04" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ + "6", "6" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "6" + "6", + "7" ] }, { @@ -61,7 +56,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.6.1 < 5.0.0" + "version_requirement": ">= 4.7.1 < 6.0.0" } ], "tags": [ From 7742b2f44141ee2a42dfdb619d0e104df3df80d0 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Tue, 19 Sep 2017 23:17:11 -0700 Subject: [PATCH 066/146] Create grafana_plugin resource type, and create grafana::plugins passthrough --- README.md | 18 ++++-- .../provider/grafana_plugin/grafana_cli.rb | 56 +++++++++++++++++++ lib/puppet/type/grafana_plugin.rb | 31 ++++++++++ manifests/init.pp | 12 +++- manifests/plugin.pp | 10 ---- spec/acceptance/grafana_plugin_spec.rb | 38 +++++++++++++ spec/classes/grafana_spec.rb | 15 +++++ spec/defines/plugin_spec.rb | 20 ------- .../grafana_plugin/grafana_cli_spec.rb | 53 ++++++++++++++++++ spec/unit/puppet/type/grafana_plugin_spec.rb | 16 ++++++ 10 files changed, 232 insertions(+), 37 deletions(-) create mode 100644 lib/puppet/provider/grafana_plugin/grafana_cli.rb create mode 100644 lib/puppet/type/grafana_plugin.rb delete mode 100644 manifests/plugin.pp create mode 100644 spec/acceptance/grafana_plugin_spec.rb delete mode 100644 spec/defines/plugin_spec.rb create mode 100644 spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb create mode 100644 spec/unit/puppet/type/grafana_plugin_spec.rb diff --git a/README.md b/README.md index d979916b0..833099497 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,11 @@ Grafana repositories are enabled on your host. If true, the official Grafana repositories will be enabled. If false, the module assumes you are managing your own package repository and will not set one up for you. Defaults to true. +##### `plugins` + +Hash. This is a passthrough to call `create_resources()` on the +`grafana_plugin` resource type. + ##### `package_name` The name of the package managed with the 'package' install method. Defaults to @@ -333,7 +338,7 @@ Example: #### Custom Types and Providers -The module includes two custom types: `grafana_dashboard` and `grafana_datasource` +The module includes several custom types: ##### `grafana_dashboard` @@ -380,14 +385,15 @@ from the browser, or `proxy` to send requests via grafana. Authentication is optional, as is `database`; additional `json_data` can be provided to allow custom configuration options. -##### `grafana::plugin` +##### `grafana_plugin` -There exists a custom defined resource which wraps grafana-cli to install -plugins. Deinstallation isn't supported right now, also docker support -completely missing. Example usage: +An example is provided for convenience; for more details, please view the +puppet strings docs. ```puppet -grafana::plugin{'grafana-simple-json-datasource':} +grafana_plugin { 'grafana-simple-json-datasource': + ensure => present, +} ``` ##### `grafana::user` diff --git a/lib/puppet/provider/grafana_plugin/grafana_cli.rb b/lib/puppet/provider/grafana_plugin/grafana_cli.rb new file mode 100644 index 000000000..153e1b1ce --- /dev/null +++ b/lib/puppet/provider/grafana_plugin/grafana_cli.rb @@ -0,0 +1,56 @@ +Puppet::Type.type(:grafana_plugin).provide(:grafana_cli) do + has_command(:grafana_cli, 'grafana-cli') do + is_optional + end + + defaultfor feature: :posix + + mk_resource_methods + + def self.all_plugins + plugins = [] + grafana_cli('plugins', 'ls').split(%r{\n}).each do |line| + next unless line =~ %r{^(\S+)\s+@\s+((?:\d\.).+)\s*$} + name = Regexp.last_match(1) + version = Regexp.last_match(2) + Puppet.debug("Found grafana plugin #{name} #{version}") + plugins.push(name) + end + plugins.sort + end + + def self.instances + resources = [] + all_plugins.each do |name| + plugin = { + ensure: :present, + name: name + } + resources << new(plugin) if plugin[:name] + end + resources + end + + def self.prefetch(resources) + plugins = instances + resources.keys.each do |name| + if (provider = plugins.find { |plugin| plugin.name == name }) + resources[name].provider = provider + end + end + end + + def exists? + @property_hash[:ensure] == :present + end + + def create + grafana_cli('plugins', 'install', resource[:name]) + @property_hash[:ensure] = :present + end + + def destroy + grafana_cli('plugins', 'uninstall', resource[:name]) + @property_hash[:ensure] = :absent + end +end diff --git a/lib/puppet/type/grafana_plugin.rb b/lib/puppet/type/grafana_plugin.rb new file mode 100644 index 000000000..4f2d95572 --- /dev/null +++ b/lib/puppet/type/grafana_plugin.rb @@ -0,0 +1,31 @@ +Puppet::Type.newtype(:grafana_plugin) do + desc <<-DESC +manages grafana plugins + +@example Install a grafana plugin + grafana_plugin { 'grafana-simple-json-datasource': } + +@example Uninstall a grafana plugin + grafana_plugin { 'grafana-simple-json-datasource': + ensure => absent, + } + +@example Show resources + $ puppet resource grafana_plugin +DESC + + ensurable do + defaultto(:present) + newvalue(:present) do + provider.create + end + newvalue(:absent) do + provider.destroy + end + end + + newparam(:name, namevar: true) do + desc 'The name of the plugin to enable' + newvalues(%r{^\S+$}) + end +end diff --git a/manifests/init.pp b/manifests/init.pp index 467ffc5c5..c4f020343 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -62,6 +62,10 @@ # Set to 'testing' to install beta versions # Defaults to stable. # +# [*plugins*] +# A hash of plugins to be passed to `create_resources`, wraps around the +# `grafana_plugin` resource. +# # === Examples # # class { '::grafana': @@ -84,7 +88,8 @@ $repo_name = $::grafana::params::repo_name, $rpm_iteration = $::grafana::params::rpm_iteration, $service_name = $::grafana::params::service_name, - $version = $::grafana::params::version + $version = $::grafana::params::version, + $plugins = {} ) inherits grafana::params { # validate parameters here @@ -99,4 +104,9 @@ Class['grafana::install'] -> Class['grafana::config'] ~> Class['grafana::service'] + + create_resources(grafana_plugin, $plugins) + + Grafana_Plugin <| |> ~> Class['grafana::service'] + } diff --git a/manifests/plugin.pp b/manifests/plugin.pp deleted file mode 100644 index ff10a9079..000000000 --- a/manifests/plugin.pp +++ /dev/null @@ -1,10 +0,0 @@ -# defined resource to add plugins to grafana via CLI -# this won't work with the docker installation method -define grafana::plugin( - String $plugin = $title, -){ - exec{"install ${plugin}": - command => "/usr/bin/grafana-cli plugins install ${plugin}", - creates => "/var/lib/grafana/plugins/${plugin}", - } -} diff --git a/spec/acceptance/grafana_plugin_spec.rb b/spec/acceptance/grafana_plugin_spec.rb new file mode 100644 index 000000000..49bdde3d9 --- /dev/null +++ b/spec/acceptance/grafana_plugin_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper_acceptance' + +describe 'grafana_plugin' do + context 'create plugin resource' do + it 'runs successfully' do + pp = <<-EOS + class { 'grafana':} + grafana_plugin { 'grafana-simple-json-datasource': } + EOS + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + + it 'has the plugin' do + shell('grafana-cli plugins ls') do |r| + expect(r.stdout).to match(%r{grafana-simple-json-datasource}) + end + end + end + context 'destroy plugin resource' do + it 'runs successfully' do + pp = <<-EOS + class { 'grafana':} + grafana_plugin { 'grafana-simple-json-datasource': + ensure => absent, + } + EOS + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + + it 'does not have the plugin' do + shell('grafana-cli plugins ls') do |r| + expect(r.stdout).not_to match(%r{grafana-simple-json-datasource}) + end + end + end +end diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index c66c95879..46b870f93 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -69,6 +69,21 @@ end end + context 'with some plugins passed in' do + let(:params) do + { + plugins: + { + 'grafana-wizzle' => { 'ensure' => 'present' }, + 'grafana-woozle' => { 'ensure' => 'absent' } + } + } + end + + it { is_expected.to contain_grafana_plugin('grafana-wizzle').with(ensure: 'present') } + it { is_expected.to contain_grafana_plugin('grafana-woozle').with(ensure: 'absent').that_notifies('Class[grafana::service]') } + end + context 'with parameter install_method is set to repo' do let(:params) do { diff --git a/spec/defines/plugin_spec.rb b/spec/defines/plugin_spec.rb deleted file mode 100644 index 6b1fb9950..000000000 --- a/spec/defines/plugin_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'grafana::plugin', type: :define do - on_supported_os.each do |os, facts| - context "on #{os} " do - let :facts do - facts - end - - let :title do - 'grafana-simple-json-datasource' - end - - context 'with all defaults' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_exec("install #{title}") } - end - end - end -end diff --git a/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb b/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb new file mode 100644 index 000000000..3c6914a08 --- /dev/null +++ b/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +provider_class = Puppet::Type.type(:grafana_plugin).provider(:grafana_cli) +describe provider_class do + let(:resource) do + Puppet::Type::Grafana_plugin.new( + name: 'grafana-wizzle' + ) + end + let(:provider) { provider_class.new(resource) } + + describe '#instances' do + # rubocop:disable Layout/TrailingWhitespace + provider_class.expects(:grafana_cli).with('plugins', 'ls').returns <<-EOT +installed plugins: +grafana-simple-json-datasource @ 1.3.4 +jdbranham-diagram-panel @ 1.4.0 + +Restart grafana after installing plugins . + +EOT + # rubocop:enable Layout/TrailingWhitespace + instances = provider_class.instances + it 'has the right number of instances' do + expect(instances.size).to eq(2) + end + + it 'has the correct names' do + names = instances.map(&:name) + expect(names).to include('grafana-simple-json-datasource', 'jdbranham-diagram-panel') + end + + it 'does not match if there are no plugins' do + provider_class.expects(:grafana_cli).with('plugins', 'ls').returns <<-EOT + +Restart grafana after installing plugins . + +EOT + instances = provider_class.instances + expect(provider.exists?).to eq(false) + end + end + + it '#create' do + provider.expects(:grafana_cli).with('plugins', 'install', 'grafana-wizzle') + provider.create + end + + it '#destroy' do + provider.expects(:grafana_cli).with('plugins', 'uninstall', 'grafana-wizzle') + provider.destroy + end +end diff --git a/spec/unit/puppet/type/grafana_plugin_spec.rb b/spec/unit/puppet/type/grafana_plugin_spec.rb new file mode 100644 index 000000000..29e7ea50f --- /dev/null +++ b/spec/unit/puppet/type/grafana_plugin_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' +describe Puppet::Type.type(:grafana_plugin) do + let(:plugin) do + Puppet::Type.type(:grafana_plugin).new(name: 'grafana-whatsit') + end + + it 'accepts a plugin name' do + plugin[:name] = 'plugin-name' + expect(plugin[:name]).to eq('plugin-name') + end + it 'requires a name' do + expect do + Puppet::Type.type(:grafana_plugin).new({}) + end.to raise_error(Puppet::Error, 'Title or name must be provided') + end +end From 9c050abdc600fb152f0b145637b2451ec9857b8a Mon Sep 17 00:00:00 2001 From: William Yardley Date: Wed, 20 Sep 2017 11:33:10 -0700 Subject: [PATCH 067/146] Get rid of the dependency on 'wget' module since archive is already a dependency --- .fixtures.yml | 1 - manifests/install.pp | 7 +++---- metadata.json | 4 ---- spec/classes/grafana_spec.rb | 10 +++++++--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index d478d5be8..88216cdb2 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,7 +3,6 @@ fixtures: stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" archive: "https://github.com/voxpupuli/puppet-archive.git" docker: "https://github.com/garethr/garethr-docker.git" - wget: "https://github.com/maestrodev/puppet-wget.git" apt: "https://github.com/puppetlabs/puppetlabs-apt.git" symlinks: grafana: "#{source_dir}" diff --git a/manifests/install.pp b/manifests/install.pp index ef6cdeebd..46e16a4ee 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -34,16 +34,15 @@ ensure => present, } - wget::fetch { 'grafana': - source => $real_package_source, - destination => '/tmp/grafana.deb', + archive { '/tmp/grafana.deb': + source => $real_package_source, } package { $::grafana::package_name: ensure => present, provider => 'dpkg', source => '/tmp/grafana.deb', - require => [Wget::Fetch['grafana'],Package['libfontconfig1']], + require => [Archive['/tmp/grafana.deb'],Package['libfontconfig1']], } } 'RedHat': { diff --git a/metadata.json b/metadata.json index ca080ef7c..daf26b850 100644 --- a/metadata.json +++ b/metadata.json @@ -8,10 +8,6 @@ "project_page": "https://github.com/voxpupuli/puppet-grafana", "issue_url": "https://github.com/voxpupuli/puppet-grafana/issues", "dependencies": [ - { - "name": "maestrodev/wget", - "version_requirement": ">= 1.7.3 < 2.0.0" - }, { "name": "puppet/archive", "version_requirement": ">= 1.0.1 < 2.0.0" diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index c66c95879..de63d8f35 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -45,9 +45,13 @@ when 'Debian' download_location = '/tmp/grafana.deb' - describe 'use wget to fetch the package to a temporary location' do - it { is_expected.to contain_wget__fetch('grafana').with_destination(download_location) } - it { is_expected.to contain_wget__fetch('grafana').that_comes_before('Package[grafana]') } + describe 'use archive to fetch the package to a temporary location' do + it do + is_expected.to contain_archive('/tmp/grafana.deb').with_source( + 'https://s3-us-west-2.amazonaws.com/grafana-releases/release/builds/grafana_4.5.1_amd64.deb' + ) + end + it { is_expected.to contain_archive('/tmp/grafana.deb').that_comes_before('Package[grafana]') } end describe 'install dependencies first' do From e2b39a9e2140b9c57eb400145e476a14de826242 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Wed, 20 Sep 2017 12:01:55 -0700 Subject: [PATCH 068/146] Switch to Puppet Data Types --- manifests/init.pp | 39 ++++++++++++++++-------------------- manifests/params.pp | 3 --- spec/classes/grafana_spec.rb | 10 --------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c4f020343..9897d9819 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -73,30 +73,25 @@ # } # class grafana ( - $archive_source = $::grafana::params::archive_source, - $cfg_location = $::grafana::params::cfg_location, - $cfg = $::grafana::params::cfg, - $ldap_cfg = $::grafana::params::ldap_cfg, - $container_cfg = $::grafana::params::container_cfg, - $container_params = $::grafana::params::container_params, - $data_dir = $::grafana::params::data_dir, - $install_dir = $::grafana::params::install_dir, - $install_method = $::grafana::params::install_method, - $manage_package_repo = $::grafana::params::manage_package_repo, - $package_name = $::grafana::params::package_name, - $package_source = $::grafana::params::package_source, - $repo_name = $::grafana::params::repo_name, - $rpm_iteration = $::grafana::params::rpm_iteration, - $service_name = $::grafana::params::service_name, - $version = $::grafana::params::version, - $plugins = {} + Optional[String] $archive_source = undef, + String $cfg_location = $::grafana::params::cfg_location, + Hash $cfg = $::grafana::params::cfg, + Optional[Hash] $ldap_cfg = undef, + Boolean $container_cfg = $::grafana::params::container_cfg, + Hash $container_params = $::grafana::params::container_params, + String $data_dir = $::grafana::params::data_dir, + String $install_dir = $::grafana::params::install_dir, + String $install_method = $::grafana::params::install_method, + Boolean $manage_package_repo = $::grafana::params::manage_package_repo, + String $package_name = $::grafana::params::package_name, + Optional[String] $package_source = undef, + Enum['stable', 'testing'] $repo_name = $::grafana::params::repo_name, + String $rpm_iteration = $::grafana::params::rpm_iteration, + String $service_name = $::grafana::params::service_name, + String $version = $::grafana::params::version, + Hash $plugins = {} ) inherits grafana::params { - # validate parameters here - if !is_hash($cfg) { - fail('cfg parameter must be a hash') - } - contain grafana::install contain grafana::config contain grafana::service diff --git a/manifests/params.pp b/manifests/params.pp index 4407a1c5e..54ef4a05b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,7 +4,6 @@ # It sets variables according to platform # class grafana::params { - $archive_source = undef $cfg = {} $container_cfg = false $container_params = {} @@ -12,9 +11,7 @@ $docker_image = 'grafana/grafana' $docker_ports = '3000:3000' $install_dir = '/usr/share/grafana' - $ldap_cfg = false $package_name = 'grafana' - $package_source = undef $rpm_iteration = '1' $repo_name = 'stable' $version = '4.5.1' diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 46b870f93..71a9296cf 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -221,16 +221,6 @@ context 'invalid parameters' do context 'cfg' do - describe 'should raise an error when cfg parameter is not a hash' do - let(:params) do - { - cfg: [] - } - end - - it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{cfg parameter must be a hash}) } - end - describe 'should not raise an error when cfg parameter is a hash' do let(:params) do { From 6edca8f69dbcb92c8a26460224f9379ef4d990e3 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Wed, 20 Sep 2017 10:18:24 -0700 Subject: [PATCH 069/146] Remove licenses from the top of files, since LICENSE is already included in the project --- lib/puppet/provider/grafana.rb | 12 ------------ lib/puppet/provider/grafana_dashboard/grafana.rb | 11 ----------- lib/puppet/provider/grafana_datasource/grafana.rb | 12 ------------ lib/puppet/provider/grafana_user/grafana.rb | 12 ------------ lib/puppet/type/grafana_dashboard.rb | 11 ----------- lib/puppet/type/grafana_datasource.rb | 12 ------------ lib/puppet/type/grafana_user.rb | 12 ------------ 7 files changed, 82 deletions(-) diff --git a/lib/puppet/provider/grafana.rb b/lib/puppet/provider/grafana.rb index 0ebb0ad99..6f198b5a1 100644 --- a/lib/puppet/provider/grafana.rb +++ b/lib/puppet/provider/grafana.rb @@ -1,17 +1,5 @@ # Copyright 2015 Mirantis, Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# require 'cgi' require 'json' require 'net/http' diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index fb215d987..3ac3a7d44 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -1,16 +1,5 @@ # Copyright 2015 Mirantis, Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. require 'json' require File.expand_path(File.join(File.dirname(__FILE__), '..', 'grafana')) diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 79d7d5dea..6ac97ecdd 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -1,17 +1,5 @@ # Copyright 2015 Mirantis, Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# require 'json' require File.expand_path(File.join(File.dirname(__FILE__), '..', 'grafana')) diff --git a/lib/puppet/provider/grafana_user/grafana.rb b/lib/puppet/provider/grafana_user/grafana.rb index da0eeffdf..fc8b79cab 100644 --- a/lib/puppet/provider/grafana_user/grafana.rb +++ b/lib/puppet/provider/grafana_user/grafana.rb @@ -1,15 +1,3 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# require 'json' require File.expand_path(File.join(File.dirname(__FILE__), '..', 'grafana')) diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index 96cdd9b99..d76d731f5 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -1,16 +1,5 @@ # Copyright 2015 Mirantis, Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. require 'json' Puppet::Type.newtype(:grafana_dashboard) do diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 6cb413243..7f08cb1bc 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -1,17 +1,5 @@ # Copyright 2015 Mirantis, Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# Puppet::Type.newtype(:grafana_datasource) do @doc = 'Manage datasources in Grafana' diff --git a/lib/puppet/type/grafana_user.rb b/lib/puppet/type/grafana_user.rb index 8b15bb010..6714dac53 100644 --- a/lib/puppet/type/grafana_user.rb +++ b/lib/puppet/type/grafana_user.rb @@ -1,15 +1,3 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# Puppet::Type.newtype(:grafana_user) do @doc = 'Manage users in Grafana' From 6b8e37dd9847a54674e5f006ae8398accb80ff55 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Wed, 20 Sep 2017 13:18:12 -0700 Subject: [PATCH 070/146] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 833099497..14e9532af 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,20 @@ This module has been tested on Ubuntu 14.04, using each of the 'archive', 'docke and 'package' installation methods. Other configurations should work with minimal, if any, additional effort. +## Development + +This module is a fork of +[bfraser/grafana](https://github.com/bfraser/puppet-grafana) maintained by [Vox +Pupuli](https://voxpupuli.org/). Vox Pupuli welcomes new contributions to this +module, especially those that include documentation and rspec tests. We are +happy to provide guidance if necessary. + +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details. + +### Authors +* Bill Fraser +* Vox Pupuli Team + ## Copyright and License Copyright (C) 2015 Bill Fraser From f9e9a2e17b85de9d49b893733a1e1f7a8523ded3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 4 Jul 2017 22:10:56 +0200 Subject: [PATCH 071/146] release 4.0.0 --- CHANGELOG.md | 85 +++++++++++++++++++++++++------ HISTORY.md | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 2 +- 3 files changed, 205 insertions(+), 17 deletions(-) create mode 100644 HISTORY.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 70cd7f6b7..c915e3279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,33 +1,83 @@ -# Releasing v3.0.0 (2017-03-29) +# Changelog + +All notable changes to this project will be documented in this file. +Each new release typically also includes the latest modulesync defaults. +These should not affect the functionality of the module. + +## [v4.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.0) (2017-09-20) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v3.0.0...v4.0.0) + +**Implemented enhancements:** + +- BREAKING: Switch to Puppet Data Types \(ldap\_cfg is now undef when disabled\) [\#66](https://github.com/voxpupuli/puppet-grafana/pull/66) ([wyardley](https://github.com/wyardley)) +- BREAKING: Create grafana\_plugin resource type and change grafana::plugins [\#63](https://github.com/voxpupuli/puppet-grafana/pull/63) ([wyardley](https://github.com/wyardley)) +- BREAKING: Update default Grafana version to 4.5.1 and improve acceptance tests [\#61](https://github.com/voxpupuli/puppet-grafana/pull/61) ([wyardley](https://github.com/wyardley)) +- grafana\_user custom resource [\#60](https://github.com/voxpupuli/puppet-grafana/pull/60) ([atward](https://github.com/atward)) +- Support newer versions of puppetlabs/apt module [\#53](https://github.com/voxpupuli/puppet-grafana/pull/53) ([ghoneycutt](https://github.com/ghoneycutt)) +- Support custom plugins [\#44](https://github.com/voxpupuli/puppet-grafana/pull/44) ([bastelfreak](https://github.com/bastelfreak)) + +**Fixed bugs:** + +- gpg key error on CentOS 7 with default params [\#59](https://github.com/voxpupuli/puppet-grafana/issues/59) +- wget called even if not necessary [\#54](https://github.com/voxpupuli/puppet-grafana/issues/54) +- Fix typo in provider [\#58](https://github.com/voxpupuli/puppet-grafana/pull/58) ([atward](https://github.com/atward)) + +**Closed issues:** + +- install\_method 'docker" ignores all other configurations [\#51](https://github.com/voxpupuli/puppet-grafana/issues/51) +- Usable for Grafana 4.x? [\#37](https://github.com/voxpupuli/puppet-grafana/issues/37) +- Remove docker dependency [\#22](https://github.com/voxpupuli/puppet-grafana/issues/22) + +**Merged pull requests:** + +- Update README.md [\#67](https://github.com/voxpupuli/puppet-grafana/pull/67) ([wyardley](https://github.com/wyardley)) +- Get rid of the dependency on 'wget' module in favor of puppet-archive [\#65](https://github.com/voxpupuli/puppet-grafana/pull/65) ([wyardley](https://github.com/wyardley)) +- Remove licenses from the top of files [\#64](https://github.com/voxpupuli/puppet-grafana/pull/64) ([wyardley](https://github.com/wyardley)) +- Always use jessie apt repo when osfamily is Debian. [\#41](https://github.com/voxpupuli/puppet-grafana/pull/41) ([furhouse](https://github.com/furhouse)) + +## [v3.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v3.0.0) (2017-03-29) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.3...v3.0.0) **Implemented enhancements:** -- Implement package\_ensure param for Arch Linux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) +- implement package\_ensure param for archlinux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) **Fixed bugs:** +- implement package\\_ensure param for archlinux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) - FIX configuration file ownership [\#30](https://github.com/voxpupuli/puppet-grafana/pull/30) ([cassianoleal](https://github.com/cassianoleal)) **Closed issues:** -- Configured Grafana Debian repo should contain current distribution [\#27](https://github.com/voxpupuli/puppet-grafana/issues/27) +- Configured grafana debian repo should contain current distribution [\#27](https://github.com/voxpupuli/puppet-grafana/issues/27) - Error while creating dashboard [\#25](https://github.com/voxpupuli/puppet-grafana/issues/25) **Merged pull requests:** +- Bump version, Update changelog [\#38](https://github.com/voxpupuli/puppet-grafana/pull/38) ([dhoppe](https://github.com/dhoppe)) - Debian and RedHat based operating systems should use the repository by default [\#36](https://github.com/voxpupuli/puppet-grafana/pull/36) ([dhoppe](https://github.com/dhoppe)) -- Add support for Arch Linux [\#32](https://github.com/voxpupuli/puppet-grafana/pull/32) ([bastelfreak](https://github.com/bastelfreak)) +- Add support for archlinux [\#32](https://github.com/voxpupuli/puppet-grafana/pull/32) ([bastelfreak](https://github.com/bastelfreak)) - Fix grafana\_dashboards [\#31](https://github.com/voxpupuli/puppet-grafana/pull/31) ([cassianoleal](https://github.com/cassianoleal)) -- Supoort jessie for install method repo [\#28](https://github.com/voxpupuli/puppet-grafana/pull/28) ([roock](https://github.com/roock)) +- supoort jessie for install method repo [\#28](https://github.com/voxpupuli/puppet-grafana/pull/28) ([roock](https://github.com/roock)) - Use operatinsystemmajrelease fact in repo url [\#24](https://github.com/voxpupuli/puppet-grafana/pull/24) ([mirekys](https://github.com/mirekys)) - The puppet 4-only release will start at 3.0.0 [\#21](https://github.com/voxpupuli/puppet-grafana/pull/21) ([rnelson0](https://github.com/rnelson0)) -# Releasing v2.6.1 (2017-01-18) +## [v2.6.3](https://github.com/voxpupuli/puppet-grafana/tree/v2.6.3) (2017-01-18) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.2...v2.6.3) + +## [v2.6.2](https://github.com/voxpupuli/puppet-grafana/tree/v2.6.2) (2017-01-18) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.1...v2.6.2) + +**Merged pull requests:** + +- release 2.6.2 \(optimistic, i know ;\) [\#20](https://github.com/voxpupuli/puppet-grafana/pull/20) ([igalic](https://github.com/igalic)) + +## v2.6.1 (2017-01-18) Just a notice: The next release will be a major one without Puppet 3 support! This is the last Release that supports it! -# Releasing v2.6.0 (2017-01-18) +## Releasing v2.6.0 (2017-01-18) **Enhancements** @@ -53,7 +103,7 @@ This is the last Release that supports it! * Rubocop and ruby-lint style-fixes! * test with puppet > 4.x -# 2.5.0 (2015-10-31) +## 2.5.0 (2015-10-31) **Enhancements** - Support for [Grafana 2.5](http://grafana.org/blog/2015/10/28/Grafana-2-5-Released.html). This is just a version bump to reflect that Grafana 2.5 is now installed by default @@ -67,7 +117,7 @@ This is the last Release that supports it! - [PR #59](https://github.com/bfraser/puppet-grafana/pull/59) More specific version requirements in ```metadata.json``` due to use of ```contain``` function - [PR #61](https://github.com/bfraser/puppet-grafana/pull/61) Fixed typos in ```metadata.json``` -# 2.1.0 (2015-08-07) +## 2.1.0 (2015-08-07) **Enhancements** - Support for [Grafana 2.1](http://grafana.org/blog/2015/08/04/Grafana-2-1-Released.html) @@ -84,7 +134,7 @@ This is the last Release that supports it! **Behind The Scenes** - Use 40 character GPG key ID for packagecloud apt repository -# 2.0.2 (2015-04-30) +## 2.0.2 (2015-04-30) **Enhancements** - Support for Grafana 2.0. Users of Grafana 1.x should stick to version 1.x of the Puppet module @@ -96,7 +146,7 @@ This is the last Release that supports it! - Update module operatingsystem support, tags, Puppet requirements - Tests for 'archive' and 'package' install methods -# 1.0.1 (2015-02-27) +## 1.0.1 (2015-02-27) **Enhancements** - New parameter for Grafana admin password @@ -111,7 +161,7 @@ This is the last Release that supports it! - Allow Travis to fail on Ruby 1.8.7 - More Puppet versions are tested by Travis -# 1.0.0 (2014-12-16) +## 1.0.0 (2014-12-16) **Enhancements** - Add max_search_results parameter @@ -127,7 +177,7 @@ This is the last Release that supports it! - Removal of vagrant-wrapper gem - Fancy badges for build status -# 0.2.2 (2014-10-27) +## 0.2.2 (2014-10-27) **Enhancements** - Add default_route parameter to manage start dashboard @@ -138,7 +188,7 @@ This is the last Release that supports it! **Behind The Scenes** - [Issue #9](https://github.com/bfraser/puppet-grafana/issues/9) Remove stdlib inclusion from manifest -# 0.2.1 (2014-10-14) +## 0.2.1 (2014-10-14) **Enhancements** - Support for multiple datasources @@ -149,11 +199,14 @@ This is the last Release that supports it! - Add stdlib as a module dependency - Add operating system compatibility -# 0.1.3 (2014-07-03) +## 0.1.3 (2014-07-03) **Enhancements** - Added support for InfluxDB -# 0.1.2 (2014-06-30) +## 0.1.2 (2014-06-30) First release on the Puppet Forge + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 000000000..f7ccd8868 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,135 @@ +## v2.6.1 (2017-01-18) + +Just a notice: The next release will be a major one without Puppet 3 support! +This is the last Release that supports it! + +## Releasing v2.6.0 (2017-01-18) + +**Enhancements** + +* add two types & provider: `grafana_datasource` & `grafana_dashboard` these + type allow configuration of the datasource and the dashboard against the API +* allow configuration of `repo_name` for all installation methods +* be more conservative when installing from docker, while also allowing users to + override our `stable` choice + +**Fixes** + +* ensure correct ownership of downloaded artefact +* fix use-before definition of `$version`: https://github.com/bfraser/puppet-grafana/issues/87 + +**Behind The Scenes** + +* switch to voxpupuli/archive from camptocamp + +**Changes since forking from bfraser/puppet-grafana** + +* Add CONTRIBUTING.MD as well as our issues, spec etc… templates +* update README and other files to point to forked repository +* Rubocop and ruby-lint style-fixes! +* test with puppet > 4.x + +## 2.5.0 (2015-10-31) + +**Enhancements** +- Support for [Grafana 2.5](http://grafana.org/blog/2015/10/28/Grafana-2-5-Released.html). This is just a version bump to reflect that Grafana 2.5 is now installed by default +- [PR #58](https://github.com/bfraser/puppet-grafana/pull/58) Sort ```cfg``` keys so ```config.ini``` content is not updated every Puppet run + +**Fixes** +- [Issue #52](https://github.com/bfraser/puppet-grafana/issues/52) Version logic moved to ```init.pp``` so overriding the version of Grafana to install works as intended + +**Behind The Scenes** + +- [PR #59](https://github.com/bfraser/puppet-grafana/pull/59) More specific version requirements in ```metadata.json``` due to use of ```contain``` function +- [PR #61](https://github.com/bfraser/puppet-grafana/pull/61) Fixed typos in ```metadata.json``` + +## 2.1.0 (2015-08-07) + +**Enhancements** +- Support for [Grafana 2.1](http://grafana.org/blog/2015/08/04/Grafana-2-1-Released.html) +- [Issue #40](https://github.com/bfraser/puppet-grafana/issues/40) Support for [LDAP integration](http://docs.grafana.org/v2.1/installation/ldap/) +- [PR #34](https://github.com/bfraser/puppet-grafana/pull/34) Support for 'repo' install method to install packages from [packagecloud](https://packagecloud.io/grafana) repositories +- Addition of boolean parameter ```manage_package_repo``` to control whether the module will manage the package repository when using the 'repo' install method. See README.md for details +- [PR #39](https://github.com/bfraser/puppet-grafana/pull/39) Ability to ensure a specific package version is installed when using the 'repo' install method + +**Fixes** +- [Issue #37](https://github.com/bfraser/puppet-grafana/issues/37) Archive install method: check if user and service are already defined before attempting to define them +- [Issue #42](https://github.com/bfraser/puppet-grafana/issues/42) Package versioning for RPM / yum systems +- [Issue #45](https://github.com/bfraser/puppet-grafana/issues/45) Fix resource dependency issues when ```manage_package_repo``` is false + +**Behind The Scenes** +- Use 40 character GPG key ID for packagecloud apt repository + +## 2.0.2 (2015-04-30) + +**Enhancements** +- Support for Grafana 2.0. Users of Grafana 1.x should stick to version 1.x of the Puppet module +- Support 'archive', 'docker' and 'package' install methods +- Ability to supply a hash of parameters to the Docker container when using 'docker' install method +- [PR #24](https://github.com/bfraser/puppet-grafana/pull/24) Ability to configure Grafana using configuration hash parameter ```cfg``` + +**Behind The Scenes** +- Update module operatingsystem support, tags, Puppet requirements +- Tests for 'archive' and 'package' install methods + +## 1.0.1 (2015-02-27) + +**Enhancements** +- New parameter for Grafana admin password + +**Fixes** +- Package install method now makes use of install_dir for config.js path + +**Behind The Scenes** +- Add archive module to .fixtures.yml +- Unquote booleans to make lint happy +- Fix license identifier and unbounded dependencies in module metadata +- Allow Travis to fail on Ruby 1.8.7 +- More Puppet versions are tested by Travis + +## 1.0.0 (2014-12-16) + +**Enhancements** +- Add max_search_results parameter +- Install Grafana 1.9.0 by default + +**Documentation** +- Add download_url and install_method parameters to README + +**Behind The Scenes** +- [Issue #6](https://github.com/bfraser/puppet-grafana/issues/6) Replace gini/archive dependency with camptocamp/archive +- Addition of CHANGELOG +- Style fixes +- Removal of vagrant-wrapper gem +- Fancy badges for build status + +## 0.2.2 (2014-10-27) + +**Enhancements** +- Add default_route parameter to manage start dashboard + +**Fixes** +- Symlink behavior + +**Behind The Scenes** +- [Issue #9](https://github.com/bfraser/puppet-grafana/issues/9) Remove stdlib inclusion from manifest + +## 0.2.1 (2014-10-14) + +**Enhancements** +- Support for multiple datasources +- Install Grafana 1.8.1 by default + +**Behind The Scenes** +- Added RSpec tests +- Add stdlib as a module dependency +- Add operating system compatibility + +## 0.1.3 (2014-07-03) + +**Enhancements** +- Added support for InfluxDB + +## 0.1.2 (2014-06-30) + +First release on the Puppet Forge diff --git a/metadata.json b/metadata.json index daf26b850..0335bec82 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "3.0.0", + "version": "4.0.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 5ddeb8dab70ce9150b1db3b2c574c7a8956c0060 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 20 Sep 2017 23:31:55 +0200 Subject: [PATCH 072/146] [blacksmith] Bump version to 4.0.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 0335bec82..7a16e1818 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.0", + "version": "4.0.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From d5103a529f8782e02c8858a21764afb2d8286f05 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Thu, 21 Sep 2017 10:19:26 -0700 Subject: [PATCH 073/146] Update Travis secrets --- .sync.yml | 2 +- .travis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.sync.yml b/.sync.yml index 578b586c8..c34f3cf00 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,6 +1,6 @@ --- .travis.yml: - secure: "qtLA1TPKaVgd9rvi0kkF2v0CP0QLls//lFHJ9IowTYNi5O+0dx7OxZCK3g4nkNWWbsujS464/YFJqVRWoXIeLIyFtfMKkaRAiuaukxOQqnzD+BsnpYYeo2zeZPCvMbB94+7G7JQ+jpuzlsHX6j+H6LQEj6+kXzd8NAj8rlygrL8XcFN3bA8XM/unCvqn2b2sduShExVl0mnNMIvZMHCbdrEzByXkz+FmyGYCay+feDIYbIbhzYLNnh6BcDkq24TxRmVOdEnUkPG6ZU0UJlNqBZB++zAIazR25NyX+b22/CFp6D6YJKkJvBNnywGUNNF21s4a6kPoEnUVBEO6yg5sDkKgp8nAvsmUnI8A1tfRFWKejxHZN3YqveY60xiNIUEHJU4MjEE6VVi9WpNW8CpJbfP/z3RtlU5n4ckSER7mb/ApxspUPJRzyMKjobDP12WU/bgXinzdNMu6PH9H56WkDpRNtIYnNhIAuirdfDr2Ok5z9/9yObUt/OQddM4wrOnMG7lyyUIzAO2OOJbIcOaZBedTKccpCu6k2mOkUHhMutf1D0bde5IGhrs7E54V2ZNxX5Dopv5eOrmVN2OxdcB9g8nmISxX6Tty/BNrTBvt7urthGjUJrjlnNE/K1595KmcWa6PGWUcYZyzdKeWqiA3+iWKSmnx1Ri0lsml5Z/a4QM=" + secure: "C+dXd27/doW1JnKqv+UDHL6/HBI5Te+xGsaoPkqhpO4iXfMxJrTi6sBWaEuyNTeHIwN8wOWHaW9qKEqTuYZ0/k+k3SWFmZpi3jSh79Y8WDoYK7+DsbKQ6xZy54Sh56YIYXfkaLQYYYrqKKksZ57h/NYU/hzu9h8oH+PnXfGT6i/KH9C4z8IR9qTxIiErrJHUMni9CryTTbtGV9pIj0QTZP+OQLoE660J8/uMsfTQDK9/NqQ2nsTaQ12SS9xg6MmmOX7W4NhRrOyIi0sd7eR0dRIoVf0TwfYhw8Yi4aDuTZIHNtcHiyfAVsvh3RpAr5d01GjXEr5lj0XyBOu8t1U3BzPU7LrJRrwE+ZmP72L39vrT7rmDRz9pDU7fVIOiRtqRLEJRDIW4I2ISkwBdzFKX8UTozTkPEmt9Iy+uKX5n2y8re2KFaseXWxTeVJbHh+DsJQ/hWsUNrHcl2dKmtgo7xHSonmevnATVV1vUbwvswm1oEiAFRdhF4gNdC8I6OGlVzmzwMbwqiGUk/nRBQeMEbyeRQV54QV3zteuBiHc8neQPR+QiD7diR2d4JhmDbr6xop+Bat2SVQqLg2IdAJ/Qu1Aor7mxhmPqiz35SWkbaaoDJYbWrCBeQ+jos4s2jCDY7OJEXW8ng9gPO71W/lcybMWzihUw6fA9w/riHe37Ez0=" docker_sets: - set: docker/ubuntu-16.04 - set: docker/centos-7 diff --git a/.travis.yml b/.travis.yml index 7392419f8..738e05bd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,7 @@ deploy: provider: puppetforge user: puppet password: - secure: "qtLA1TPKaVgd9rvi0kkF2v0CP0QLls//lFHJ9IowTYNi5O+0dx7OxZCK3g4nkNWWbsujS464/YFJqVRWoXIeLIyFtfMKkaRAiuaukxOQqnzD+BsnpYYeo2zeZPCvMbB94+7G7JQ+jpuzlsHX6j+H6LQEj6+kXzd8NAj8rlygrL8XcFN3bA8XM/unCvqn2b2sduShExVl0mnNMIvZMHCbdrEzByXkz+FmyGYCay+feDIYbIbhzYLNnh6BcDkq24TxRmVOdEnUkPG6ZU0UJlNqBZB++zAIazR25NyX+b22/CFp6D6YJKkJvBNnywGUNNF21s4a6kPoEnUVBEO6yg5sDkKgp8nAvsmUnI8A1tfRFWKejxHZN3YqveY60xiNIUEHJU4MjEE6VVi9WpNW8CpJbfP/z3RtlU5n4ckSER7mb/ApxspUPJRzyMKjobDP12WU/bgXinzdNMu6PH9H56WkDpRNtIYnNhIAuirdfDr2Ok5z9/9yObUt/OQddM4wrOnMG7lyyUIzAO2OOJbIcOaZBedTKccpCu6k2mOkUHhMutf1D0bde5IGhrs7E54V2ZNxX5Dopv5eOrmVN2OxdcB9g8nmISxX6Tty/BNrTBvt7urthGjUJrjlnNE/K1595KmcWa6PGWUcYZyzdKeWqiA3+iWKSmnx1Ri0lsml5Z/a4QM=" + secure: "C+dXd27/doW1JnKqv+UDHL6/HBI5Te+xGsaoPkqhpO4iXfMxJrTi6sBWaEuyNTeHIwN8wOWHaW9qKEqTuYZ0/k+k3SWFmZpi3jSh79Y8WDoYK7+DsbKQ6xZy54Sh56YIYXfkaLQYYYrqKKksZ57h/NYU/hzu9h8oH+PnXfGT6i/KH9C4z8IR9qTxIiErrJHUMni9CryTTbtGV9pIj0QTZP+OQLoE660J8/uMsfTQDK9/NqQ2nsTaQ12SS9xg6MmmOX7W4NhRrOyIi0sd7eR0dRIoVf0TwfYhw8Yi4aDuTZIHNtcHiyfAVsvh3RpAr5d01GjXEr5lj0XyBOu8t1U3BzPU7LrJRrwE+ZmP72L39vrT7rmDRz9pDU7fVIOiRtqRLEJRDIW4I2ISkwBdzFKX8UTozTkPEmt9Iy+uKX5n2y8re2KFaseXWxTeVJbHh+DsJQ/hWsUNrHcl2dKmtgo7xHSonmevnATVV1vUbwvswm1oEiAFRdhF4gNdC8I6OGlVzmzwMbwqiGUk/nRBQeMEbyeRQV54QV3zteuBiHc8neQPR+QiD7diR2d4JhmDbr6xop+Bat2SVQqLg2IdAJ/Qu1Aor7mxhmPqiz35SWkbaaoDJYbWrCBeQ+jos4s2jCDY7OJEXW8ng9gPO71W/lcybMWzihUw6fA9w/riHe37Ez0=" on: tags: true # all_branches is required to use tags From ea55bd73b3e7a8de79710cf6ea9d3dda1921c343 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Thu, 21 Sep 2017 10:19:54 -0700 Subject: [PATCH 074/146] CHANGELOG and metadata for release --- CHANGELOG.md | 8 ++++++++ metadata.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c915e3279..feb9063e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.0.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.1) (2017-09-21) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.0...v4.0.1) + +**Fixed bugs:** + +- Module doesn't work on Ubuntu Xenial [\#56](https://github.com/voxpupuli/puppet-grafana/issues/56) + ## [v4.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.0) (2017-09-20) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v3.0.0...v4.0.0) @@ -33,6 +40,7 @@ These should not affect the functionality of the module. - Update README.md [\#67](https://github.com/voxpupuli/puppet-grafana/pull/67) ([wyardley](https://github.com/wyardley)) - Get rid of the dependency on 'wget' module in favor of puppet-archive [\#65](https://github.com/voxpupuli/puppet-grafana/pull/65) ([wyardley](https://github.com/wyardley)) - Remove licenses from the top of files [\#64](https://github.com/voxpupuli/puppet-grafana/pull/64) ([wyardley](https://github.com/wyardley)) +- Release 4.0.0 [\#62](https://github.com/voxpupuli/puppet-grafana/pull/62) ([bastelfreak](https://github.com/bastelfreak)) - Always use jessie apt repo when osfamily is Debian. [\#41](https://github.com/voxpupuli/puppet-grafana/pull/41) ([furhouse](https://github.com/furhouse)) ## [v3.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v3.0.0) (2017-03-29) diff --git a/metadata.json b/metadata.json index 7a16e1818..6d4a20567 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.1-rc0", + "version": "4.0.1", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 05f9ba6362a8845262bf261da9294e39f7ca8473 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Fri, 22 Sep 2017 08:33:50 -0700 Subject: [PATCH 075/146] [blacksmith] Bump version to 4.0.2-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 6d4a20567..7913f15d1 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.1", + "version": "4.0.2-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From b1dae41d5a79dfcd5373757e2ac3d0d093e6f8af Mon Sep 17 00:00:00 2001 From: William Yardley Date: Fri, 22 Sep 2017 09:40:00 -0700 Subject: [PATCH 076/146] fix typo in metadata (redhat 6 twice vs 6/7) --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 7913f15d1..7b026c68c 100644 --- a/metadata.json +++ b/metadata.json @@ -35,7 +35,7 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", - "6" + "7" ] }, { From e6f6f9c03c16f81ef094025cdff69998a8c9be98 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 12 Oct 2017 07:35:54 -0700 Subject: [PATCH 077/146] add debian 8 and 9 support --- metadata.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 7b026c68c..da90b0366 100644 --- a/metadata.json +++ b/metadata.json @@ -21,7 +21,9 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "7" + "7", + "8", + "9" ] }, { From 6790b6a513021719ebfe7a84476e5a81776a6619 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 12 Oct 2017 07:44:07 -0700 Subject: [PATCH 078/146] bump archive upper boundary to work witha latest versions --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 7b026c68c..6cc91c5b4 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppet/archive", - "version_requirement": ">= 1.0.1 < 2.0.0" + "version_requirement": ">= 1.0.1 < 3.0.0" }, { "name": "puppetlabs/stdlib", From b2884e9ad0eb6d5b0758a63e7771e8d4c8a7abb7 Mon Sep 17 00:00:00 2001 From: David Hollinger Date: Thu, 12 Oct 2017 11:06:32 -0500 Subject: [PATCH 079/146] Release 4.0.2 --- CHANGELOG.md | 18 +++++++++++++++++- metadata.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index feb9063e0..ec341387d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,29 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. -## [v4.0.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.1) (2017-09-21) +## [v4.0.2](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.2) (2017-10-12) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.1...v4.0.2) + +**Implemented enhancements:** + +- bump archive upper boundary to work with latest versions [\#73](https://github.com/voxpupuli/puppet-grafana/pull/73) ([bastelfreak](https://github.com/bastelfreak)) +- add debian 8 and 9 support [\#72](https://github.com/voxpupuli/puppet-grafana/pull/72) ([bastelfreak](https://github.com/bastelfreak)) + +**Merged pull requests:** + +- fix typo in metadata \(redhat 6 twice vs 6/7\) [\#69](https://github.com/voxpupuli/puppet-grafana/pull/69) ([wyardley](https://github.com/wyardley)) + +## [v4.0.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.1) (2017-09-22) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.0...v4.0.1) **Fixed bugs:** - Module doesn't work on Ubuntu Xenial [\#56](https://github.com/voxpupuli/puppet-grafana/issues/56) +**Merged pull requests:** + +- Release 4.0.1 [\#68](https://github.com/voxpupuli/puppet-grafana/pull/68) ([wyardley](https://github.com/wyardley)) + ## [v4.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.0) (2017-09-20) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v3.0.0...v4.0.0) diff --git a/metadata.json b/metadata.json index 9ab01f56f..bb37aeb4f 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.2-rc0", + "version": "4.0.2", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From f505078e1fc09a55328d08e8bf9446a42e1c0f88 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 12 Oct 2017 10:49:46 -0700 Subject: [PATCH 080/146] [blacksmith] Bump version to 4.0.3-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index bb37aeb4f..ac7d46ba1 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.2", + "version": "4.0.3-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 3f9fa4e9480aa9484fff3339b53ea0ce0cd00b92 Mon Sep 17 00:00:00 2001 From: David Leib Date: Fri, 27 Oct 2017 16:45:13 +0200 Subject: [PATCH 081/146] Removing the datasource url check as it leads to errors with postgres-datasource --- lib/puppet/type/grafana_datasource.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 7f08cb1bc..e168fde0a 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -30,12 +30,6 @@ newproperty(:url) do desc 'The URL of the datasource' - - validate do |value| - unless value =~ %r{^https?://} - raise ArgumentError, format('%s is not a valid URL', value) - end - end end newproperty(:type) do From f06a7c90a4c53971b2f6a48ac7cb6c183b49b45e Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 16 Nov 2017 13:38:11 +0100 Subject: [PATCH 082/146] modulesync 1.5.0 --- .github/CONTRIBUTING.md | 29 ++++++++++------- .msync.yml | 2 +- .rubocop.yml | 13 ++++++++ .travis.yml | 33 +++++++++++--------- Gemfile | 17 ++++++---- Rakefile | 26 +++++++++++++-- spec/acceptance/nodesets/docker/debian-7.yml | 1 - spec/acceptance/nodesets/docker/debian-8.yml | 1 - spec/acceptance/nodesets/docker/debian-9.yml | 20 ++++++++++++ spec/spec_helper.rb | 3 +- 10 files changed, 105 insertions(+), 40 deletions(-) create mode 100644 spec/acceptance/nodesets/docker/debian-9.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 602f324b9..7a0980a9e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,6 +1,6 @@ This module has grown over time based on a range of contributions from people using it. If you follow these contributing guidelines your patch -will likely make it into a release a little quicker. +will likely make it into a release a little more quickly. ## Contributing @@ -65,6 +65,10 @@ add tests if you're adding new functionality. If you've not used [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask about how best to test your new feature. +To run the linter, the syntax checker and the unit tests: + + bundle exec rake test + To run your all the unit tests bundle exec rake spec SPEC_OPTS='--format documentation' @@ -73,10 +77,6 @@ To run a specific spec test set the `SPEC` variable: bundle exec rake spec SPEC=spec/foo_spec.rb -To run the linter, the syntax checker and the unit tests: - - bundle exec rake test - ## Integration tests The unit tests just check the code runs, not that it does exactly what @@ -89,15 +89,20 @@ with: bundle exec rake acceptance -This will run the tests on an Ubuntu 12.04 virtual machine. You can also -run the integration tests against Centos 6.6 with. +This will run the tests on the module's default nodeset. You can override the +nodeset used, e.g., + + BEAKER_set=centos-7-x64 bundle exec rake acceptance + +There are default rake tasks for the various acceptance test modules, e.g., - BEAKER_set=centos-66-x64 bundle exec rake acceptances + bundle exec rake beaker:centos-7-x64 + bundle exec rake beaker:ssh:centos-7-x64 -If you don't want to have to recreate the virtual machine every time you -can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will -at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile -for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`. +If you don't want to have to recreate the virtual machine every time you can +use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at +least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the +created virtual machines will be in `.vagrant/beaker_vagrant_files`. The easiest way to debug in a docker container is to open a shell: diff --git a/.msync.yml b/.msync.yml index 0a4a57db7..80959a381 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.1.0' +modulesync_config_version: '1.5.0' diff --git a/.rubocop.yml b/.rubocop.yml index b1a952131..3fc819bf5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,6 +12,7 @@ AllCops: - Gemfile - Rakefile - Guardfile + - Vagrantfile Lint/ConditionPosition: Enabled: True @@ -45,6 +46,9 @@ Style/HashSyntax: Style/RedundantReturn: Enabled: True +Style/EndOfLine: + Enabled: False + Lint/AmbiguousOperator: Enabled: True @@ -530,3 +534,12 @@ Layout/IndentHeredoc: # disable Yaml safe_load. This is needed to support ruby2.0.0 development envs Security/YAMLLoad: Enabled: false + +# This affects hiera interpolation, as well as some configs that we push. +Style/FormatStringToken: + Enabled: false + +# This is useful, but sometimes a little too picky about where unit tests files +# are located. +RSpec/FilePath: + Enabled: false diff --git a/.travis.yml b/.travis.yml index 738e05bd5..83156c6a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,29 +15,29 @@ script: matrix: fast_finish: true include: - - rvm: 2.4.1 - bundler_args: --without development + - rvm: 2.4.2 + bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker services: docker sudo: required - - rvm: 2.4.1 - bundler_args: --without development + - rvm: 2.4.2 + bundler_args: --without development release dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker services: docker sudo: required - rvm: 2.1.9 - bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.1 - bundler_args: --without system_tests development - env: PUPPET_VERSION="~> 5.0" CHECK=test - - rvm: 2.4.1 - bundler_args: --without system_tests development + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=16 + - rvm: 2.4.2 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls + - rvm: 2.4.2 + bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=rubocop - - rvm: 2.4.1 - bundler_args: --without system_tests development + - rvm: 2.4.2 + bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: @@ -45,6 +45,11 @@ branches: - /^v\d/ notifications: email: false + irc: + on_success: always + on_failure: always + channels: + - "chat.freenode.org#voxpupuli-notifications" deploy: provider: puppetforge user: puppet diff --git a/Gemfile b/Gemfile index 2579f05db..b2a30cf30 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.2.0', :require => false + gem 'puppetlabs_spec_helper', '~> 2.5.0', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false @@ -22,18 +22,13 @@ group :test do gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-variable_contains_upcase', :require => false gem 'metadata-json-lint', :require => false - gem 'puppet-blacksmith', :require => false - gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' - gem 'puppet-strings', '~> 1.0', :require => false gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0' gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'mocha', '>= 1.2.1', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'github_changelog_generator', '~> 1.13.0', :require => false if RUBY_VERSION < '2.2.2' gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' - gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2' gem 'parallel_tests', :require => false gem 'toml', :require => false end @@ -46,8 +41,11 @@ group :development do end group :system_tests do + gem 'winrm', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) + else + gem 'beaker', '>= 3.9.0', :require => false end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) @@ -59,6 +57,13 @@ group :system_tests do gem 'beaker-module_install_helper', :require => false end +group :release do + gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2' + gem 'puppet-blacksmith', :require => false + gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' + gem 'puppet-strings', '~> 1.0', :require => false +end + if facterversion = ENV['FACTER_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index ab9411ba2..14ccf58b6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,13 @@ require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet_blacksmith/rake_tasks' -require 'voxpupuli/release/rake_tasks' -require 'puppet-strings/tasks' + +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'puppet_blacksmith/rake_tasks' + require 'voxpupuli/release/rake_tasks' + require 'puppet-strings/tasks' +rescue LoadError +end PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' PuppetLint.configuration.fail_on_warnings = true @@ -31,6 +37,17 @@ task test: [ :release_checks, ] +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' + end +end + begin require 'github_changelog_generator/task' GitHubChangelogGenerator::RakeTask.new :changelog do |config| @@ -39,6 +56,9 @@ begin config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} config.user = 'voxpupuli' + metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') + metadata = JSON.load(File.read(metadata_json)) + config.project = metadata['name'] end rescue LoadError end diff --git a/spec/acceptance/nodesets/docker/debian-7.yml b/spec/acceptance/nodesets/docker/debian-7.yml index 071acbf90..41b284d39 100644 --- a/spec/acceptance/nodesets/docker/debian-7.yml +++ b/spec/acceptance/nodesets/docker/debian-7.yml @@ -10,7 +10,6 @@ HOSTS: docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: - - 'echo deb http://ftp.debian.org/debian wheezy-backports main >> /etc/apt/sources.list' - 'apt-get update && apt-get install -y cron locales-all net-tools wget' CONFIG: trace_limit: 200 diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml index 7a1f35c37..a630b7efd 100644 --- a/spec/acceptance/nodesets/docker/debian-8.yml +++ b/spec/acceptance/nodesets/docker/debian-8.yml @@ -10,7 +10,6 @@ HOSTS: docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: - - 'echo deb http://ftp.debian.org/debian jessie-backports main >> /etc/apt/sources.list' - 'apt-get update && apt-get install -y cron locales-all net-tools wget' - 'rm -f /usr/sbin/policy-rc.d' - 'systemctl mask getty@tty1.service getty-static.service' diff --git a/spec/acceptance/nodesets/docker/debian-9.yml b/spec/acceptance/nodesets/docker/debian-9.yml new file mode 100644 index 000000000..dfc8e9c09 --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-9.yml @@ -0,0 +1,20 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/theforeman/foreman-installer-modulesync +HOSTS: + debian-9-x64: + platform: debian-9-amd64 + hypervisor: docker + image: debian:9 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y cron locales-all net-tools wget systemd-sysv' + - 'rm -f /usr/sbin/policy-rc.d' + - 'systemctl mask getty@tty1.service getty-static.service' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2aa9da74c..cdd493591 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,8 +8,7 @@ require 'simplecov-console' SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console, - Coveralls::SimpleCov::Formatter + SimpleCov::Formatter::Console ] SimpleCov.start do track_files 'lib/**/*.rb' From ff61bf9a98bfc5c124f4deeee39aa4cbf38abf56 Mon Sep 17 00:00:00 2001 From: devcfgc Date: Fri, 24 Nov 2017 11:38:54 +0100 Subject: [PATCH 083/146] update readme with examples of using grafana_datasource and grafana_dashboard --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index 14e9532af..0dc09f9fd 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,25 @@ grafana_dashboard { 'example_dashboard': `grafana_user` and `grafana_password` are optional, and required when authentication is enabled in Grafana. +Example: +Make sure the `grafana-server` service is up and running before creating the `grafana_dashboard` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module + +```puppet +http_conn_validator { 'grafana-conn-validator' : + host => 'localhost', + port => '3000', + use_ssl => false, + test_url => '/public/img/grafana_icon.svg', + require => Class['grafana'], +} -> +grafana_dashboard { 'example_dashboard': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => '5ecretPassw0rd', + content => template('path/to/exported/file.json'), +} +``` + ##### `grafana_datasource` In order to use the datasource resource, add the following to your manifest: @@ -385,6 +404,32 @@ from the browser, or `proxy` to send requests via grafana. Authentication is optional, as is `database`; additional `json_data` can be provided to allow custom configuration options. +Example: +Make sure the `grafana-server` service is up and running before creating the `grafana_datasource` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module + +```puppet +http_conn_validator { 'grafana-conn-validator' : + host => 'localhost', + port => '3000', + use_ssl => false, + test_url => '/public/img/grafana_icon.svg', + require => Class['grafana'], +} -> +grafana_datasource { 'influxdb': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => '5ecretPassw0rd', + type => 'influxdb', + url => 'http://localhost:8086', + user => 'admin', + password => '1nFlux5ecret', + database => 'graphite', + access_mode => 'proxy', + is_default => true, + json_data => template('path/to/additional/config.json'), +} +``` + ##### `grafana_plugin` An example is provided for convenience; for more details, please view the From 1a7d0cce06eb43ad4fd65d553b0118240e6117ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=B3mez?= Date: Sun, 26 Nov 2017 19:33:51 +0100 Subject: [PATCH 084/146] fixing puppet-lint --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0dc09f9fd..175f68710 100644 --- a/README.md +++ b/README.md @@ -367,8 +367,8 @@ http_conn_validator { 'grafana-conn-validator' : use_ssl => false, test_url => '/public/img/grafana_icon.svg', require => Class['grafana'], -} -> -grafana_dashboard { 'example_dashboard': +} +-> grafana_dashboard { 'example_dashboard': grafana_url => 'http://localhost:3000', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', @@ -414,8 +414,8 @@ http_conn_validator { 'grafana-conn-validator' : use_ssl => false, test_url => '/public/img/grafana_icon.svg', require => Class['grafana'], -} -> -grafana_datasource { 'influxdb': +} +-> grafana_datasource { 'influxdb': grafana_url => 'http://localhost:3000', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', From ed5ffbb4588678938ea3ae801d60feca977a1542 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 26 Nov 2017 16:02:13 +0100 Subject: [PATCH 085/146] release 4.0.3 --- CHANGELOG.md | 44 ++++++++++++++++++++++++++++++++------------ metadata.json | 2 +- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec341387d..49af64f75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,23 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.0.3](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.3) (2017-12-09) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.2...v4.0.3) + +**Closed issues:** + +- Apt key add gets called every run [\#77](https://github.com/voxpupuli/puppet-grafana/issues/77) +- Getting rid or changing the url check for grafana datasource url's [\#75](https://github.com/voxpupuli/puppet-grafana/issues/75) + +**Merged pull requests:** + +- Update readme with examples of using datasource and dashboard [\#80](https://github.com/voxpupuli/puppet-grafana/pull/80) ([devcfgc](https://github.com/devcfgc)) +- Removing the datasource url check as it leads to errors with postgres… [\#76](https://github.com/voxpupuli/puppet-grafana/pull/76) ([Faffnir](https://github.com/Faffnir)) +- Release 4.0.2 [\#74](https://github.com/voxpupuli/puppet-grafana/pull/74) ([dhollinger](https://github.com/dhollinger)) + ## [v4.0.2](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.2) (2017-10-12) + [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.1...v4.0.2) **Implemented enhancements:** @@ -15,8 +31,10 @@ These should not affect the functionality of the module. **Merged pull requests:** - fix typo in metadata \(redhat 6 twice vs 6/7\) [\#69](https://github.com/voxpupuli/puppet-grafana/pull/69) ([wyardley](https://github.com/wyardley)) +- Release 4.0.1 [\#68](https://github.com/voxpupuli/puppet-grafana/pull/68) ([wyardley](https://github.com/wyardley)) ## [v4.0.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.1) (2017-09-22) + [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.0...v4.0.1) **Fixed bugs:** @@ -25,16 +43,20 @@ These should not affect the functionality of the module. **Merged pull requests:** -- Release 4.0.1 [\#68](https://github.com/voxpupuli/puppet-grafana/pull/68) ([wyardley](https://github.com/wyardley)) +- Release 4.0.0 [\#62](https://github.com/voxpupuli/puppet-grafana/pull/62) ([bastelfreak](https://github.com/bastelfreak)) ## [v4.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.0) (2017-09-20) + [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v3.0.0...v4.0.0) -**Implemented enhancements:** +**Breaking changes:** - BREAKING: Switch to Puppet Data Types \(ldap\_cfg is now undef when disabled\) [\#66](https://github.com/voxpupuli/puppet-grafana/pull/66) ([wyardley](https://github.com/wyardley)) - BREAKING: Create grafana\_plugin resource type and change grafana::plugins [\#63](https://github.com/voxpupuli/puppet-grafana/pull/63) ([wyardley](https://github.com/wyardley)) - BREAKING: Update default Grafana version to 4.5.1 and improve acceptance tests [\#61](https://github.com/voxpupuli/puppet-grafana/pull/61) ([wyardley](https://github.com/wyardley)) + +**Implemented enhancements:** + - grafana\_user custom resource [\#60](https://github.com/voxpupuli/puppet-grafana/pull/60) ([atward](https://github.com/atward)) - Support newer versions of puppetlabs/apt module [\#53](https://github.com/voxpupuli/puppet-grafana/pull/53) ([ghoneycutt](https://github.com/ghoneycutt)) - Support custom plugins [\#44](https://github.com/voxpupuli/puppet-grafana/pull/44) ([bastelfreak](https://github.com/bastelfreak)) @@ -56,19 +78,16 @@ These should not affect the functionality of the module. - Update README.md [\#67](https://github.com/voxpupuli/puppet-grafana/pull/67) ([wyardley](https://github.com/wyardley)) - Get rid of the dependency on 'wget' module in favor of puppet-archive [\#65](https://github.com/voxpupuli/puppet-grafana/pull/65) ([wyardley](https://github.com/wyardley)) - Remove licenses from the top of files [\#64](https://github.com/voxpupuli/puppet-grafana/pull/64) ([wyardley](https://github.com/wyardley)) -- Release 4.0.0 [\#62](https://github.com/voxpupuli/puppet-grafana/pull/62) ([bastelfreak](https://github.com/bastelfreak)) - Always use jessie apt repo when osfamily is Debian. [\#41](https://github.com/voxpupuli/puppet-grafana/pull/41) ([furhouse](https://github.com/furhouse)) +- Bump version, Update changelog [\#38](https://github.com/voxpupuli/puppet-grafana/pull/38) ([dhoppe](https://github.com/dhoppe)) ## [v3.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v3.0.0) (2017-03-29) -[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.3...v3.0.0) - -**Implemented enhancements:** -- implement package\_ensure param for archlinux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.3...v3.0.0) **Fixed bugs:** -- implement package\\_ensure param for archlinux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) +- implement package\_ensure param for archlinux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) - FIX configuration file ownership [\#30](https://github.com/voxpupuli/puppet-grafana/pull/30) ([cassianoleal](https://github.com/cassianoleal)) **Closed issues:** @@ -78,7 +97,6 @@ These should not affect the functionality of the module. **Merged pull requests:** -- Bump version, Update changelog [\#38](https://github.com/voxpupuli/puppet-grafana/pull/38) ([dhoppe](https://github.com/dhoppe)) - Debian and RedHat based operating systems should use the repository by default [\#36](https://github.com/voxpupuli/puppet-grafana/pull/36) ([dhoppe](https://github.com/dhoppe)) - Add support for archlinux [\#32](https://github.com/voxpupuli/puppet-grafana/pull/32) ([bastelfreak](https://github.com/bastelfreak)) - Fix grafana\_dashboards [\#31](https://github.com/voxpupuli/puppet-grafana/pull/31) ([cassianoleal](https://github.com/cassianoleal)) @@ -87,15 +105,17 @@ These should not affect the functionality of the module. - The puppet 4-only release will start at 3.0.0 [\#21](https://github.com/voxpupuli/puppet-grafana/pull/21) ([rnelson0](https://github.com/rnelson0)) ## [v2.6.3](https://github.com/voxpupuli/puppet-grafana/tree/v2.6.3) (2017-01-18) -[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.2...v2.6.3) -## [v2.6.2](https://github.com/voxpupuli/puppet-grafana/tree/v2.6.2) (2017-01-18) -[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.1...v2.6.2) +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.2...v2.6.3) **Merged pull requests:** - release 2.6.2 \(optimistic, i know ;\) [\#20](https://github.com/voxpupuli/puppet-grafana/pull/20) ([igalic](https://github.com/igalic)) +## [v2.6.2](https://github.com/voxpupuli/puppet-grafana/tree/v2.6.2) (2017-01-18) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.1...v2.6.2) + ## v2.6.1 (2017-01-18) Just a notice: The next release will be a major one without Puppet 3 support! diff --git a/metadata.json b/metadata.json index ac7d46ba1..ff05ba9ee 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.3-rc0", + "version": "4.0.3", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 9b05f988769f82bde81daca50758949a2669bf52 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 9 Dec 2017 16:04:17 +0100 Subject: [PATCH 086/146] [blacksmith] Bump version to 4.0.4-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index ff05ba9ee..95bee7da9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.3", + "version": "4.0.4-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From fea6450fc5b3b9ee086113b1d321a84ca2693dca Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 4 Jan 2018 00:52:44 +0100 Subject: [PATCH 087/146] modulesync 1.6.0 --- .msync.yml | 2 +- .rubocop.yml | 2 +- .travis.yml | 31 +++++++++++++------------------ Rakefile | 27 +++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/.msync.yml b/.msync.yml index 80959a381..08e85ce0e 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.5.0' +modulesync_config_version: '1.6.0' diff --git a/.rubocop.yml b/.rubocop.yml index 3fc819bf5..099a11c53 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -46,7 +46,7 @@ Style/HashSyntax: Style/RedundantReturn: Enabled: True -Style/EndOfLine: +Layout/EndOfLine: Enabled: False Lint/AmbiguousOperator: diff --git a/.travis.yml b/.travis.yml index 83156c6a3..f738c6c40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,29 +4,12 @@ dist: trusty language: ruby cache: bundler before_install: - - bundle -v - - rm Gemfile.lock || true - - gem update --system - - gem update bundler - - gem --version - - bundle -v + - rm -f Gemfile.lock script: - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - - rvm: 2.4.2 - bundler_args: --without development release - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker - services: docker - sudo: required - - rvm: 2.4.2 - bundler_args: --without development release - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker - services: docker - sudo: required - rvm: 2.1.9 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=16 @@ -39,6 +22,18 @@ matrix: - rvm: 2.4.2 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes + - rvm: 2.4.2 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker + services: docker + sudo: required + - rvm: 2.4.2 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker + services: docker + sudo: required branches: only: - master diff --git a/Rakefile b/Rakefile index 14ccf58b6..279580ac6 100644 --- a/Rakefile +++ b/Rakefile @@ -26,6 +26,12 @@ exclude_paths = %w( PuppetLint.configuration.ignore_paths = exclude_paths PuppetSyntax.exclude_paths = exclude_paths +desc 'Auto-correct puppet-lint offenses' +task 'lint:auto_correct' do + PuppetLint.configuration.fix = true + Rake::Task[:lint].invoke +end + desc 'Run acceptance tests' RSpec::Core::RakeTask.new(:acceptance) do |t| t.pattern = 'spec/acceptance' @@ -48,6 +54,27 @@ task test_with_coveralls: [:test] do end end +desc "Print supported beaker sets" +task 'beaker_sets', [:directory] do |t, args| + directory = args[:directory] + + metadata = JSON.load(File.read('metadata.json')) + + (metadata['operatingsystem_support'] || []).each do |os| + (os['operatingsystemrelease'] || []).each do |release| + if directory + beaker_set = "#{directory}/#{os['operatingsystem'].downcase}-#{release}" + else + beaker_set = "#{os['operatingsystem'].downcase}-#{release}-x64" + end + + filename = "spec/acceptance/nodesets/#{beaker_set}.yml" + + puts beaker_set if File.exists? filename + end + end +end + begin require 'github_changelog_generator/task' GitHubChangelogGenerator::RakeTask.new :changelog do |config| From bffadfdf07b2193462ecedaf0b17de3bfcc62740 Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Fri, 1 Dec 2017 13:10:08 -0500 Subject: [PATCH 088/146] (SIMP-4206) Added Organization Provider and updated Datasource Provider - Updated grafana datasource provider to allow datasources to be created on specific organizations - Added grafana organization provider to allow organizations to be created - Updated README to add more descriptive information for previous features as well as new Fixes commercial/enterprise-meta#91 SIMP-4206 #close --- README.md | 117 +++++++++++++++++- .../provider/grafana_datasource/grafana.rb | 99 ++++++++++++++- .../provider/grafana_organization/grafana.rb | 102 +++++++++++++++ lib/puppet/type/grafana_datasource.rb | 35 ++++++ lib/puppet/type/grafana_organization.rb | 48 +++++++ .../type/grafana_datasource_type_spec.rb | 25 +++- .../type/grafana_organization_type_spec.rb | 49 ++++++++ 7 files changed, 469 insertions(+), 6 deletions(-) create mode 100644 lib/puppet/provider/grafana_organization/grafana.rb create mode 100644 lib/puppet/type/grafana_organization.rb create mode 100644 spec/unit/puppet/type/grafana_organization_type_spec.rb diff --git a/README.md b/README.md index 175f68710..c6a78a398 100644 --- a/README.md +++ b/README.md @@ -340,7 +340,25 @@ Example: The module includes several custom types: -##### `grafana_dashboard` +#### `grafana_organization` + +In order to use the organization resource, add the following to your manifest: + +```puppet +grafana_organization { 'example_org': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => '5ecretPassw0rd', +} +``` + +`grafana_url`, `grafana_user`, and `grafana_password` are required to create organizations via the API. + +`name` is optional if the name will differ from example_org above. + +`address` is an optional parameter that requires a hash. Address settings are `{"address1":"","address2":"","city":"","zipCode":"","state":"","country":""}` + +#### `grafana_dashboard` In order to use the dashboard resource, add the following to your manifest: @@ -386,6 +404,7 @@ grafana_datasource { 'influxdb': grafana_user => 'admin', grafana_password => '5ecretPassw0rd', type => 'influxdb', + org_name => 'NewOrg', url => 'http://localhost:8086', user => 'admin', password => '1nFlux5ecret', @@ -396,11 +415,15 @@ grafana_datasource { 'influxdb': } ``` -Available default types are: influxdb, elasticsearch, graphite, kairosdb, opentsdb, prometheus +Available types are: influxdb, elasticsearch, graphite, cloudwatch, mysql, opentsdb, and prometheus + +`org_name` is used to set which organization a datasource will be created on. If this parameter is not set, it will default to organization ID 1 (Main Org. by default). If the default org is deleted, organizations will need to be specified. Access mode determines how Grafana connects to the datasource, either `direct` from the browser, or `proxy` to send requests via grafana. +Setting `basic_auth` to `true` will allow use of the `basic_auth_user` and `basic_auth_password` params. + Authentication is optional, as is `database`; additional `json_data` can be provided to allow custom configuration options. @@ -430,6 +453,96 @@ http_conn_validator { 'grafana-conn-validator' : } ``` +Note that the `database` is dynamic, setting things other than "database" for separate types. Ex: for Elasticsearch it will set the Index Name. + +**`jsonData` Settings** + +Note that there are separate options for json_data based on the type of datasource you create. + +##### **Elasticsearch** + +`esVersion` - Required, either 2 or 5, set as a bare number. + +`timeField` - Required. By default this is @timestamp, but without setting it in jsonData, the datasource won't work without refreshing it in the GUI. + +`timeInterval` - Optional. A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example "1m" if your data is written every minute. + +Example: +```puppet +json_data => {"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"} +``` + +##### **CloudWatch** + +`authType` - Required. Options are `Access & Secret Key`, `Credentials File`, or `ARN`. + +-"keys" = Access & Secret Key + +-"credentials" = Credentials File + +-"arn" = ARN + +*When setting authType to `credentials`, the `database` param will set the Credentials Profile Name.* + +*When setting authType to `arn`, another jsonData value of `assumeRoleARN` is available, which is not required for other authType settings* + +`customMetricsNamespaces` - Optional. Namespaces of Custom Metrics, separated by commas within double quotes. + +`defaultRegion` - Required. Options are "ap-northeast-(1 or 2)", "ap-southeast-(1 or 2)", "ap-south-1", "ca-central-1", "cn-north-1", "eu-central-1", "eu-west-(1 or 2)", "sa-east-(1 or 2)", "us-east-(1 or 2)", "us-gov-west-1", "us-west-(1 or 2)". + +`timeField` + +Example: +```puppet +{"authType":"arn","assumeRoleARN":"arn:aws:iam:*","customMetricsNamespaces":"Namespace1,Namespace2","defaultRegion":"us-east-1","timeField":"@timestamp"} +``` + +##### **Graphite** + +`graphiteVersion` - Required. Available versions are `0.9` or `1.0`. + +`tlsAuth` - Set to `true` or `false` + +`tlsAuthWithCACert` - Set to `true` or `false` + +Example: +```puppet +{"graphiteVersion":"0.9","tlsAuth":true,"tlsAuthWithCACert":false} +``` + +##### **OpenTSDB** + +`tsdbResolution` - Required. Options are `1` or `2`. + + `1` = second + + `2` = millisecond + +`tsdbVersion` - Required. Options are `1`, `2`, or `3`. + + `1`    =    <=2.1 + + `2`    =    ==2.2 + + `3`    =    ==2.3 + +Example: +```puppet +{"tsdbResolution:1,"tsdbVersion":3} +``` + +##### **InfluxDB** + +N/A + +##### **MySQL** + +N/A + +##### **Prometheus** + +N/A + ##### `grafana_plugin` An example is provided for convenience; for more details, please view the diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 6ac97ecdd..bd0050644 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -9,6 +9,44 @@ defaultfor kernel: 'Linux' + def organization + resource[:organization] + end + + def fetch_organizations + response = send_request('GET', '/api/orgs') + if response.code != '200' + raise format('Fail to retrieve organizations (HTTP response: %s/%s)', response.code, response.body) + end + + begin + fetch_organizations = JSON.parse(response.body) + + fetch_organizations.map { |x| x['id'] }.map do |id| + response = send_request 'GET', format('/api/orgs/%s', id) + if response.code != '200' + raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) + end + + fetch_organization = JSON.parse(response.body) + + { + id: fetch_organization['id'], + name: fetch_organization['name'] + } + end + rescue JSON::ParserError + raise format('Failed to parse response: %s', response.body) + end + end + + def fetch_organization + unless @fetch_organization + @fetch_organization = fetch_organizations.find { |x| x[:name] == resource[:organization] } + end + @organization + end + def datasources response = send_request('GET', '/api/datasources') if response.code != '200' @@ -21,7 +59,7 @@ def datasources datasources.map { |x| x['id'] }.map do |id| response = send_request 'GET', format('/api/datasources/%s', id) if response.code != '200' - raise format('Fail to retrieve datasource %d (HTTP response: %s/%s)', id, response.code, response.body) + raise format('Failed to retrieve datasource %d (HTTP response: %s/%s)', id, response.code, response.body) end datasource = JSON.parse(response.body) @@ -36,11 +74,15 @@ def datasources database: datasource['database'], access_mode: datasource['access'], is_default: datasource['isDefault'] ? :true : :false, + with_credentials: datasource['withCredentials'] ? :true : :false, + basic_auth: datasource['basicAuth'] ? :true : :false, + basic_auth_user: datasource['basicAuthUser'], + basic_auth_password: datasource['basicAuthPassword'], json_data: datasource['jsonData'] } end rescue JSON::ParserError - raise format('Fail to parse response: %s', response.body) + raise format('Failed to parse response: %s', response.body) end end @@ -118,6 +160,42 @@ def is_default=(value) end # rubocop:enable Style/PredicateName + def basic_auth + datasource[:basic_auth] + end + + def basic_auth=(value) + resource[:basic_auth] = value + save_datasource + end + + def basic_auth_user + datasource[:basic_auth_user] + end + + def basic_auth_user=(value) + resource[:basic_auth_user] = value + save_datasource + end + + def basic_auth_password + datasource[:basic_auth_password] + end + + def basic_auth_password=(value) + resource[:basic_auth_password] = value + save_datasource + end + + def with_credentials + datasource[:is_default] + end + + def with_credentials=(value) + resource[:with_credentials] = value + save_datasource + end + def json_data datasource[:json_data] end @@ -128,6 +206,19 @@ def json_data=(value) end def save_datasource + if fetch_organization.nil? + response = send_request('POST', '/api/user/using/1') + if response.code != '200' + raise format('Failed to switch to org 1 (HTTP response: %s/%s)', response.code, response.body) + end + else + organization_id = fetch_organization[:id] + response = send_request 'POST', format('/api/user/using/%s', organization_id) + if response.code != '200' + raise format('Failed to switch to org %s (HTTP response: %s/%s)', organization_id, response.code, response.body) + end + end + data = { name: resource[:name], type: resource[:type], @@ -137,6 +228,10 @@ def save_datasource user: resource[:user], password: resource[:password], isDefault: (resource[:is_default] == :true), + basicAuth: (resource[:basic_auth] == :true), + basicAuthUser: resource[:basic_auth_user], + basicAuthPassword: resource[:basic_auth_password], + withCredentials: (resource[:with_credentials] == :true), jsonData: resource[:json_data] } diff --git a/lib/puppet/provider/grafana_organization/grafana.rb b/lib/puppet/provider/grafana_organization/grafana.rb new file mode 100644 index 000000000..222d6c78b --- /dev/null +++ b/lib/puppet/provider/grafana_organization/grafana.rb @@ -0,0 +1,102 @@ +require 'json' + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'grafana')) + +Puppet::Type.type(:grafana_organization).provide(:grafana, parent: Puppet::Provider::Grafana) do + desc 'Support for Grafana organizations' + + defaultfor kernel: 'Linux' + + def organizations + response = send_request('GET', '/api/orgs') + if response.code != '200' + raise format('Failed to retrieve organizations (HTTP response: %s/%s)', response.code, response.body) + end + + begin + organizations = JSON.parse(response.body) + + organizations.map { |x| x['id'] }.map do |id| + response = send_request 'GET', format('/api/orgs/%s', id) + if response.code != '200' + raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) + end + + organization = JSON.parse(response.body) + + { + id: organization['id'], + name: organization['name'], + address: organization['address'] + } + end + rescue JSON::ParserError + raise format('Failed to parse response: %s', response.body) + end + end + + def organization + unless @organization + @organization = organizations.find { |x| x[:name] == resource[:name] } + end + @organization + end + + attr_writer :organization + + # rubocop:enable Style/PredicateName + + def id + organization[:id] + end + + def id=(value) + resource[:id] = value + save_organization + end + + def address + organization[:json_data] + end + + def address=(value) + resource[:address] = value + save_organization + end + + def save_organization + data = { + id: resource[:id], + name: resource[:name], + address: resource[:address] + } + + response = send_request('POST', '/api/orgs', data) if organization.nil? + + if response.code != '200' + raise format('Failed to create save %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) + end + self.organization = nil + end + + def delete_organization + response = send_request 'DELETE', format('/api/orgs/%s', organization[:id]) + + if response.code != '200' + raise format('Failed to delete organization %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) + end + self.organization = nil + end + + def create + save_organization + end + + def destroy + delete_organization + end + + def exists? + organization + end +end diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index e168fde0a..88d2fa487 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -30,10 +30,22 @@ newproperty(:url) do desc 'The URL of the datasource' + + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end + end end newproperty(:type) do desc 'The datasource type' + newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus) + end + + newproperty(:organization) do + desc 'The organization name to create the datasource on' + defaultto '1' end newproperty(:user) do @@ -60,6 +72,28 @@ defaultto :false end + newproperty(:basic_auth) do + desc 'Whether basic auth is enabled or not' + newvalues(:true, :false) + defaultto :false + end + + newproperty(:basic_auth_user) do + desc 'The username for basic auth if enabled' + defaultto '' + end + + newproperty(:basic_auth_password) do + desc 'The password for basic auth if enabled' + defaultto '' + end + + newproperty(:with_credentials) do + desc 'Whether credentials such as cookies or auth headers should be sent with cross-site requests' + newvalues(:true, :false) + defaultto :false + end + newproperty(:json_data) do desc 'Additional JSON data to configure the datasource (optional)' @@ -69,6 +103,7 @@ end end end + autorequire(:service) do 'grafana-server' end diff --git a/lib/puppet/type/grafana_organization.rb b/lib/puppet/type/grafana_organization.rb new file mode 100644 index 000000000..caf3c692e --- /dev/null +++ b/lib/puppet/type/grafana_organization.rb @@ -0,0 +1,48 @@ +Puppet::Type.newtype(:grafana_organization) do + @doc = 'Manage organizations in Grafana' + + ensurable do + defaultvalues + defaultto :present + end + + newparam(:name, namevar: true) do + desc 'The name of the organization.' + end + + newparam(:grafana_url) do + desc 'The URL of the Grafana server' + defaultto '' + + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end + end + end + + newparam(:grafana_user) do + desc 'The username for the Grafana server' + end + + newparam(:grafana_password) do + desc 'The password for the Grafana server' + end + + newproperty(:id) do + desc 'The ID of the organization' + end + + newproperty(:address) do + desc 'Additional JSON data to configure the organization address (optional)' + + validate do |value| + unless value.nil? || value.is_a?(Hash) + raise ArgumentError, 'address should be a Hash!' + end + end + end + autorequire(:service) do + 'grafana-server' + end +end diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index 8688f4b35..b25656cfe 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -15,7 +15,7 @@ describe Puppet::Type.type(:grafana_datasource) do let(:gdatasource) do - described_class.new name: 'foo', grafana_url: 'http://example.com', url: 'http://influx.example.com' + described_class.new name: 'foo', grafana_url: 'http://example.com', url: 'http://es.example.com', type: 'elasticsearch', organization: 'test_org', access_mode: 'proxy', is_default: true, basic_auth: true, basic_auth_user: 'user', basic_auth_password: 'password', with_credentials: true, database: 'test_db', user: 'db_user', password: 'db_password', json_data: '{"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"}' end context 'when setting parameters' do @@ -25,6 +25,12 @@ end.to raise_error(Puppet::Error, %r{not a valid URL}) end + it "fails if url isn't HTTP-based" do + expect do + described_class.new name: 'foo', url: 'example.com', content: '{}', ensure: :present + end.to raise_error(Puppet::Error, %r{not a valid URL}) + end + it "fails if json_data isn't valid" do expect do described_class.new name: 'foo', grafana_url: 'http://example.com', json_data: 'invalid', ensure: :present @@ -35,8 +41,22 @@ it 'accepts valid parameters' do expect(gdatasource[:name]).to eq('foo') expect(gdatasource[:grafana_url]).to eq('http://example.com') - expect(gdatasource[:url]).to eq('http://influx.example.com') + expect(gdatasource[:url]).to eq('http://es.example.com') + expect(gdatasource[:type]).to eq(:elasticsearch) + expect(gdatasource[:organization]).to eq('test_org') + expect(gdatasource[:access_mode]).to eq(:proxy) + expect(gdatasource[:is_default]).to eq(:true) + expect(gdatasource[:basic_auth]).to eq(:true) + expect(gdatasource[:basic_auth_user]).to eq('user') + expect(gdatasource[:basic_auth_password]).to eq('password') + expect(gdatasource[:with_credentials]).to eq(:true) + expect(gdatasource[:database]).to eq('test_db') + expect(gdatasource[:user]).to eq('db_user') + expect(gdatasource[:password]).to eq('db_password') + expect(gdatasource[:json_data]).to eq('{"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"}') end + # rubocop:enable RSpec/MultipleExpectations + it 'autorequires the grafana-server for proper ordering' do catalog = Puppet::Resource::Catalog.new service = Puppet::Type.type(:service).new(name: 'grafana-server') @@ -48,6 +68,7 @@ end expect(relationship).to be_a Puppet::Relationship end + it 'does not autorequire the service it is not managed' do catalog = Puppet::Resource::Catalog.new catalog.add_resource gdatasource diff --git a/spec/unit/puppet/type/grafana_organization_type_spec.rb b/spec/unit/puppet/type/grafana_organization_type_spec.rb new file mode 100644 index 000000000..d3685f0b0 --- /dev/null +++ b/spec/unit/puppet/type/grafana_organization_type_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe Puppet::Type.type(:grafana_organization) do + let(:gorganization) do + described_class.new name: 'foo', grafana_url: 'http://example.com', grafana_user: 'admin', grafana_password: 'admin', address: '{"address1":"test address1","address2":"test address2","city":"CityName","state":"NewState","zipcode":"12345","country":"USA"}' + end + + context 'when setting parameters' do + it "fails if json_data isn't valid" do + expect do + described_class.new name: 'foo', address: 'invalid address' + end.to raise_error(Puppet::Error, %r{address should be a Hash!}) + end + + it "fails if grafana_url isn't HTTP-based" do + expect do + described_class.new name: 'foo', grafana_url: 'example.com', content: '{}', ensure: :present + end.to raise_error(Puppet::Error, %r{not a valid URL}) + end + + # rubocop:disable RSpec/MultipleExpectations + it 'accepts valid parameters' do + expect(gorganization[:name]).to eq('foo') + expect(gorganization[:grafana_user]).to eq('admin') + expect(gorganization[:grafana_password]).to eq('admin') + expect(gorganization[:grafana_url]).to eq('http://example.com') + expect(gorganization[:address]).to eq('{"address1":"test address1","address2":"test address2","city":"CityName","state":"NewState","zipcode":"12345","country":"USA"}') + end + # rubocop:enable RSpec/MultipleExpectations + + it 'autorequires the grafana-server for proper ordering' do + catalog = Puppet::Resource::Catalog.new + service = Puppet::Type.type(:service).new(name: 'grafana-server') + catalog.add_resource service + catalog.add_resource gorganization + + relationship = gorganization.autorequire.find do |rel| + (rel.source.to_s == 'Service[grafana-server]') && (rel.target.to_s == gorganization.to_s) + end + expect(relationship).to be_a Puppet::Relationship + end + + it 'does not autorequire the service it is not managed' do + catalog = Puppet::Resource::Catalog.new + catalog.add_resource gorganization + expect(gorganization.autorequire).to be_empty + end + end +end From 13a270613e956e4d7434860b681a3dc44d4e6cf6 Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Fri, 2 Feb 2018 10:56:07 -0500 Subject: [PATCH 089/146] Updating to fix spec tests/rubocop errors --- .../type/grafana_datasource_type_spec.rb | 21 ++++++++++++++++--- .../type/grafana_organization_type_spec.rb | 12 ++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index b25656cfe..60d4fcbd7 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -15,7 +15,23 @@ describe Puppet::Type.type(:grafana_datasource) do let(:gdatasource) do - described_class.new name: 'foo', grafana_url: 'http://example.com', url: 'http://es.example.com', type: 'elasticsearch', organization: 'test_org', access_mode: 'proxy', is_default: true, basic_auth: true, basic_auth_user: 'user', basic_auth_password: 'password', with_credentials: true, database: 'test_db', user: 'db_user', password: 'db_password', json_data: '{"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"}' + described_class.new( + name: 'foo', + grafana_url: 'http://example.com', + url: 'http://es.example.com', + type: 'elasticsearch', + organization: 'test_org', + access_mode: 'proxy', + is_default: true, + basic_auth: true, + basic_auth_user: 'user', + basic_auth_password: 'password', + with_credentials: true, + database: 'test_db', + user: 'db_user', + password: 'db_password', + json_data: {:esVersion=>5,:timeField=>"@timestamp",:timeInterval=>"1m"} + ) end context 'when setting parameters' do @@ -36,7 +52,6 @@ described_class.new name: 'foo', grafana_url: 'http://example.com', json_data: 'invalid', ensure: :present end.to raise_error(Puppet::Error, %r{json_data should be a Hash}) end - # rubocop:disable RSpec/MultipleExpectations it 'accepts valid parameters' do expect(gdatasource[:name]).to eq('foo') @@ -53,7 +68,7 @@ expect(gdatasource[:database]).to eq('test_db') expect(gdatasource[:user]).to eq('db_user') expect(gdatasource[:password]).to eq('db_password') - expect(gdatasource[:json_data]).to eq('{"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"}') + expect(gdatasource[:json_data]).to eq(esVersion: 5, timeField: '@timestamp', timeInterval: '1m') end # rubocop:enable RSpec/MultipleExpectations diff --git a/spec/unit/puppet/type/grafana_organization_type_spec.rb b/spec/unit/puppet/type/grafana_organization_type_spec.rb index d3685f0b0..aee004ccd 100644 --- a/spec/unit/puppet/type/grafana_organization_type_spec.rb +++ b/spec/unit/puppet/type/grafana_organization_type_spec.rb @@ -2,7 +2,13 @@ describe Puppet::Type.type(:grafana_organization) do let(:gorganization) do - described_class.new name: 'foo', grafana_url: 'http://example.com', grafana_user: 'admin', grafana_password: 'admin', address: '{"address1":"test address1","address2":"test address2","city":"CityName","state":"NewState","zipcode":"12345","country":"USA"}' + described_class.new( + name: 'foo', + grafana_url: 'http://example.com', + grafana_user: 'admin', + grafana_password: 'admin', + address: { address1: 'test address1', address2: 'test address2', city: 'CityName', state: 'NewState', zipcode: '12345', country: 'USA' } + ) end context 'when setting parameters' do @@ -17,14 +23,14 @@ described_class.new name: 'foo', grafana_url: 'example.com', content: '{}', ensure: :present end.to raise_error(Puppet::Error, %r{not a valid URL}) end - + # rubocop:disable RSpec/MultipleExpectations it 'accepts valid parameters' do expect(gorganization[:name]).to eq('foo') expect(gorganization[:grafana_user]).to eq('admin') expect(gorganization[:grafana_password]).to eq('admin') expect(gorganization[:grafana_url]).to eq('http://example.com') - expect(gorganization[:address]).to eq('{"address1":"test address1","address2":"test address2","city":"CityName","state":"NewState","zipcode":"12345","country":"USA"}') + expect(gorganization[:address]).to eq(address1: 'test address1', address2: 'test address2', city: 'CityName', state: 'NewState', zipcode: '12345', country: 'USA') end # rubocop:enable RSpec/MultipleExpectations From 531aeda864e068edd27df595fffef1230abf27b0 Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Fri, 2 Feb 2018 15:10:01 -0500 Subject: [PATCH 090/146] final rubocop fix --- spec/unit/puppet/type/grafana_datasource_type_spec.rb | 4 ++-- spec/unit/puppet/type/grafana_organization_type_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index 60d4fcbd7..fc302963d 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -15,7 +15,7 @@ describe Puppet::Type.type(:grafana_datasource) do let(:gdatasource) do - described_class.new( + described_class.new( name: 'foo', grafana_url: 'http://example.com', url: 'http://es.example.com', @@ -30,7 +30,7 @@ database: 'test_db', user: 'db_user', password: 'db_password', - json_data: {:esVersion=>5,:timeField=>"@timestamp",:timeInterval=>"1m"} + json_data: { esVersion: 5, timeField: '@timestamp', timeInterval: '1m' } ) end diff --git a/spec/unit/puppet/type/grafana_organization_type_spec.rb b/spec/unit/puppet/type/grafana_organization_type_spec.rb index aee004ccd..522ec0e45 100644 --- a/spec/unit/puppet/type/grafana_organization_type_spec.rb +++ b/spec/unit/puppet/type/grafana_organization_type_spec.rb @@ -23,7 +23,7 @@ described_class.new name: 'foo', grafana_url: 'example.com', content: '{}', ensure: :present end.to raise_error(Puppet::Error, %r{not a valid URL}) end - + # rubocop:disable RSpec/MultipleExpectations it 'accepts valid parameters' do expect(gorganization[:name]).to eq('foo') From 6743a794c37e3815797b75f25205a90cd03bd993 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 3 Feb 2018 01:16:19 +0100 Subject: [PATCH 091/146] modulesync 1.7.0 --- .msync.yml | 2 +- .travis.yml | 2 +- Gemfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.msync.yml b/.msync.yml index 08e85ce0e..046cac86b 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.6.0' +modulesync_config_version: '1.7.0' diff --git a/.travis.yml b/.travis.yml index f738c6c40..5f077928d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: include: - rvm: 2.1.9 bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=16 + env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12 - rvm: 2.4.2 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls diff --git a/Gemfile b/Gemfile index b2a30cf30..8ded02b2d 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,7 @@ group :system_tests do end group :release do - gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2' + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator' if RUBY_VERSION >= '2.2.2' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' gem 'puppet-strings', '~> 1.0', :require => false From bc655cff81ba5e5fafee86d4832e0db31b1fd28b Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 3 Feb 2018 10:21:19 +0100 Subject: [PATCH 092/146] release 4.1.0 --- CHANGELOG.md | 18 +++++++++++++++++- metadata.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49af64f75..0df0bd363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.1.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.0) (2018-02-03) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.3...v4.1.0) + +**Implemented enhancements:** + +- \(SIMP-4206\) Added organization provider and updated datasource provider [\#86](https://github.com/voxpupuli/puppet-grafana/pull/86) ([heliocentric](https://github.com/heliocentric)) + +**Closed issues:** + +- "Could not autoload" error in grafana\_dashboard with ruby 2.4 on Centos 6 [\#83](https://github.com/voxpupuli/puppet-grafana/issues/83) + +**Merged pull requests:** + +- release 4.0.3 [\#81](https://github.com/voxpupuli/puppet-grafana/pull/81) ([bastelfreak](https://github.com/bastelfreak)) + ## [v4.0.3](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.3) (2017-12-09) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.2...v4.0.3) @@ -253,4 +269,4 @@ This is the last Release that supports it! First release on the Puppet Forge -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/metadata.json b/metadata.json index 95bee7da9..470786bdb 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.0.4-rc0", + "version": "4.1.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From ec2403fb738f316cc8536ce5ce339f6827282cfa Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 3 Feb 2018 11:05:30 +0100 Subject: [PATCH 093/146] [blacksmith] Bump version to 4.1.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 470786bdb..b75c5b46b 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.1.0", + "version": "4.1.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From bbaba72800b36c7632edec310ed6975b24b1940b Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Fri, 16 Feb 2018 13:38:33 -0500 Subject: [PATCH 094/146] fix datasource provider error with_credentials def was referencing datasource[:is_default] and preventing idempotency --- lib/puppet/provider/grafana_datasource/grafana.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index bd0050644..6acc62bd0 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -188,7 +188,7 @@ def basic_auth_password=(value) end def with_credentials - datasource[:is_default] + datasource[:with_credentials] end def with_credentials=(value) From a6609703c844d12d23afd86f364146a8397b72e2 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 21 Feb 2018 16:55:31 +0100 Subject: [PATCH 095/146] modulesync 1.8.0 --- .msync.yml | 2 +- .travis.yml | 13 ++++++++----- Gemfile | 2 +- spec/acceptance/nodesets/fedora-25-x64.yml | 2 -- spec/acceptance/nodesets/fedora-26-x64.yml | 16 ++++++++++++++++ spec/acceptance/nodesets/fedora-27-x64.yml | 18 ++++++++++++++++++ 6 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 spec/acceptance/nodesets/fedora-26-x64.yml create mode 100644 spec/acceptance/nodesets/fedora-27-x64.yml diff --git a/.msync.yml b/.msync.yml index 046cac86b..4df90fba4 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.7.0' +modulesync_config_version: '1.8.0' diff --git a/.travis.yml b/.travis.yml index 5f077928d..43f560aae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,22 +13,25 @@ matrix: - rvm: 2.1.9 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12 - - rvm: 2.4.2 + - rvm: 2.4.3 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls - - rvm: 2.4.2 + - rvm: 2.5.0 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls + - rvm: 2.4.3 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=rubocop - - rvm: 2.4.2 + - rvm: 2.4.3 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - - rvm: 2.4.2 + - rvm: 2.4.3 bundler_args: --without development release dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker services: docker sudo: required - - rvm: 2.4.2 + - rvm: 2.4.3 bundler_args: --without development release dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker diff --git a/Gemfile b/Gemfile index 8ded02b2d..32e6600eb 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.5.0', :require => false + gem 'puppetlabs_spec_helper', '~> 2.6.0', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false diff --git a/spec/acceptance/nodesets/fedora-25-x64.yml b/spec/acceptance/nodesets/fedora-25-x64.yml index 60ae01179..54dd33054 100644 --- a/spec/acceptance/nodesets/fedora-25-x64.yml +++ b/spec/acceptance/nodesets/fedora-25-x64.yml @@ -3,8 +3,6 @@ # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config # -# platform is fedora 24 because there is no -# puppet-agent for fedora 25 by 2016-12-30 HOSTS: fedora-25-x64: roles: diff --git a/spec/acceptance/nodesets/fedora-26-x64.yml b/spec/acceptance/nodesets/fedora-26-x64.yml new file mode 100644 index 000000000..598822b0e --- /dev/null +++ b/spec/acceptance/nodesets/fedora-26-x64.yml @@ -0,0 +1,16 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +HOSTS: + fedora-26-x64: + roles: + - master + platform: fedora-26-x86_64 + box: fedora/26-cloud-base + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/fedora-27-x64.yml b/spec/acceptance/nodesets/fedora-27-x64.yml new file mode 100644 index 000000000..c2b61ebbf --- /dev/null +++ b/spec/acceptance/nodesets/fedora-27-x64.yml @@ -0,0 +1,18 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# platform is fedora 26 because there is no puppet-agent +# for fedora 27 as of 2017-11-17 +HOSTS: + fedora-27-x64: + roles: + - master + platform: fedora-26-x86_64 + box: fedora/27-cloud-base + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml From 5d4ed82fa221046826e3dbac1588336db645e9f1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 21 Feb 2018 17:00:38 +0100 Subject: [PATCH 096/146] release 4.1.1 --- CHANGELOG.md | 13 +++++++++++++ metadata.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0df0bd363..fe43be3ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.1.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.1) (2018-02-21) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.1.0...v4.1.1) + +**Fixed bugs:** + +- grafana\_datasource provider with\_credentials\(\) returns is\_default value [\#89](https://github.com/voxpupuli/puppet-grafana/issues/89) +- fix datasource provider error [\#90](https://github.com/voxpupuli/puppet-grafana/pull/90) ([brandonrdn](https://github.com/brandonrdn)) + +**Merged pull requests:** + +- release 4.1.0 [\#88](https://github.com/voxpupuli/puppet-grafana/pull/88) ([bastelfreak](https://github.com/bastelfreak)) + ## [v4.1.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.0) (2018-02-03) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.3...v4.1.0) diff --git a/metadata.json b/metadata.json index b75c5b46b..fa81ccda5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.1.1-rc0", + "version": "4.1.1", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 3f432205c3467b4614de47f488b1f94646bc3426 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 21 Feb 2018 17:15:15 +0100 Subject: [PATCH 097/146] [blacksmith] Bump version to 4.1.2-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index fa81ccda5..f7adbf03c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.1.1", + "version": "4.1.2-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 3cd219c874986e90cd31345bb5e2e2585d9d3930 Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Wed, 18 Jan 2017 20:04:51 +0100 Subject: [PATCH 098/146] Add grafana_api_path to allow for API sub-paths - Updated types and providers to allow the grafana_api_path parameter to be set when using sub-paths for the API --- README.md | 23 ++++++++++++++++--- .../provider/grafana_dashboard/grafana.rb | 8 +++---- .../provider/grafana_datasource/grafana.rb | 18 +++++++-------- .../provider/grafana_organization/grafana.rb | 8 +++---- lib/puppet/provider/grafana_user/grafana.rb | 14 +++++------ lib/puppet/type/grafana_dashboard.rb | 11 +++++++++ lib/puppet/type/grafana_datasource.rb | 11 +++++++++ lib/puppet/type/grafana_organization.rb | 11 +++++++++ lib/puppet/type/grafana_user.rb | 11 +++++++++ 9 files changed, 88 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index c6a78a398..c0e5cc8dc 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,20 @@ Example: ``` + +#### Using a sub-path for Grafana API + +If you are using a sub-path for the Grafana API, you will need to set the `grafana_api_path` parameter for the following custom types: +- `grafana_dashboard` +- `grafana_datasource` +- `grafana_organization` +- `grafana_user` + +For instance, if your sub-path is `/grafana`, the `grafana_api_path` must +be set to `/grafana/api`. Do not add a trailing `/` (slash) at the end of the value. + +If you are not using sub-paths, you do not need to set this parameter. + #### Custom Types and Providers The module includes several custom types: @@ -367,13 +381,14 @@ grafana_dashboard { 'example_dashboard': grafana_url => 'http://localhost:3000', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', + grafana_api_path => '/grafana/api' content => template('path/to/exported/file.json'), } ``` `content` must be valid JSON, and is parsed before imported. `grafana_user` and `grafana_password` are optional, and required when -authentication is enabled in Grafana. +authentication is enabled in Grafana. `grafana_api_path` is optional, and only used when using sub-paths for the API. Example: Make sure the `grafana-server` service is up and running before creating the `grafana_dashboard` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module @@ -403,6 +418,7 @@ grafana_datasource { 'influxdb': grafana_url => 'http://localhost:3000', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', + grafana_api_path => '/grafana/api' type => 'influxdb', org_name => 'NewOrg', url => 'http://localhost:8086', @@ -424,8 +440,7 @@ from the browser, or `proxy` to send requests via grafana. Setting `basic_auth` to `true` will allow use of the `basic_auth_user` and `basic_auth_password` params. -Authentication is optional, as is `database`; additional `json_data` can be -provided to allow custom configuration options. +Authentication is optional, as are `database` and `grafana_api_path`; additional `json_data` can be provided to allow custom configuration options. Example: Make sure the `grafana-server` service is up and running before creating the `grafana_datasource` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module @@ -561,6 +576,7 @@ Creates and manages a global grafana user via the API. ```puppet grafana_user { 'username': grafana_url => 'http://localhost:3000', + grafana_api_path => '/grafana/api' grafana_user => 'admin', grafana_password => '5ecretPassw0rd', full_name => 'John Doe', @@ -568,6 +584,7 @@ grafana_user { 'username': email => 'john@example.com', } ``` +`grafana_api_path` is only required if using sub-paths for the API ## Limitations diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index 3ac3a7d44..a6383012f 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -14,7 +14,7 @@ # Return the list of dashboards def dashboards - response = send_request('GET', '/api/search', nil, q: '', starred: false) + response = send_request('GET', format('%s/search', resource[:grafana_api_path]), nil, q: '', starred: false) if response.code != '200' raise format('Fail to retrieve the dashboards (HTTP response: %s/%s)', response.code, response.body) end @@ -30,7 +30,7 @@ def dashboards def find_dashboard return unless dashboards.find { |x| x['title'] == resource[:title] } - response = send_request('GET', format('/api/dashboards/db/%s', slug)) + response = send_request('GET', format('%s/dashboards/db/%s', resource[:grafana_api_path], slug)) if response.code != '200' raise format('Fail to retrieve dashboard %s (HTTP response: %s/%s)', resource[:title], response.code, response.body) end @@ -51,7 +51,7 @@ def save_dashboard(dashboard) overwrite: !@dashboard.nil? } - response = send_request('POST', '/api/dashboards/db', data) + response = send_request('POST', format('%s/dashboards/db', resource[:grafana_api_path]), data) return unless response.code != '200' raise format('Fail to save dashboard %s (HTTP response: %s/%s', resource[:name], response.code, response.body) end @@ -73,7 +73,7 @@ def create end def destroy - response = send_request('DELETE', format('/api/dashboards/db/%s', slug)) + response = send_request('DELETE', format('%s/dashboards/db/%s', resource[:grafana_api_path], slug)) return unless response.code != '200' raise Puppet::Error, format('Failed to delete dashboard %s (HTTP response: %s/%s', resource[:title], response.code, response.body) diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 6acc62bd0..748136579 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -14,7 +14,7 @@ def organization end def fetch_organizations - response = send_request('GET', '/api/orgs') + response = send_request('GET', format('%s/orgs', resource[:grafana_api_path])) if response.code != '200' raise format('Fail to retrieve organizations (HTTP response: %s/%s)', response.code, response.body) end @@ -23,7 +23,7 @@ def fetch_organizations fetch_organizations = JSON.parse(response.body) fetch_organizations.map { |x| x['id'] }.map do |id| - response = send_request 'GET', format('/api/orgs/%s', id) + response = send_request('GET', format('%s/orgs/%s', resource[:grafana_api_path], id)) if response.code != '200' raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -48,7 +48,7 @@ def fetch_organization end def datasources - response = send_request('GET', '/api/datasources') + response = send_request('GET', format('%s/datasources', resource[:grafana_api_path])) if response.code != '200' raise format('Fail to retrieve datasources (HTTP response: %s/%s)', response.code, response.body) end @@ -57,7 +57,7 @@ def datasources datasources = JSON.parse(response.body) datasources.map { |x| x['id'] }.map do |id| - response = send_request 'GET', format('/api/datasources/%s', id) + response = send_request('GET', format('%s/datasources/%s', resource[:grafana_api_path], id)) if response.code != '200' raise format('Failed to retrieve datasource %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -207,13 +207,13 @@ def json_data=(value) def save_datasource if fetch_organization.nil? - response = send_request('POST', '/api/user/using/1') + response = send_request('POST', format('%s/user/using/1', resource[:grafana_api_path])) if response.code != '200' raise format('Failed to switch to org 1 (HTTP response: %s/%s)', response.code, response.body) end else organization_id = fetch_organization[:id] - response = send_request 'POST', format('/api/user/using/%s', organization_id) + response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], organization_id) if response.code != '200' raise format('Failed to switch to org %s (HTTP response: %s/%s)', organization_id, response.code, response.body) end @@ -236,10 +236,10 @@ def save_datasource } if datasource.nil? - response = send_request('POST', '/api/datasources', data) + response = send_request('POST', format('%s/datasources', resource[:grafana_api_path]), data) else data[:id] = datasource[:id] - response = send_request 'PUT', format('/api/datasources/%s', datasource[:id]), data + response = send_request('PUT', format('%s/datasources/%s', resource[:grafana_api_path], datasource[:id]), data) end if response.code != '200' @@ -249,7 +249,7 @@ def save_datasource end def delete_datasource - response = send_request 'DELETE', format('/api/datasources/%s', datasource[:id]) + response = send_request('DELETE', format('%s/datasources/%s', resource[:grafana_api_path], datasource[:id])) if response.code != '200' raise format('Failed to delete datasource %s (HTTP response: %s/%s', resource[:name], response.code, response.body) diff --git a/lib/puppet/provider/grafana_organization/grafana.rb b/lib/puppet/provider/grafana_organization/grafana.rb index 222d6c78b..7d9fc11d6 100644 --- a/lib/puppet/provider/grafana_organization/grafana.rb +++ b/lib/puppet/provider/grafana_organization/grafana.rb @@ -8,7 +8,7 @@ defaultfor kernel: 'Linux' def organizations - response = send_request('GET', '/api/orgs') + response = send_request('GET', format('%s/orgs', resource[:grafana_api_path])) if response.code != '200' raise format('Failed to retrieve organizations (HTTP response: %s/%s)', response.code, response.body) end @@ -17,7 +17,7 @@ def organizations organizations = JSON.parse(response.body) organizations.map { |x| x['id'] }.map do |id| - response = send_request 'GET', format('/api/orgs/%s', id) + response = send_request 'GET', format('%s/orgs/%s', resource[:grafana_api_path], id) if response.code != '200' raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -71,7 +71,7 @@ def save_organization address: resource[:address] } - response = send_request('POST', '/api/orgs', data) if organization.nil? + response = send_request('POST', format('%s/orgs', resource[:grafana_api_path]), data) if organization.nil? if response.code != '200' raise format('Failed to create save %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) @@ -80,7 +80,7 @@ def save_organization end def delete_organization - response = send_request 'DELETE', format('/api/orgs/%s', organization[:id]) + response = send_request('DELETE', format('%s/orgs/%s', resource[:grafana_api_path], organization[:id])) if response.code != '200' raise format('Failed to delete organization %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) diff --git a/lib/puppet/provider/grafana_user/grafana.rb b/lib/puppet/provider/grafana_user/grafana.rb index fc8b79cab..47e418d77 100644 --- a/lib/puppet/provider/grafana_user/grafana.rb +++ b/lib/puppet/provider/grafana_user/grafana.rb @@ -8,7 +8,7 @@ defaultfor kernel: 'Linux' def users - response = send_request('GET', '/api/users') + response = send_request('GET', format('%s/users', resource[:grafana_api_path])) if response.code != '200' raise format('Fail to retrieve users (HTTP response: %s/%s)', response.code, response.body) end @@ -17,7 +17,7 @@ def users users = JSON.parse(response.body) users.map { |x| x['id'] }.map do |id| - response = send_request 'GET', format('/api/users/%s', id) + response = send_request('GET', format('%s/users/%s', resource[:grafana_api_path], id)) if response.code != '200' raise format('Fail to retrieve user %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -112,12 +112,12 @@ def save_user } if user.nil? - response = send_request('POST', '/api/admin/users', data) + response = send_request('POST', format('%s/admin/users', resource[:grafana_api_path]), data) else data[:id] = user[:id] - send_request 'PUT', format('/api/admin/users/%s/password', user[:id]), password: data.delete(:password) - send_request 'PUT', format('/api/admin/users/%s/permissions', user[:id]), isGrafanaAdmin: data.delete(:isGrafanaAdmin) - response = send_request 'PUT', format('/api/users/%s', user[:id]), data + send_request 'PUT', format('%s/admin/users/%s/password', resource[:grafana_api_path], user[:id]), password: data.delete(:password) + send_request 'PUT', format('%s/admin/users/%s/permissions', resource[:grafana_api_path], user[:id]), isGrafanaAdmin: data.delete(:isGrafanaAdmin) + response = send_request('PUT', format('%s/users/%s', resource[:grafana_api_path], user[:id]), data) end if response.code != '200' @@ -127,7 +127,7 @@ def save_user end def delete_user - response = send_request 'DELETE', format('/api/admin/users/%s', user[:id]) + response = send_request('DELETE', format('%s/admin/users/%s', resource[:grafana_api_path], user[:id])) if response.code != '200' raise format('Failed to delete user %s (HTTP response: %s/%s', resource[:name], response.code, response.body) diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index d76d731f5..4f7e77468 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -55,6 +55,17 @@ def should_to_s(value) desc 'The password for the Grafana server (optional)' end + newparam(:grafana_api_path) do + desc 'The absolute path to the API endpoint' + defaultto '/api' + + validate do |value| + unless value =~ %r{^/.*/?api$} + raise ArgumentError, format('%s is not a valid API path', value) + end + end + end + # rubocop:disable Style/SignalException validate do fail('content is required when ensure is present') if self[:ensure] == :present && self[:content].nil? diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 88d2fa487..8e7acf79b 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -9,6 +9,17 @@ desc 'The name of the datasource.' end + newparam(:grafana_api_path) do + desc 'The absolute path to the API endpoint' + defaultto '/api' + + validate do |value| + unless value =~ %r{^/.*/?api$} + raise ArgumentError, format('%s is not a valid API path', value) + end + end + end + newparam(:grafana_url) do desc 'The URL of the Grafana server' defaultto '' diff --git a/lib/puppet/type/grafana_organization.rb b/lib/puppet/type/grafana_organization.rb index caf3c692e..01a521a87 100644 --- a/lib/puppet/type/grafana_organization.rb +++ b/lib/puppet/type/grafana_organization.rb @@ -10,6 +10,17 @@ desc 'The name of the organization.' end + newparam(:grafana_api_path) do + desc 'The absolute path to the API endpoint' + defaultto '/api' + + validate do |value| + unless value =~ %r{^/.*/?api$} + raise ArgumentError, format('%s is not a valid API path', value) + end + end + end + newparam(:grafana_url) do desc 'The URL of the Grafana server' defaultto '' diff --git a/lib/puppet/type/grafana_user.rb b/lib/puppet/type/grafana_user.rb index 6714dac53..1d7569b0d 100644 --- a/lib/puppet/type/grafana_user.rb +++ b/lib/puppet/type/grafana_user.rb @@ -7,6 +7,17 @@ desc 'The username of the user.' end + newparam(:grafana_api_path) do + desc 'The absolute path to the API endpoint' + defaultto '/api' + + validate do |value| + unless value =~ %r{^/.*/?api$} + raise ArgumentError, format('%s is not a valid API path', value) + end + end + end + newparam(:grafana_url) do desc 'The URL of the Grafana server' defaultto '' From f79e9c19fd25a31e9cf01f1edb14de5d2dbb379d Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Wed, 21 Feb 2018 16:17:46 -0500 Subject: [PATCH 099/146] Expand organization property for dashboards --- README.md | 7 +-- .../provider/grafana_dashboard/grafana.rb | 51 +++++++++++++++++++ lib/puppet/type/grafana_dashboard.rb | 5 ++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c0e5cc8dc..41d5f5440 100644 --- a/README.md +++ b/README.md @@ -382,13 +382,14 @@ grafana_dashboard { 'example_dashboard': grafana_user => 'admin', grafana_password => '5ecretPassw0rd', grafana_api_path => '/grafana/api' + organization => 'NewOrg', content => template('path/to/exported/file.json'), } ``` `content` must be valid JSON, and is parsed before imported. `grafana_user` and `grafana_password` are optional, and required when -authentication is enabled in Grafana. `grafana_api_path` is optional, and only used when using sub-paths for the API. +authentication is enabled in Grafana. `grafana_api_path` is optional, and only used when using sub-paths for the API. `organization` is optional, and used when creating a dashboard for a specific organization. Example: Make sure the `grafana-server` service is up and running before creating the `grafana_dashboard` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module @@ -420,7 +421,7 @@ grafana_datasource { 'influxdb': grafana_password => '5ecretPassw0rd', grafana_api_path => '/grafana/api' type => 'influxdb', - org_name => 'NewOrg', + organization => 'NewOrg', url => 'http://localhost:8086', user => 'admin', password => '1nFlux5ecret', @@ -433,7 +434,7 @@ grafana_datasource { 'influxdb': Available types are: influxdb, elasticsearch, graphite, cloudwatch, mysql, opentsdb, and prometheus -`org_name` is used to set which organization a datasource will be created on. If this parameter is not set, it will default to organization ID 1 (Main Org. by default). If the default org is deleted, organizations will need to be specified. +`organization` is used to set which organization a datasource will be created on. If this parameter is not set, it will default to organization ID 1 (Main Org. by default). If the default org is deleted, organizations will need to be specified. Access mode determines how Grafana connects to the datasource, either `direct` from the browser, or `proxy` to send requests via grafana. diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index a6383012f..0d788acd1 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -12,6 +12,44 @@ defaultfor kernel: 'Linux' + def organization + resource[:organization] + end + + def fetch_organizations + response = send_request('GET', format('%s/orgs', resource[:grafana_api_path])) + if response.code != '200' + raise format('Fail to retrieve organizations (HTTP response: %s/%s)', response.code, response.body) + end + + begin + fetch_organizations = JSON.parse(response.body) + + fetch_organizations.map { |x| x['id'] }.map do |id| + response = send_request('GET', format('%s/orgs/%s', resource[:grafana_api_path], id)) + if response.code != '200' + raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) + end + + fetch_organization = JSON.parse(response.body) + + { + id: fetch_organization['id'], + name: fetch_organization['name'] + } + end + rescue JSON::ParserError + raise format('Failed to parse response: %s', response.body) + end + end + + def fetch_organization + unless @fetch_organization + @fetch_organization = fetch_organizations.find { |x| x[:name] == resource[:organization] } + end + @organization + end + # Return the list of dashboards def dashboards response = send_request('GET', format('%s/search', resource[:grafana_api_path]), nil, q: '', starred: false) @@ -44,6 +82,19 @@ def find_dashboard end def save_dashboard(dashboard) + if fetch_organization.nil? + response = send_request('POST', format('%s/user/using/1', resource[:grafana_api_path])) + if response.code != '200' + raise format('Failed to switch to org 1 (HTTP response: %s/%s)', response.code, response.body) + end + else + organization_id = fetch_organization[:id] + response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], organization_id) + if response.code != '200' + raise format('Failed to switch to org %s (HTTP response: %s/%s)', organization_id, response.code, response.body) + end + end + data = { dashboard: dashboard.merge('title' => resource[:title], 'id' => @dashboard ? @dashboard['id'] : nil, diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index 4f7e77468..bdaabd225 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -66,6 +66,11 @@ def should_to_s(value) end end + newproperty(:organization) do + desc 'The organization name to create the datasource on' + defaultto '1' + end + # rubocop:disable Style/SignalException validate do fail('content is required when ensure is present') if self[:ensure] == :present && self[:content].nil? From d236f426d2b5db5064c491a67f72a53221b62780 Mon Sep 17 00:00:00 2001 From: Brandon Riden Date: Mon, 5 Mar 2018 12:16:54 -0500 Subject: [PATCH 100/146] Bug fixes and adding organization option to dashboards --- .../provider/grafana_dashboard/grafana.rb | 32 ++++++++-------- .../provider/grafana_datasource/grafana.rb | 37 +++++++++---------- .../provider/grafana_organization/grafana.rb | 2 +- lib/puppet/type/grafana_dashboard.rb | 4 +- lib/puppet/type/grafana_datasource.rb | 4 +- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/lib/puppet/provider/grafana_dashboard/grafana.rb b/lib/puppet/provider/grafana_dashboard/grafana.rb index 0d788acd1..e5b879bc3 100644 --- a/lib/puppet/provider/grafana_dashboard/grafana.rb +++ b/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -16,6 +16,10 @@ def organization resource[:organization] end + def grafana_api_path + resource[:grafana_api_path] + end + def fetch_organizations response = send_request('GET', format('%s/orgs', resource[:grafana_api_path])) if response.code != '200' @@ -26,7 +30,7 @@ def fetch_organizations fetch_organizations = JSON.parse(response.body) fetch_organizations.map { |x| x['id'] }.map do |id| - response = send_request('GET', format('%s/orgs/%s', resource[:grafana_api_path], id)) + response = send_request 'GET', format('%s/orgs/%s', resource[:grafana_api_path], id) if response.code != '200' raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -45,9 +49,14 @@ def fetch_organizations def fetch_organization unless @fetch_organization - @fetch_organization = fetch_organizations.find { |x| x[:name] == resource[:organization] } + @fetch_organization = + if resource[:organization].is_a?(Numeric) || resource[:organization].match(%r{^[0-9]*$}) + fetch_organizations.find { |x| x[:id] == resource[:organization] } + else + fetch_organizations.find { |x| x[:name] == resource[:organization] } + end end - @organization + @fetch_organization end # Return the list of dashboards @@ -82,17 +91,10 @@ def find_dashboard end def save_dashboard(dashboard) - if fetch_organization.nil? - response = send_request('POST', format('%s/user/using/1', resource[:grafana_api_path])) - if response.code != '200' - raise format('Failed to switch to org 1 (HTTP response: %s/%s)', response.code, response.body) - end - else - organization_id = fetch_organization[:id] - response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], organization_id) - if response.code != '200' - raise format('Failed to switch to org %s (HTTP response: %s/%s)', organization_id, response.code, response.body) - end + # change organizations + response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], fetch_organization[:id]) + unless response.code == '200' + raise format('Failed to switch to org %s (HTTP response: %s/%s)', fetch_organization[:id], response.code, response.body) end data = { @@ -103,7 +105,7 @@ def save_dashboard(dashboard) } response = send_request('POST', format('%s/dashboards/db', resource[:grafana_api_path]), data) - return unless response.code != '200' + return unless (response.code != '200') && (response.code != '412') raise format('Fail to save dashboard %s (HTTP response: %s/%s', resource[:name], response.code, response.body) end diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 748136579..38cf421d3 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -13,6 +13,10 @@ def organization resource[:organization] end + def grafana_api_path + resource[:grafana_api_path] + end + def fetch_organizations response = send_request('GET', format('%s/orgs', resource[:grafana_api_path])) if response.code != '200' @@ -21,9 +25,8 @@ def fetch_organizations begin fetch_organizations = JSON.parse(response.body) - fetch_organizations.map { |x| x['id'] }.map do |id| - response = send_request('GET', format('%s/orgs/%s', resource[:grafana_api_path], id)) + response = send_request 'GET', format('%s/orgs/%s', resource[:grafana_api_path], id) if response.code != '200' raise format('Failed to retrieve organization %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -42,9 +45,13 @@ def fetch_organizations def fetch_organization unless @fetch_organization - @fetch_organization = fetch_organizations.find { |x| x[:name] == resource[:organization] } + @fetch_organization = if resource[:organization].is_a?(Numeric) || resource[:organization].match(%r{^[0-9]*$}) + fetch_organizations.find { |x| x[:id] == resource[:organization] } + else + fetch_organizations.find { |x| x[:name] == resource[:organization] } + end end - @organization + @fetch_organization end def datasources @@ -57,7 +64,7 @@ def datasources datasources = JSON.parse(response.body) datasources.map { |x| x['id'] }.map do |id| - response = send_request('GET', format('%s/datasources/%s', resource[:grafana_api_path], id)) + response = send_request 'GET', format('%s/datasources/%s', resource[:grafana_api_path], id) if response.code != '200' raise format('Failed to retrieve datasource %d (HTTP response: %s/%s)', id, response.code, response.body) end @@ -206,17 +213,10 @@ def json_data=(value) end def save_datasource - if fetch_organization.nil? - response = send_request('POST', format('%s/user/using/1', resource[:grafana_api_path])) - if response.code != '200' - raise format('Failed to switch to org 1 (HTTP response: %s/%s)', response.code, response.body) - end - else - organization_id = fetch_organization[:id] - response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], organization_id) - if response.code != '200' - raise format('Failed to switch to org %s (HTTP response: %s/%s)', organization_id, response.code, response.body) - end + # change organizations + response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], fetch_organization[:id]) + unless response.code == '200' + raise format('Failed to switch to org %s (HTTP response: %s/%s)', fetch_organization[:id], response.code, response.body) end data = { @@ -239,9 +239,8 @@ def save_datasource response = send_request('POST', format('%s/datasources', resource[:grafana_api_path]), data) else data[:id] = datasource[:id] - response = send_request('PUT', format('%s/datasources/%s', resource[:grafana_api_path], datasource[:id]), data) + response = send_request 'PUT', format('%s/datasources/%s', resource[:grafana_api_path], datasource[:id]), data end - if response.code != '200' raise format('Failed to create save %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) end @@ -249,7 +248,7 @@ def save_datasource end def delete_datasource - response = send_request('DELETE', format('%s/datasources/%s', resource[:grafana_api_path], datasource[:id])) + response = send_request 'DELETE', format('%s/datasources/%s', resource[:grafana_api_path], datasource[:id]) if response.code != '200' raise format('Failed to delete datasource %s (HTTP response: %s/%s', resource[:name], response.code, response.body) diff --git a/lib/puppet/provider/grafana_organization/grafana.rb b/lib/puppet/provider/grafana_organization/grafana.rb index 7d9fc11d6..c0fe8e926 100644 --- a/lib/puppet/provider/grafana_organization/grafana.rb +++ b/lib/puppet/provider/grafana_organization/grafana.rb @@ -80,7 +80,7 @@ def save_organization end def delete_organization - response = send_request('DELETE', format('%s/orgs/%s', resource[:grafana_api_path], organization[:id])) + response = send_request 'DELETE', format('%s/orgs/%s', resource[:grafana_api_path], organization[:id]) if response.code != '200' raise format('Failed to delete organization %s (HTTP response: %s/%s)', resource[:name], response.code, response.body) diff --git a/lib/puppet/type/grafana_dashboard.rb b/lib/puppet/type/grafana_dashboard.rb index bdaabd225..a0a6cb3bc 100644 --- a/lib/puppet/type/grafana_dashboard.rb +++ b/lib/puppet/type/grafana_dashboard.rb @@ -66,9 +66,9 @@ def should_to_s(value) end end - newproperty(:organization) do + newparam(:organization) do desc 'The organization name to create the datasource on' - defaultto '1' + defaultto 1 end # rubocop:disable Style/SignalException diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 8e7acf79b..a360f803b 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -54,9 +54,9 @@ newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus) end - newproperty(:organization) do + newparam(:organization) do desc 'The organization name to create the datasource on' - defaultto '1' + defaultto 1 end newproperty(:user) do From 66c1a4d364c6c26eee24043fe15c670728e6cdc2 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 6 Mar 2018 12:24:02 +0100 Subject: [PATCH 101/146] release 4.2.0 --- CHANGELOG.md | 16 +++++++++++++++- metadata.json | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe43be3ad..f63a14223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.2.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.2.0) (2018-03-06) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.1.1...v4.2.0) + +**Implemented enhancements:** + +- Create organization [\#71](https://github.com/voxpupuli/puppet-grafana/issues/71) +- Expand organization property for dashboards [\#94](https://github.com/voxpupuli/puppet-grafana/pull/94) ([brandonrdn](https://github.com/brandonrdn)) +- Add grafana\_api\_path to allow for API sub-paths [\#93](https://github.com/voxpupuli/puppet-grafana/pull/93) ([brandonrdn](https://github.com/brandonrdn)) + ## [v4.1.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.1) (2018-02-21) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.1.0...v4.1.1) @@ -15,6 +25,7 @@ These should not affect the functionality of the module. **Merged pull requests:** +- release 4.1.1 [\#92](https://github.com/voxpupuli/puppet-grafana/pull/92) ([bastelfreak](https://github.com/bastelfreak)) - release 4.1.0 [\#88](https://github.com/voxpupuli/puppet-grafana/pull/88) ([bastelfreak](https://github.com/bastelfreak)) ## [v4.1.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.0) (2018-02-03) @@ -114,9 +125,12 @@ These should not affect the functionality of the module. [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.3...v3.0.0) -**Fixed bugs:** +**Implemented enhancements:** - implement package\_ensure param for archlinux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak)) + +**Fixed bugs:** + - FIX configuration file ownership [\#30](https://github.com/voxpupuli/puppet-grafana/pull/30) ([cassianoleal](https://github.com/cassianoleal)) **Closed issues:** diff --git a/metadata.json b/metadata.json index f7adbf03c..eac462990 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.1.2-rc0", + "version": "4.2.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From e2fa0e5464111ed5c86bb60421a9c8cd9c6b801d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 6 Mar 2018 12:31:20 +0100 Subject: [PATCH 102/146] [blacksmith] Bump version to 4.2.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index eac462990..33b48d0ee 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.2.0", + "version": "4.2.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From f7efd245c88d7781ed44a29b04ff02d992c9f586 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Mar 2018 22:23:46 -0500 Subject: [PATCH 103/146] Update README.md Fixed typos on all lines that defined grafana_api_path --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 41d5f5440..00afb3e74 100644 --- a/README.md +++ b/README.md @@ -381,7 +381,7 @@ grafana_dashboard { 'example_dashboard': grafana_url => 'http://localhost:3000', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', - grafana_api_path => '/grafana/api' + grafana_api_path => '/grafana/api', organization => 'NewOrg', content => template('path/to/exported/file.json'), } @@ -419,7 +419,7 @@ grafana_datasource { 'influxdb': grafana_url => 'http://localhost:3000', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', - grafana_api_path => '/grafana/api' + grafana_api_path => '/grafana/api', type => 'influxdb', organization => 'NewOrg', url => 'http://localhost:8086', @@ -577,7 +577,7 @@ Creates and manages a global grafana user via the API. ```puppet grafana_user { 'username': grafana_url => 'http://localhost:3000', - grafana_api_path => '/grafana/api' + grafana_api_path => '/grafana/api', grafana_user => 'admin', grafana_password => '5ecretPassw0rd', full_name => 'John Doe', From 3114e76944c27d2ad068c150d6396efc07d95bd6 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 17 Mar 2018 10:27:39 +0100 Subject: [PATCH 104/146] switch from topscope facts to $facts hash --- manifests/install.pp | 6 +++--- manifests/params.pp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 46e16a4ee..23e9a46ea 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -28,7 +28,7 @@ } } 'package': { - case $::osfamily { + case $facts['os']['family'] { 'Debian': { package { 'libfontconfig1': ensure => present, @@ -58,12 +58,12 @@ } } default: { - fail("${::operatingsystem} not supported") + fail("${facts['os']['family']} not supported") } } } 'repo': { - case $::osfamily { + case $facts['os']['family'] { 'Debian': { package { 'libfontconfig1': ensure => present, diff --git a/manifests/params.pp b/manifests/params.pp index 54ef4a05b..062054afc 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -15,7 +15,7 @@ $rpm_iteration = '1' $repo_name = 'stable' $version = '4.5.1' - case $::osfamily { + case $facts['os']['family'] { 'Archlinux': { $manage_package_repo = false $install_method = 'repo' From a208a1c795e7e98aabec3c53caf3114712cc53dd Mon Sep 17 00:00:00 2001 From: TraGicCode <6224270+TraGicCode@users.noreply.github.com> Date: Fri, 23 Mar 2018 20:32:05 -0500 Subject: [PATCH 105/146] modulesync 1.9.0 --- .github/PULL_REQUEST_TEMPLATE.md | 12 ++++++++++++ .msync.yml | 2 +- spec/acceptance/nodesets/docker/ubuntu-16.04.yml | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 66f80444c..ef25cdbf4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,3 +6,15 @@ Thank you for contributing to this project! - Our vulnerabilities reporting process is at https://voxpupuli.org/security/ --> +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + diff --git a/.msync.yml b/.msync.yml index 4df90fba4..b49c4c69f 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.8.0' +modulesync_config_version: '1.9.0' diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml index 2d173c5b9..cd6f3762b 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml @@ -10,8 +10,10 @@ HOSTS: docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: + - 'systemctl mask getty@tty1.service getty-static.service' - 'apt-get install -y net-tools wget locales apt-transport-https' - 'locale-gen en_US.UTF-8' + - 'echo LANG=en_US.UTF-8 > /etc/default/locale' CONFIG: trace_limit: 200 masterless: true From fb6d15e0550bf2d669cfe7e461b73fa4ffe7e9aa Mon Sep 17 00:00:00 2001 From: David Leib Date: Mon, 26 Mar 2018 11:29:52 +0200 Subject: [PATCH 106/146] Adding Postgres support --- lib/puppet/type/grafana_datasource.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index a360f803b..81e7e1181 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -51,7 +51,7 @@ newproperty(:type) do desc 'The datasource type' - newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus) + newvalues(:influxdb, :elasticsearch, :graphite, :kairosdb, :opentsdb, :prometheus, :postgres) end newparam(:organization) do From 38882fe3e0f580f7b3e380a13692f61c5823560e Mon Sep 17 00:00:00 2001 From: David Leib Date: Mon, 26 Mar 2018 11:38:20 +0200 Subject: [PATCH 107/146] Adding secure_json_data field to the grafana_datasource declaration --- README.md | 49 ++++++++++--------- .../provider/grafana_datasource/grafana.rb | 15 +++++- lib/puppet/type/grafana_datasource.rb | 10 ++++ .../type/grafana_datasource_type_spec.rb | 10 +++- 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 00afb3e74..be198db32 100644 --- a/README.md +++ b/README.md @@ -366,12 +366,12 @@ grafana_organization { 'example_org': } ``` -`grafana_url`, `grafana_user`, and `grafana_password` are required to create organizations via the API. +`grafana_url`, `grafana_user`, and `grafana_password` are required to create organizations via the API. `name` is optional if the name will differ from example_org above. `address` is an optional parameter that requires a hash. Address settings are `{"address1":"","address2":"","city":"","zipCode":"","state":"","country":""}` - + #### `grafana_dashboard` In order to use the dashboard resource, add the following to your manifest: @@ -416,32 +416,33 @@ In order to use the datasource resource, add the following to your manifest: ```puppet grafana_datasource { 'influxdb': - grafana_url => 'http://localhost:3000', - grafana_user => 'admin', - grafana_password => '5ecretPassw0rd', - grafana_api_path => '/grafana/api', - type => 'influxdb', - organization => 'NewOrg', - url => 'http://localhost:8086', - user => 'admin', - password => '1nFlux5ecret', - database => 'graphite', - access_mode => 'proxy', - is_default => true, - json_data => template('path/to/additional/config.json'), + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => '5ecretPassw0rd', + grafana_api_path => '/grafana/api', + type => 'influxdb', + organization => 'NewOrg', + url => 'http://localhost:8086', + user => 'admin', + password => '1nFlux5ecret', + database => 'graphite', + access_mode => 'proxy', + is_default => true, + json_data => template('path/to/additional/config.json'), + secure_json_data => template('path/to/additional/secure/config.json') } ``` -Available types are: influxdb, elasticsearch, graphite, cloudwatch, mysql, opentsdb, and prometheus +Available types are: influxdb, elasticsearch, graphite, cloudwatch, mysql, opentsdb, postgres and prometheus -`organization` is used to set which organization a datasource will be created on. If this parameter is not set, it will default to organization ID 1 (Main Org. by default). If the default org is deleted, organizations will need to be specified. +`organization` is used to set which organization a datasource will be created on. If this parameter is not set, it will default to organization ID 1 (Main Org. by default). If the default org is deleted, organizations will need to be specified. Access mode determines how Grafana connects to the datasource, either `direct` from the browser, or `proxy` to send requests via grafana. Setting `basic_auth` to `true` will allow use of the `basic_auth_user` and `basic_auth_password` params. -Authentication is optional, as are `database` and `grafana_api_path`; additional `json_data` can be provided to allow custom configuration options. +Authentication is optional, as are `database` and `grafana_api_path`; additional `json_data` and `secure_json_data` can be provided to allow custom configuration options. Example: Make sure the `grafana-server` service is up and running before creating the `grafana_datasource` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module @@ -473,7 +474,7 @@ Note that the `database` is dynamic, setting things other than "database" for se **`jsonData` Settings** -Note that there are separate options for json_data based on the type of datasource you create. +Note that there are separate options for json_data / secure_json_data based on the type of datasource you create. ##### **Elasticsearch** @@ -491,16 +492,16 @@ json_data => {"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"} ##### **CloudWatch** `authType` - Required. Options are `Access & Secret Key`, `Credentials File`, or `ARN`. - + -"keys" = Access & Secret Key -"credentials" = Credentials File -"arn" = ARN - + *When setting authType to `credentials`, the `database` param will set the Credentials Profile Name.* -*When setting authType to `arn`, another jsonData value of `assumeRoleARN` is available, which is not required for other authType settings* +*When setting authType to `arn`, another jsonData value of `assumeRoleARN` is available, which is not required for other authType settings* `customMetricsNamespaces` - Optional. Namespaces of Custom Metrics, separated by commas within double quotes. @@ -508,11 +509,11 @@ json_data => {"esVersion":5,"timeField":"@timestamp","timeInterval":"1m"} `timeField` -Example: +Example: ```puppet {"authType":"arn","assumeRoleARN":"arn:aws:iam:*","customMetricsNamespaces":"Namespace1,Namespace2","defaultRegion":"us-east-1","timeField":"@timestamp"} ``` - + ##### **Graphite** `graphiteVersion` - Required. Available versions are `0.9` or `1.0`. diff --git a/lib/puppet/provider/grafana_datasource/grafana.rb b/lib/puppet/provider/grafana_datasource/grafana.rb index 38cf421d3..6688b30d2 100644 --- a/lib/puppet/provider/grafana_datasource/grafana.rb +++ b/lib/puppet/provider/grafana_datasource/grafana.rb @@ -85,7 +85,8 @@ def datasources basic_auth: datasource['basicAuth'] ? :true : :false, basic_auth_user: datasource['basicAuthUser'], basic_auth_password: datasource['basicAuthPassword'], - json_data: datasource['jsonData'] + json_data: datasource['jsonData'], + secure_json_data: datasource['secureJsonData'] } end rescue JSON::ParserError @@ -212,6 +213,15 @@ def json_data=(value) save_datasource end + def secure_json_data + datasource[:secure_json_data] + end + + def secure_json_data=(value) + resource[:secure_json_data] = value + save_datasource + end + def save_datasource # change organizations response = send_request 'POST', format('%s/user/using/%s', resource[:grafana_api_path], fetch_organization[:id]) @@ -232,7 +242,8 @@ def save_datasource basicAuthUser: resource[:basic_auth_user], basicAuthPassword: resource[:basic_auth_password], withCredentials: (resource[:with_credentials] == :true), - jsonData: resource[:json_data] + jsonData: resource[:json_data], + secureJsonData: resource[:secure_json_data] } if datasource.nil? diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 81e7e1181..0b9855636 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -115,6 +115,16 @@ end end + newproperty(:secure_json_data) do + desc 'Additional secure JSON data to configure the datasource (optional)' + + validate do |value| + unless value.nil? || value.is_a?(Hash) + raise ArgumentError, 'secure_json_data should be a Hash!' + end + end + end + autorequire(:service) do 'grafana-server' end diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index fc302963d..89f817236 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -30,7 +30,8 @@ database: 'test_db', user: 'db_user', password: 'db_password', - json_data: { esVersion: 5, timeField: '@timestamp', timeInterval: '1m' } + json_data: { esVersion: 5, timeField: '@timestamp', timeInterval: '1m' }, + secure_json_data: { password: '5ecretPassw0rd' } ) end @@ -52,6 +53,12 @@ described_class.new name: 'foo', grafana_url: 'http://example.com', json_data: 'invalid', ensure: :present end.to raise_error(Puppet::Error, %r{json_data should be a Hash}) end + + it "fails if secure_json_data isn't valid" do + expect do + described_class.new name: 'foo', grafana_url: 'http://example.com', secure_json_data: 'invalid', ensure: :present + end.to raise_error(Puppet::Error, %r{json_data should be a Hash}) + end # rubocop:disable RSpec/MultipleExpectations it 'accepts valid parameters' do expect(gdatasource[:name]).to eq('foo') @@ -69,6 +76,7 @@ expect(gdatasource[:user]).to eq('db_user') expect(gdatasource[:password]).to eq('db_password') expect(gdatasource[:json_data]).to eq(esVersion: 5, timeField: '@timestamp', timeInterval: '1m') + expect(gdatasource[:secure_json_data]).to eq(password: '5ecretPassw0rd') end # rubocop:enable RSpec/MultipleExpectations From a984c1dc5e78093d5aa4bf9acbe075ebab81bc08 Mon Sep 17 00:00:00 2001 From: David Leib Date: Mon, 26 Mar 2018 12:43:49 +0200 Subject: [PATCH 108/146] Removing this check again as it breaks postgres datasource definition Removed this explicitly in commit d7e19910cfad56fd87c9c5047c621646f5105bf9 but the check was readded... --- lib/puppet/type/grafana_datasource.rb | 8 +------- spec/unit/puppet/type/grafana_datasource_type_spec.rb | 6 ------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/puppet/type/grafana_datasource.rb b/lib/puppet/type/grafana_datasource.rb index 0b9855636..0694f3f58 100644 --- a/lib/puppet/type/grafana_datasource.rb +++ b/lib/puppet/type/grafana_datasource.rb @@ -40,13 +40,7 @@ end newproperty(:url) do - desc 'The URL of the datasource' - - validate do |value| - unless value =~ %r{^https?://} - raise ArgumentError, format('%s is not a valid URL', value) - end - end + desc 'The URL/Endpoint of the datasource' end newproperty(:type) do diff --git a/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/spec/unit/puppet/type/grafana_datasource_type_spec.rb index 89f817236..55b224b3f 100644 --- a/spec/unit/puppet/type/grafana_datasource_type_spec.rb +++ b/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -42,12 +42,6 @@ end.to raise_error(Puppet::Error, %r{not a valid URL}) end - it "fails if url isn't HTTP-based" do - expect do - described_class.new name: 'foo', url: 'example.com', content: '{}', ensure: :present - end.to raise_error(Puppet::Error, %r{not a valid URL}) - end - it "fails if json_data isn't valid" do expect do described_class.new name: 'foo', grafana_url: 'http://example.com', json_data: 'invalid', ensure: :present From d0f6d96f5caee38825dadc6ad5fbbf25d0787b11 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 11 Apr 2018 12:35:07 +0200 Subject: [PATCH 109/146] modulesync 1.9.0-12-gacb0134 --- .github/CONTRIBUTING.md | 19 +++++++++++++++++-- .msync.yml | 2 +- Gemfile | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7a0980a9e..496a5c034 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -40,9 +40,24 @@ you must set an environment variable such as: export PUPPET_VERSION="~> 4.2.0" -Install the dependencies like so... +You can install all needed gems for spec tests into the modules directory by +running: - bundle install +```sh +bundle install --path .vendor/ --without development --without system_tests --without release +``` + +If you also want to run acceptance tests: + +```sh +bundle install --path .vendor/ --without development --with system_tests --without release +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle install --path .vendor/ --without development --with system_tests --without release; bundle update; bundle clean +``` ## Syntax and style diff --git a/.msync.yml b/.msync.yml index b49c4c69f..964ecbaaa 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.0' +modulesync_config_version: '1.9.1' diff --git a/Gemfile b/Gemfile index 32e6600eb..91457201f 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ group :test do gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0' gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' - gem 'mocha', '>= 1.2.1', :require => false + gem 'mocha', '~> 1.4.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' From 9405e2ac11caab745163a26850e0f2089150757b Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Sun, 13 May 2018 13:24:04 +0200 Subject: [PATCH 110/146] Rely on beaker-hostgenerator for docker nodesets --- .msync.yml | 2 +- .sync.yml | 4 ++-- .travis.yml | 23 +++++++++++-------- Gemfile | 9 ++++---- spec/acceptance/nodesets/docker/centos-5.yml | 19 --------------- spec/acceptance/nodesets/docker/centos-6.yml | 20 ---------------- spec/acceptance/nodesets/docker/centos-7.yml | 19 --------------- spec/acceptance/nodesets/docker/debian-7.yml | 18 --------------- spec/acceptance/nodesets/docker/debian-8.yml | 20 ---------------- spec/acceptance/nodesets/docker/debian-9.yml | 20 ---------------- .../nodesets/docker/ubuntu-12.04.yml | 19 --------------- .../nodesets/docker/ubuntu-14.04.yml | 21 ----------------- .../nodesets/docker/ubuntu-16.04.yml | 21 ----------------- spec/spec_helper.rb | 4 ++++ 14 files changed, 25 insertions(+), 194 deletions(-) delete mode 100644 spec/acceptance/nodesets/docker/centos-5.yml delete mode 100644 spec/acceptance/nodesets/docker/centos-6.yml delete mode 100644 spec/acceptance/nodesets/docker/centos-7.yml delete mode 100644 spec/acceptance/nodesets/docker/debian-7.yml delete mode 100644 spec/acceptance/nodesets/docker/debian-8.yml delete mode 100644 spec/acceptance/nodesets/docker/debian-9.yml delete mode 100644 spec/acceptance/nodesets/docker/ubuntu-12.04.yml delete mode 100644 spec/acceptance/nodesets/docker/ubuntu-14.04.yml delete mode 100644 spec/acceptance/nodesets/docker/ubuntu-16.04.yml diff --git a/.msync.yml b/.msync.yml index 964ecbaaa..1a132115d 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.1' +modulesync_config_version: '1.9.2' diff --git a/.sync.yml b/.sync.yml index c34f3cf00..4352e5c3b 100644 --- a/.sync.yml +++ b/.sync.yml @@ -2,8 +2,8 @@ .travis.yml: secure: "C+dXd27/doW1JnKqv+UDHL6/HBI5Te+xGsaoPkqhpO4iXfMxJrTi6sBWaEuyNTeHIwN8wOWHaW9qKEqTuYZ0/k+k3SWFmZpi3jSh79Y8WDoYK7+DsbKQ6xZy54Sh56YIYXfkaLQYYYrqKKksZ57h/NYU/hzu9h8oH+PnXfGT6i/KH9C4z8IR9qTxIiErrJHUMni9CryTTbtGV9pIj0QTZP+OQLoE660J8/uMsfTQDK9/NqQ2nsTaQ12SS9xg6MmmOX7W4NhRrOyIi0sd7eR0dRIoVf0TwfYhw8Yi4aDuTZIHNtcHiyfAVsvh3RpAr5d01GjXEr5lj0XyBOu8t1U3BzPU7LrJRrwE+ZmP72L39vrT7rmDRz9pDU7fVIOiRtqRLEJRDIW4I2ISkwBdzFKX8UTozTkPEmt9Iy+uKX5n2y8re2KFaseXWxTeVJbHh+DsJQ/hWsUNrHcl2dKmtgo7xHSonmevnATVV1vUbwvswm1oEiAFRdhF4gNdC8I6OGlVzmzwMbwqiGUk/nRBQeMEbyeRQV54QV3zteuBiHc8neQPR+QiD7diR2d4JhmDbr6xop+Bat2SVQqLg2IdAJ/Qu1Aor7mxhmPqiz35SWkbaaoDJYbWrCBeQ+jos4s2jCDY7OJEXW8ng9gPO71W/lcybMWzihUw6fA9w/riHe37Ez0=" docker_sets: - - set: docker/ubuntu-16.04 - - set: docker/centos-7 + - set: ubuntu1604-64 + - set: centos7-64 Gemfile: optional: ':test': diff --git a/.travis.yml b/.travis.yml index 43f560aae..15b4f8780 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,11 @@ sudo: false dist: trusty language: ruby cache: bundler +# related to https://github.com/rubygems/rubygems/issues/2123 before_install: - - rm -f Gemfile.lock + - 'rm -f Gemfile.lock' + - 'gem update --system' + - 'gem install bundler' script: - 'bundle exec rake $CHECK' matrix: @@ -13,28 +16,28 @@ matrix: - rvm: 2.1.9 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12 - - rvm: 2.4.3 + - rvm: 2.4.4 bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls - - rvm: 2.5.0 + env: PUPPET_VERSION="~> 5.0" CHECK=test + - rvm: 2.5.1 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls - - rvm: 2.4.3 + - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=rubocop - - rvm: 2.4.3 + - rvm: 2.5.1 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - - rvm: 2.4.3 + - rvm: 2.5.1 bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker services: docker sudo: required - - rvm: 2.4.3 + - rvm: 2.5.1 bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker services: docker sudo: required branches: diff --git a/Gemfile b/Gemfile index 91457201f..90a43fdc8 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ group :development do end group :system_tests do - gem 'winrm', :require => false + gem 'winrm', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) else @@ -52,9 +52,10 @@ group :system_tests do else gem 'beaker-rspec', :require => false end - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'beaker-module_install_helper', :require => false + gem 'serverspec', :require => false + gem 'beaker-hostgenerator', '>= 1.1.10', :require => false + gem 'beaker-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false end group :release do diff --git a/spec/acceptance/nodesets/docker/centos-5.yml b/spec/acceptance/nodesets/docker/centos-5.yml deleted file mode 100644 index c17bc3d00..000000000 --- a/spec/acceptance/nodesets/docker/centos-5.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - centos-5-x64: - platform: el-5-x86_64 - hypervisor: docker - image: centos:5 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' - - 'sed -i -e "/mingetty/d" /etc/inittab' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-6.yml b/spec/acceptance/nodesets/docker/centos-6.yml deleted file mode 100644 index d93f884cb..000000000 --- a/spec/acceptance/nodesets/docker/centos-6.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - centos-6-x64: - platform: el-6-x86_64 - hypervisor: docker - image: centos:6 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'rm -rf /var/run/network/*' - - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' - - 'rm /etc/init/tty.conf' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml deleted file mode 100644 index 41e924b50..000000000 --- a/spec/acceptance/nodesets/docker/centos-7.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor: docker - image: centos:7 - docker_preserve_image: true - docker_cmd: '["/usr/sbin/init"]' - docker_image_commands: - - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which ss' - - 'systemctl mask getty@tty1.service' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-7.yml b/spec/acceptance/nodesets/docker/debian-7.yml deleted file mode 100644 index 41b284d39..000000000 --- a/spec/acceptance/nodesets/docker/debian-7.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - debian-7-x64: - platform: debian-7-amd64 - hypervisor: docker - image: debian:7 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y cron locales-all net-tools wget' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml deleted file mode 100644 index a630b7efd..000000000 --- a/spec/acceptance/nodesets/docker/debian-8.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor: docker - image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y cron locales-all net-tools wget' - - 'rm -f /usr/sbin/policy-rc.d' - - 'systemctl mask getty@tty1.service getty-static.service' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-9.yml b/spec/acceptance/nodesets/docker/debian-9.yml deleted file mode 100644 index dfc8e9c09..000000000 --- a/spec/acceptance/nodesets/docker/debian-9.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/theforeman/foreman-installer-modulesync -HOSTS: - debian-9-x64: - platform: debian-9-amd64 - hypervisor: docker - image: debian:9 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y cron locales-all net-tools wget systemd-sysv' - - 'rm -f /usr/sbin/policy-rc.d' - - 'systemctl mask getty@tty1.service getty-static.service' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-12.04.yml b/spec/acceptance/nodesets/docker/ubuntu-12.04.yml deleted file mode 100644 index ab77cda48..000000000 --- a/spec/acceptance/nodesets/docker/ubuntu-12.04.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - ubuntu-1204-x64: - platform: ubuntu-12.04-amd64 - hypervisor: docker - image: ubuntu:12.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml deleted file mode 100644 index ae4530444..000000000 --- a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor: docker - image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'rm /usr/sbin/policy-rc.d' - - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' - - 'apt-get install -y net-tools wget apt-transport-https' - - 'locale-gen en_US.UTF-8' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml deleted file mode 100644 index cd6f3762b..000000000 --- a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config -HOSTS: - ubuntu-1604-x64: - platform: ubuntu-16.04-amd64 - hypervisor: docker - image: ubuntu:16.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'systemctl mask getty@tty1.service getty-static.service' - - 'apt-get install -y net-tools wget locales apt-transport-https' - - 'locale-gen en_US.UTF-8' - - 'echo LANG=en_US.UTF-8 > /etc/default/locale' -CONFIG: - trace_limit: 200 - masterless: true -... -# vim: syntax=yaml diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cdd493591..ea74a52a3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,6 +2,10 @@ require 'rspec-puppet-facts' include RspecPuppetFacts +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config + if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'coveralls' require 'simplecov' From 6a5b5bce2c3a0991de6734e4c368af93b5a77aff Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 20 May 2018 14:59:44 +0200 Subject: [PATCH 111/146] drop EOL OSs; fix puppet version range --- metadata.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index 33b48d0ee..ab977ce44 100644 --- a/metadata.json +++ b/metadata.json @@ -21,7 +21,6 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "7", "8", "9" ] @@ -54,7 +53,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.7.1 < 6.0.0" + "version_requirement": ">= 4.10.0 < 6.0.0" } ], "tags": [ From 082e3d6e0e74868f17d81cfaeb419a31370bdbed Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Mon, 18 Jun 2018 14:47:14 -0500 Subject: [PATCH 112/146] Updated release codename from jessie to stretch. Grafana upstream documetation: http://docs.grafana.org/installation/debian/, says to use 'stretch' codename for all repositories. --- manifests/install.pp | 2 +- spec/classes/grafana_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 23e9a46ea..3ebbd2ded 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -75,7 +75,7 @@ } apt::source { 'grafana': location => "https://packagecloud.io/grafana/${::grafana::repo_name}/debian", - release => 'jessie', + release => 'stretch', repos => 'main', key => { 'id' => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB', diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index b6fb7c29a..780817210 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -99,7 +99,7 @@ when 'Debian' describe 'install apt repo dependencies first' do it { is_expected.to contain_class('apt') } - it { is_expected.to contain_apt__source('grafana').with(release: 'jessie', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } + it { is_expected.to contain_apt__source('grafana').with(release: 'stretch', repos: 'main', location: 'https://packagecloud.io/grafana/stable/debian') } it { is_expected.to contain_apt__source('grafana').that_comes_before('Package[grafana]') } end From aaff1ed96ea69914403afc073fc09b616d4bdf91 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 18 Jun 2018 22:33:20 +0200 Subject: [PATCH 113/146] release 4.3.0 --- CHANGELOG.md | 47 ++++++++++++++++++++++++++++++----------------- metadata.json | 2 +- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f63a14223..5743ce353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.3.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.3.0) (2018-06-18) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.2.0...v4.3.0) + +**Implemented enhancements:** + +- Add postgres support and secure\_json\_data support [\#105](https://github.com/voxpupuli/puppet-grafana/pull/105) ([Faffnir](https://github.com/Faffnir)) + +**Fixed bugs:** + +- Update release codename from jessie to stretch. [\#113](https://github.com/voxpupuli/puppet-grafana/pull/113) ([drshawnkwang](https://github.com/drshawnkwang)) + +**Closed issues:** + +- puppet-grafana Debian repository should use codename stretch [\#112](https://github.com/voxpupuli/puppet-grafana/issues/112) + +**Merged pull requests:** + +- drop EOL OSs; fix puppet version range [\#109](https://github.com/voxpupuli/puppet-grafana/pull/109) ([bastelfreak](https://github.com/bastelfreak)) +- Rely on beaker-hostgenerator for docker nodesets [\#108](https://github.com/voxpupuli/puppet-grafana/pull/108) ([ekohl](https://github.com/ekohl)) +- switch from topscope facts to $facts hash [\#102](https://github.com/voxpupuli/puppet-grafana/pull/102) ([bastelfreak](https://github.com/bastelfreak)) +- Update README.md [\#99](https://github.com/voxpupuli/puppet-grafana/pull/99) ([cclloyd](https://github.com/cclloyd)) + ## [v4.2.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.2.0) (2018-03-06) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.1.1...v4.2.0) @@ -23,11 +46,6 @@ These should not affect the functionality of the module. - grafana\_datasource provider with\_credentials\(\) returns is\_default value [\#89](https://github.com/voxpupuli/puppet-grafana/issues/89) - fix datasource provider error [\#90](https://github.com/voxpupuli/puppet-grafana/pull/90) ([brandonrdn](https://github.com/brandonrdn)) -**Merged pull requests:** - -- release 4.1.1 [\#92](https://github.com/voxpupuli/puppet-grafana/pull/92) ([bastelfreak](https://github.com/bastelfreak)) -- release 4.1.0 [\#88](https://github.com/voxpupuli/puppet-grafana/pull/88) ([bastelfreak](https://github.com/bastelfreak)) - ## [v4.1.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.0) (2018-02-03) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.3...v4.1.0) @@ -40,10 +58,6 @@ These should not affect the functionality of the module. - "Could not autoload" error in grafana\_dashboard with ruby 2.4 on Centos 6 [\#83](https://github.com/voxpupuli/puppet-grafana/issues/83) -**Merged pull requests:** - -- release 4.0.3 [\#81](https://github.com/voxpupuli/puppet-grafana/pull/81) ([bastelfreak](https://github.com/bastelfreak)) - ## [v4.0.3](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.3) (2017-12-09) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.0.2...v4.0.3) @@ -57,7 +71,6 @@ These should not affect the functionality of the module. - Update readme with examples of using datasource and dashboard [\#80](https://github.com/voxpupuli/puppet-grafana/pull/80) ([devcfgc](https://github.com/devcfgc)) - Removing the datasource url check as it leads to errors with postgres… [\#76](https://github.com/voxpupuli/puppet-grafana/pull/76) ([Faffnir](https://github.com/Faffnir)) -- Release 4.0.2 [\#74](https://github.com/voxpupuli/puppet-grafana/pull/74) ([dhollinger](https://github.com/dhollinger)) ## [v4.0.2](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.2) (2017-10-12) @@ -71,7 +84,6 @@ These should not affect the functionality of the module. **Merged pull requests:** - fix typo in metadata \(redhat 6 twice vs 6/7\) [\#69](https://github.com/voxpupuli/puppet-grafana/pull/69) ([wyardley](https://github.com/wyardley)) -- Release 4.0.1 [\#68](https://github.com/voxpupuli/puppet-grafana/pull/68) ([wyardley](https://github.com/wyardley)) ## [v4.0.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.1) (2017-09-22) @@ -83,7 +95,7 @@ These should not affect the functionality of the module. **Merged pull requests:** -- Release 4.0.0 [\#62](https://github.com/voxpupuli/puppet-grafana/pull/62) ([bastelfreak](https://github.com/bastelfreak)) +- Release 4.0.1 [\#68](https://github.com/voxpupuli/puppet-grafana/pull/68) ([wyardley](https://github.com/wyardley)) ## [v4.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.0) (2017-09-20) @@ -118,8 +130,8 @@ These should not affect the functionality of the module. - Update README.md [\#67](https://github.com/voxpupuli/puppet-grafana/pull/67) ([wyardley](https://github.com/wyardley)) - Get rid of the dependency on 'wget' module in favor of puppet-archive [\#65](https://github.com/voxpupuli/puppet-grafana/pull/65) ([wyardley](https://github.com/wyardley)) - Remove licenses from the top of files [\#64](https://github.com/voxpupuli/puppet-grafana/pull/64) ([wyardley](https://github.com/wyardley)) +- Release 4.0.0 [\#62](https://github.com/voxpupuli/puppet-grafana/pull/62) ([bastelfreak](https://github.com/bastelfreak)) - Always use jessie apt repo when osfamily is Debian. [\#41](https://github.com/voxpupuli/puppet-grafana/pull/41) ([furhouse](https://github.com/furhouse)) -- Bump version, Update changelog [\#38](https://github.com/voxpupuli/puppet-grafana/pull/38) ([dhoppe](https://github.com/dhoppe)) ## [v3.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v3.0.0) (2017-03-29) @@ -140,6 +152,7 @@ These should not affect the functionality of the module. **Merged pull requests:** +- Bump version, Update changelog [\#38](https://github.com/voxpupuli/puppet-grafana/pull/38) ([dhoppe](https://github.com/dhoppe)) - Debian and RedHat based operating systems should use the repository by default [\#36](https://github.com/voxpupuli/puppet-grafana/pull/36) ([dhoppe](https://github.com/dhoppe)) - Add support for archlinux [\#32](https://github.com/voxpupuli/puppet-grafana/pull/32) ([bastelfreak](https://github.com/bastelfreak)) - Fix grafana\_dashboards [\#31](https://github.com/voxpupuli/puppet-grafana/pull/31) ([cassianoleal](https://github.com/cassianoleal)) @@ -151,14 +164,14 @@ These should not affect the functionality of the module. [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.2...v2.6.3) -**Merged pull requests:** - -- release 2.6.2 \(optimistic, i know ;\) [\#20](https://github.com/voxpupuli/puppet-grafana/pull/20) ([igalic](https://github.com/igalic)) - ## [v2.6.2](https://github.com/voxpupuli/puppet-grafana/tree/v2.6.2) (2017-01-18) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v2.6.1...v2.6.2) +**Merged pull requests:** + +- release 2.6.2 \(optimistic, i know ;\) [\#20](https://github.com/voxpupuli/puppet-grafana/pull/20) ([igalic](https://github.com/igalic)) + ## v2.6.1 (2017-01-18) Just a notice: The next release will be a major one without Puppet 3 support! diff --git a/metadata.json b/metadata.json index ab977ce44..cba863eda 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.2.1-rc0", + "version": "4.3.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From a90354ce6aaca8ea53eefd228a5609a94a84e513 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 18 Jun 2018 22:46:17 +0200 Subject: [PATCH 114/146] [blacksmith] Bump version to 4.3.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index cba863eda..cee7c9870 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.3.0", + "version": "4.3.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From b40f064fdf5710c69e795af944cbd525e81dde95 Mon Sep 17 00:00:00 2001 From: Andreas Zuber Date: Thu, 21 Jun 2018 10:26:15 +0200 Subject: [PATCH 115/146] Manage sysconfig files Use augeas to manage the sysconfig files which come with the Debian and RedHat packages. --- README.md | 19 +++++++++++++++++++ manifests/config.pp | 12 ++++++++++++ manifests/init.pp | 14 +++++++++++++- manifests/params.pp | 12 +++++++++++- spec/classes/grafana_spec.rb | 22 ++++++++++++++++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index be198db32..e535e493c 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,25 @@ Defaults to 'grafana-server'. The version of Grafana to install and manage. Defaults to the latest version of Grafana available at the time of module release. +##### `sysconfig_location` + +The RPM and DEB packages bring with them the default environment files for the +services. The default location of this file for Debian is /etc/default/grafana-server +and for RedHat /etc/sysconfig/grafana-server. + +##### `sysconfig` + +A hash of environment variables for the service. This only has an effect for installations +with RPM and DEB packages (if install_method is set to 'package' or 'repo'). + +Example: + +```puppet +sysconfig => { + 'http_proxy' => 'http://proxy.example.com', +} +``` + ### Advanced usage The archive install method will create the user and a "command line" service by diff --git a/manifests/config.pp b/manifests/config.pp index 725b10d9b..d357eb2e1 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -25,6 +25,18 @@ owner => 'grafana', group => 'grafana', } + + $sysconfig = $::grafana::sysconfig + $sysconfig_location = $::grafana::sysconfig_location + + if $sysconfig_location and $sysconfig { + $changes = $sysconfig.map |$key, $value| { "set ${key} ${value}" } + + augeas{'sysconfig/grafana-server': + context => "/files${$sysconfig_location}", + changes => $changes, + } + } } 'archive': { $cfg = $::grafana::cfg diff --git a/manifests/init.pp b/manifests/init.pp index 9897d9819..01343bfea 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -66,6 +66,16 @@ # A hash of plugins to be passed to `create_resources`, wraps around the # `grafana_plugin` resource. # +# [*sysconfig_location*] +# Location of the sysconfig file for the environment of the grafana-server service. +# This is only used when the install_method is 'package' or 'repo'. +# +# [*sysconfig*] +# A hash of environment variables for the grafana-server service +# +# Example: +# sysconfig => { 'http_proxy' => 'http://proxy.example.com/' } +# # === Examples # # class { '::grafana': @@ -89,7 +99,9 @@ String $rpm_iteration = $::grafana::params::rpm_iteration, String $service_name = $::grafana::params::service_name, String $version = $::grafana::params::version, - Hash $plugins = {} + Hash $plugins = {}, + Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location, + Optional[Hash] $sysconfig = undef, ) inherits grafana::params { contain grafana::install diff --git a/manifests/params.pp b/manifests/params.pp index 062054afc..31544a130 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,18 +21,28 @@ $install_method = 'repo' $cfg_location = '/etc/grafana.ini' $service_name = 'grafana' + $sysconfig_location = undef } - 'Debian', 'RedHat': { + 'Debian': { $manage_package_repo = true $install_method = 'repo' $cfg_location = '/etc/grafana/grafana.ini' $service_name = 'grafana-server' + $sysconfig_location = '/etc/default/grafana-server' + } + 'RedHat': { + $manage_package_repo = true + $install_method = 'repo' + $cfg_location = '/etc/grafana/grafana.ini' + $service_name = 'grafana-server' + $sysconfig_location = '/etc/sysconfig/grafana-server' } default: { $manage_package_repo = true $install_method = 'package' $cfg_location = '/etc/grafana/grafana.ini' $service_name = 'grafana-server' + $sysconfig_location = undef } } } diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 780817210..9237efa67 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -309,6 +309,28 @@ it { is_expected.to contain_file('/etc/grafana/ldap.toml').with_content(ldap_expected) } end end + + context 'sysconfig environment variables' do + let(:params) do + { + install_method: 'repo', + sysconfig: { http_proxy: 'http://proxy.example.com/' } + } + end + + case facts[:osfamily] + when 'Debian' + describe 'Add the environment variable to the config file' do + it { is_expected.to contain_augeas('sysconfig/grafana-server').with_context('/files/etc/default/grafana-server') } + it { is_expected.to contain_augeas('sysconfig/grafana-server').with_changes(['set http_proxy http://proxy.example.com/']) } + end + when 'RedHat' + describe 'Add the environment variable to the config file' do + it { is_expected.to contain_augeas('sysconfig/grafana-server').with_context('/files/etc/sysconfig/grafana-server') } + it { is_expected.to contain_augeas('sysconfig/grafana-server').with_changes(['set http_proxy http://proxy.example.com/']) } + end + end + end end end end From badcfb76e6fe1898cf5d9b196aaf4de8fe31008d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 21 Jun 2018 20:04:06 +0200 Subject: [PATCH 116/146] bump archive upper version boundary to <4.0.0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index cee7c9870..9e6183371 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppet/archive", - "version_requirement": ">= 1.0.1 < 3.0.0" + "version_requirement": ">= 1.0.1 < 4.0.0" }, { "name": "puppetlabs/stdlib", From b0c60b7d22658438daa17e54cde2edfc7b414255 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 21 Jun 2018 20:14:58 +0200 Subject: [PATCH 117/146] release 4.4.0 --- CHANGELOG.md | 12 ++++++++++++ metadata.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5743ce353..5545e071c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.4.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.4.0) (2018-06-21) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.3.0...v4.4.0) + +**Implemented enhancements:** + +- Manage sysconfig files [\#115](https://github.com/voxpupuli/puppet-grafana/pull/115) ([ZeroPointEnergy](https://github.com/ZeroPointEnergy)) + +**Merged pull requests:** + +- bump archive upper version boundary to \<4.0.0 [\#116](https://github.com/voxpupuli/puppet-grafana/pull/116) ([bastelfreak](https://github.com/bastelfreak)) + ## [v4.3.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.3.0) (2018-06-18) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.2.0...v4.3.0) diff --git a/metadata.json b/metadata.json index 9e6183371..a5db18b2f 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.3.1-rc0", + "version": "4.4.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 45c8ae8272a886462f261d568cdd03b59d61b3dc Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 21 Jun 2018 20:37:26 +0200 Subject: [PATCH 118/146] [blacksmith] Bump version to 4.4.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index a5db18b2f..d12767b19 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.4.0", + "version": "4.4.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 1aa35ad64227a25bbea9294d31913164f3ae8385 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Wed, 27 Jun 2018 14:46:55 -0500 Subject: [PATCH 119/146] Added a file resource to config function. Modified dependency slightly to allow plugins to be installed after file resource creates plugin directory: only works for package, repo, and archive install methods. --- manifests/config.pp | 14 ++++++++++++++ manifests/init.pp | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index d357eb2e1..83a5f7fef 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -37,6 +37,13 @@ changes => $changes, } } + + file { "${::grafana::data_dir}/plugins": + ensure => directory, + owner => 'grafana', + group => 'grafana', + mode => '0750', + } } 'archive': { $cfg = $::grafana::cfg @@ -47,6 +54,13 @@ owner => 'grafana', group => 'grafana', } + + file { "${::grafana::data_dir}/plugins": + ensure => directory, + owner => 'grafana', + group => 'grafana', + mode => '0750', + } } default: { fail("Installation method ${::grafana::install_method} not supported") diff --git a/manifests/init.pp b/manifests/init.pp index 01343bfea..edfc5a793 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -113,7 +113,7 @@ ~> Class['grafana::service'] create_resources(grafana_plugin, $plugins) - - Grafana_Plugin <| |> ~> Class['grafana::service'] - + # Dependency added for Grafana_plugins to ensure it runs at the + # correct time. + Class['grafana::config'] -> Grafana_Plugin <| |> ~> Class['grafana::service'] } From bcb2d3108786fbb40eaea29847ab6963f814f3a5 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Tue, 3 Jul 2018 15:43:32 -0500 Subject: [PATCH 120/146] Fixed whitespace issue in resources. --- manifests/config.pp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 83a5f7fef..78126a6eb 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -39,10 +39,10 @@ } file { "${::grafana::data_dir}/plugins": - ensure => directory, - owner => 'grafana', - group => 'grafana', - mode => '0750', + ensure => directory, + owner => 'grafana', + group => 'grafana', + mode => '0750', } } 'archive': { @@ -56,10 +56,10 @@ } file { "${::grafana::data_dir}/plugins": - ensure => directory, - owner => 'grafana', - group => 'grafana', - mode => '0750', + ensure => directory, + owner => 'grafana', + group => 'grafana', + mode => '0750', } } default: { From 7b2e1abe02223a5032d56c1ee5722ad39ae7f011 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jul 2018 00:02:39 +0200 Subject: [PATCH 121/146] release 4.4.1 --- CHANGELOG.md | 14 +++++++++++++- metadata.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5545e071c..9cbe051fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.4.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.4.1) (2018-07-04) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.4.0...v4.4.1) + +**Fixed bugs:** + +- Fix dependency in provisioning plugins [\#118](https://github.com/voxpupuli/puppet-grafana/pull/118) ([drshawnkwang](https://github.com/drshawnkwang)) + +**Closed issues:** + +- grafana plugin install/check breaks catalog run when grafana-server service is not running [\#79](https://github.com/voxpupuli/puppet-grafana/issues/79) + ## [v4.4.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.4.0) (2018-06-21) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.3.0...v4.4.0) @@ -321,4 +333,4 @@ This is the last Release that supports it! First release on the Puppet Forge -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/metadata.json b/metadata.json index d12767b19..b4e7afc49 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.4.1-rc0", + "version": "4.4.1", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From cc593375fb96ee62c4242f4472b06f4d6feb2198 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jul 2018 09:38:29 +0200 Subject: [PATCH 122/146] [blacksmith] Bump version to 4.4.2-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index b4e7afc49..a0715c9e5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.4.1", + "version": "4.4.2-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 3914f4aca986f0cdfb9375dfb06fb43a66a32e3d Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Thu, 21 Jun 2018 12:05:00 -0500 Subject: [PATCH 123/146] Puppet provisioning of daashboards and datasources. Add funtionality to allow puppet to provision datasources and dashboards using grafana's built-in provisioning feature. Add templates for datasources and dashbaords. Allow dashboards to be dynamically provisioned using puppet file resource. --- manifests/config.pp | 56 +++++++++++++++++++++++++++++++++ manifests/init.pp | 2 ++ templates/pdashboards.yaml.erb | 3 ++ templates/pdatasources.yaml.erb | 3 ++ 4 files changed, 64 insertions(+) create mode 100644 templates/pdashboards.yaml.erb create mode 100644 templates/pdatasources.yaml.erb diff --git a/manifests/config.pp b/manifests/config.pp index 78126a6eb..d43ff2491 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -7,6 +7,7 @@ 'docker': { if $::grafana::container_cfg { $cfg = $::grafana::cfg + $myprovision = false file { $::grafana::cfg_location: ensure => file, @@ -18,6 +19,7 @@ } 'package','repo': { $cfg = $::grafana::cfg + $myprovision = true file { $::grafana::cfg_location: ensure => file, @@ -47,6 +49,7 @@ } 'archive': { $cfg = $::grafana::cfg + $myprovision = true file { "${::grafana::install_dir}/conf/custom.ini": ensure => file, @@ -76,4 +79,57 @@ group => 'grafana', } } + + # If grafana version is > 5.0.0, and the install method is package, + # repo, or archive, then use the provisioning feature. Dashboards + # and datasources are placed in + # /etc/grafana/provisioning/[dashboards|datasources]. + # --dashboards-- + if ((versioncmp($::grafana::version, '5.0.0') >= 0) and ($myprovision)) { + $pdashboards = $::grafana::provisioning_dashboards + if (length($pdashboards) >= 1 ) { + $dashboardpaths = flatten(deep_find_and_remove('options', $pdashboards)) + # template uses: + # - pdashboards + file { '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml': + ensure => file, + owner => 'grafana', + group => 'grafana', + mode => '0640', + content => template('grafana/pdashboards.yaml.erb'), + notify => Service[$::grafana::service_name], + } + # Loop over all providers, extract the paths and create + # directories for each path of dashboards. + $dashboardpaths.each | Integer $index, Hash $options | { + if has_key($options, 'path') { + file { $options['path'] : + ensure => directory, + owner => 'grafana', + group => 'grafana', + mode => '0750', + recurse => true, + purge => true, + source => $options['puppetsource'], + } + } + } + } + + # --datasources-- + $pdatasources = $::grafana::provisioning_datasources + if (length($pdatasources) >= 1) { + # template uses: + # - pdatasources + file { '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml': + ensure => file, + owner => 'grafana', + group => 'grafana', + mode => '0640', + content => template('grafana/pdatasources.yaml.erb'), + notify => Service[$::grafana::service_name], + } + } + + } } diff --git a/manifests/init.pp b/manifests/init.pp index edfc5a793..d1ac76c2e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -100,6 +100,8 @@ String $service_name = $::grafana::params::service_name, String $version = $::grafana::params::version, Hash $plugins = {}, + Hash $provisioning_dashboards = {}, + Hash $provisioning_datasources = {}, Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location, Optional[Hash] $sysconfig = undef, ) inherits grafana::params { diff --git a/templates/pdashboards.yaml.erb b/templates/pdashboards.yaml.erb new file mode 100644 index 000000000..3b74872aa --- /dev/null +++ b/templates/pdashboards.yaml.erb @@ -0,0 +1,3 @@ +# This file is managed by Puppet, any changes will be overwritten + +<%= @pdashboards.to_yaml %> diff --git a/templates/pdatasources.yaml.erb b/templates/pdatasources.yaml.erb new file mode 100644 index 000000000..b6ba42eba --- /dev/null +++ b/templates/pdatasources.yaml.erb @@ -0,0 +1,3 @@ +# This file is managed by Puppet, any changes will be overwritten + +<%= @pdatasources.to_yaml %> From a45008e0bcf0e3e4698b05090c360de62287f624 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Fri, 29 Jun 2018 11:32:34 -0500 Subject: [PATCH 124/146] Add Ruby function and puppet code to extract path from hash. Ruby function copies the options array from the input hash for puppet. Puppet uses this to create file resource for dashboard directories. Finally, the hash without the 'puppetsource' key is used in the template for grafana. --- lib/puppet/functions/deep_find_and_remove.rb | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/puppet/functions/deep_find_and_remove.rb diff --git a/lib/puppet/functions/deep_find_and_remove.rb b/lib/puppet/functions/deep_find_and_remove.rb new file mode 100644 index 000000000..2c22569e6 --- /dev/null +++ b/lib/puppet/functions/deep_find_and_remove.rb @@ -0,0 +1,38 @@ +# == Function: deep_find_and_remove +# +# This function takes a hash as input, along with a string +# (key). Additionally, the optional removekey (defaults to +# 'puppetsource') is a parameter. +# +# The purpose of this function is to extract the 'options' subhash +# from the array of hashes given to provision dashboards. This options +# subhash may contain a path and source which puppet will use for +# provisioning: creating the path and applying the files from the +# source. +# +# Additionally, if the key 'puppetsource' exists in the sub-hash, it +# will be deleted from the structure. Thus the output of this function +# may be used in yaml format for grafana's provisioning +# configuration file for dashboards. +Puppet::Functions.create_function(:'deep_find_and_remove') do + dispatch :deep_find_and_remove do + param 'String', :key + param 'Hash', :object + optional_param 'String', :removekey + return_type 'Array' + end + + def deep_find_and_remove(key, object, removekey='puppetsource') + foundpaths = Array.new + if object.respond_to?(:key?) && object.key?(key) + foundpaths << object[key].dup + object[key].delete(removekey) + end + if object.is_a? Enumerable + foundpaths << object.collect { |*a| deep_find_and_remove(key, a.last) } + end + foundpaths.flatten.compact + return foundpaths + end + +end From 90122bc062dfc89a61c717a3fb74f7adef7812ed Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Tue, 3 Jul 2018 15:42:48 -0500 Subject: [PATCH 125/146] Documentation on provisioning. No functional changes. --- README.md | 141 ++++++++++++++++++++++++++++++++++++++++++++++ manifests/init.pp | 14 +++++ 2 files changed, 155 insertions(+) diff --git a/README.md b/README.md index e535e493c..0fe7a975b 100644 --- a/README.md +++ b/README.md @@ -288,6 +288,33 @@ The download location of a package to be used with the 'package' install method. Defaults to the URL of the latest version of Grafana available at the time of module release. +##### `provisioning_datasources` + +A Hash which is converted to YAML for grafana to provision data +sources. See [provisioning +grafana](http://docs.grafana.org/administration/provisioning/) for +details and example config file. Requires grafana > v5.0.0. + +This is very useful with Hiera as you can provide a yaml +hash/dictionary which will effectively 'passthrough' to grafana. See +**Advanced Usage** for examples. + +##### `provisioning_dashboards` + +A Hash which is converted to YAML for grafana to provision +dashboards. See [provisioning +grafana](http://docs.grafana.org/administration/provisioning/) for +details and example config file. Requires grafana > v5.0.0. + +This is very useful with Hiera as you can provide a yaml +hash/dictionary which will effectively 'passthrough' to grafana. See +**Advanced Usage** for examples. + +N.B. A option named `puppetsource` may be given in the `options` hash +which is not part of grafana's syntax. This option will be extracted +from the hash, and used to "source" a directory of dashboards. See +**Advanced Usage** for details. + ##### `rpm_iteration` Used when installing Grafana from package ('package' or 'repo' install methods) @@ -607,6 +634,120 @@ grafana_user { 'username': ``` `grafana_api_path` is only required if using sub-paths for the API +#### Provisioning Grafana + +[Grafana documentation on +provisioning](http://docs.grafana.org/administration/provisioning/). + +This module will provision grafana by placing yaml files into +`/etc/grafana/provisioning/datasources` and +`/etc/grafana/provisioning/dashboards`. + +##### Example datasource + +A puppet hash example for Prometheus. The module will place the hash +as a yaml file into `/etc/gafana/provisioning/datasources/puppetprovisioned.yaml`. + +```puppet +class { 'grafana': + provisioning_datasources => { + apiVersion => 1, + datasources => [ + { + name => 'Prometheus', + type => 'prometheus', + access => 'proxy', + url => 'http://localhost:9090/prometheus', + isDefault => true, + }, + ], + } +} +``` + +Here is the same configuration example as a hiera hash. + +```yaml +grafana::provisioning_datasources: + apiVersion: 1 + datasources: + - name: 'Prometheus' + type: 'prometheus' + access: 'proxy' + url: 'http://localhost:9090/prometheus' + isDefault: true +``` + +##### Example dashboard + +An example puppet hash for provisioning dashboards. The module will +place the hash as a yaml file into +`/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml`. More details follow the examples. + +```puppet +class { 'grafana': + provisioning_dashboards => { + apiVersion => 1, + providers => [ + { + name => 'default' + orgId => 1, + fiolder => '', + type => 'file', + disableDeletion => true, + options => { + path => '/var/lib/grafana/dashboards', + puppetsource => 'puppet:///modules/my_custom_module/dashboards', + }, + }, + ], + } +} +``` + +Here is the same configuraiton example as a hiera hash. + +```yaml +grafana::provisioning_dashboards: + apiVersion: 1 + providers: + - name: 'default' + orgId: 1 + folder: '' + type: file + disableDeletion: true + options: + path: '/var/lib/grafana/dashboards' + puppetsource: 'puppet:///modules/my_custom_module/dashboards' +``` + +In both examples above a non-grafana option named `puppetsource` has +been used. When this module finds that the provisioning_dashboards hash +contains keys `path` and `puppetsource` in the `options` subhash, it +will do the following. +* It will create the path found in `options['path']`. Note: puppet + will only create the final directory of the path unless the + parameter `create_subdirs_provisioning` is set to true: this defaults + to false. +* It will use `puppetsource` as the file resource's 'source' for the + directory. +* It removes the `puppetsource` key from the `options` subhash, so the + subsequent yaml file for gafana does not contain this key. (The + `path` key will remain.) + +This feature allows you to define a custom module, and place any +dashboards you want provisioned in the its `files/` directory. In the +example above you would put dashboards into +`my_custom_module/files/dashboards` and puppet-grafana will create +`/var/lib/grafana/dashboards` and provision it with the contents of +`my_custom_module/files/dashboards`. + +Puppet's file resource may also be given a `file://` URI which may +point to a locally available directory on the filesystem, typically +the filesystem of the puppetserver/master. Thus you may specify a +local directory with grafana dashboards you wish to provision into +grafana. + ## Limitations This module has been tested on Ubuntu 14.04, using each of the 'archive', 'docker' diff --git a/manifests/init.pp b/manifests/init.pp index d1ac76c2e..5ca2dbd49 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -66,6 +66,20 @@ # A hash of plugins to be passed to `create_resources`, wraps around the # `grafana_plugin` resource. # +# [*provisioning_dashboards*] +# Hash of dashboards to provision into grafana. grafana > v5.0.0 +# required. Hash will be converted into YAML and used by grafana to +# provision dashboards. +# +# [*provisioning_datasources*] +# Hash of datasources to provision into grafana, grafana > v5.0.0 +# required. Hash will be converted into YAML and used by granfana to +# configure datasources. +# +# [*create_subdirs_provisioning*] +# Boolean, defaults to false. If true puppet will create any +# subdirectories in the given path when provisioning dashboards. +# # [*sysconfig_location*] # Location of the sysconfig file for the environment of the grafana-server service. # This is only used when the install_method is 'package' or 'repo'. From b88e8aec6c466df32ba3575b010192fa8c7634ad Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Thu, 5 Jul 2018 10:43:56 -0500 Subject: [PATCH 126/146] Added functionality to create all subpaths given in options path variable. Only works on UNIX paths. Added parameter to control whether the creation of the subpaths is to be controlled by puppet. --- lib/puppet/functions/get_sub_paths.rb | 43 +++++++++++++++++++++++++++ manifests/config.pp | 10 +++++++ manifests/init.pp | 1 + manifests/params.pp | 1 + 4 files changed, 55 insertions(+) create mode 100644 lib/puppet/functions/get_sub_paths.rb diff --git a/lib/puppet/functions/get_sub_paths.rb b/lib/puppet/functions/get_sub_paths.rb new file mode 100644 index 000000000..031382435 --- /dev/null +++ b/lib/puppet/functions/get_sub_paths.rb @@ -0,0 +1,43 @@ +# == Function get_sub_paths +# +# This function receives an input path as an input parameter, and +# returns an array of the subpaths in the input, excluding the input +# path itself. The function will attempt to ignore any extra slashes +# in the path given. +# +# This function will only work on UNIX paths with forward slashes (/). +# +# Examples: +# input = '/var/lib/grafana/dashboards' +# output = [ '/var', '/var/lib', '/var/lib/grafana'/ ] +# +# input = '/opt' +# output = [] +# +# input = '/first/second/' +# output = [ '/first' ] +Puppet::Functions.create_function(:'get_sub_paths') do + dispatch :get_sub_paths do + param 'String', :inputpath + return_type 'Array' + end + + def get_sub_paths(inputpath) + ip = inputpath.gsub(/\/+/,"/") + allsubs = Array.new + parts = ip.split('/') + parts.each_with_index do |value, index| + if (index==0) or (index==(parts.length-1)) + next + end + + if index==1 + allsubs << '/' + value + else + allsubs << allsubs[index-2] + '/' + value + end + end + return allsubs + end + +end diff --git a/manifests/config.pp b/manifests/config.pp index d43ff2491..a8aaf2835 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -103,6 +103,16 @@ # directories for each path of dashboards. $dashboardpaths.each | Integer $index, Hash $options | { if has_key($options, 'path') { + # get sub paths of 'path' and create subdirs if necessary + $subpaths = get_sub_paths($options['path']) + # @todo - consider a boolean parameter for users to choose whether or not subpaths are created. + if ($::grafana::create_subdirs_provisioning and (length($subpaths) >= 1)) { + file { $subpaths : + ensure => directory, + before => File["${options['path']}"], + } + } + file { $options['path'] : ensure => directory, owner => 'grafana', diff --git a/manifests/init.pp b/manifests/init.pp index 5ca2dbd49..b2c05cf2d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -116,6 +116,7 @@ Hash $plugins = {}, Hash $provisioning_dashboards = {}, Hash $provisioning_datasources = {}, + Boolean $create_subdirs_provisioning = $::grafana::params::create_subdirs_provisioning, Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location, Optional[Hash] $sysconfig = undef, ) inherits grafana::params { diff --git a/manifests/params.pp b/manifests/params.pp index 31544a130..b2553a422 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -15,6 +15,7 @@ $rpm_iteration = '1' $repo_name = 'stable' $version = '4.5.1' + $create_subdirs_provisioning = false case $facts['os']['family'] { 'Archlinux': { $manage_package_repo = false From 1d35bc5737585567bb4c36f4b1d04139fb4b53f5 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Thu, 5 Jul 2018 12:52:43 -0500 Subject: [PATCH 127/146] Fixed errors found by Travis CI testing. --- .../{ => grafana}/deep_find_and_remove.rb | 11 +++++------ .../functions/{ => grafana}/get_sub_paths.rb | 17 +++++++---------- manifests/config.pp | 6 +++--- 3 files changed, 15 insertions(+), 19 deletions(-) rename lib/puppet/functions/{ => grafana}/deep_find_and_remove.rb (80%) rename lib/puppet/functions/{ => grafana}/get_sub_paths.rb (74%) diff --git a/lib/puppet/functions/deep_find_and_remove.rb b/lib/puppet/functions/grafana/deep_find_and_remove.rb similarity index 80% rename from lib/puppet/functions/deep_find_and_remove.rb rename to lib/puppet/functions/grafana/deep_find_and_remove.rb index 2c22569e6..6ff436c9a 100644 --- a/lib/puppet/functions/deep_find_and_remove.rb +++ b/lib/puppet/functions/grafana/deep_find_and_remove.rb @@ -14,7 +14,7 @@ # will be deleted from the structure. Thus the output of this function # may be used in yaml format for grafana's provisioning # configuration file for dashboards. -Puppet::Functions.create_function(:'deep_find_and_remove') do +Puppet::Functions.create_function(:'grafana::deep_find_and_remove') do dispatch :deep_find_and_remove do param 'String', :key param 'Hash', :object @@ -22,17 +22,16 @@ return_type 'Array' end - def deep_find_and_remove(key, object, removekey='puppetsource') - foundpaths = Array.new + def deep_find_and_remove(key, object, removekey = 'puppetsource') + foundpaths = [] if object.respond_to?(:key?) && object.key?(key) foundpaths << object[key].dup object[key].delete(removekey) end if object.is_a? Enumerable - foundpaths << object.collect { |*a| deep_find_and_remove(key, a.last) } + foundpaths << object.map { |*a| deep_find_and_remove(key, a.last) } end foundpaths.flatten.compact - return foundpaths + foundpaths end - end diff --git a/lib/puppet/functions/get_sub_paths.rb b/lib/puppet/functions/grafana/get_sub_paths.rb similarity index 74% rename from lib/puppet/functions/get_sub_paths.rb rename to lib/puppet/functions/grafana/get_sub_paths.rb index 031382435..203d7dc72 100644 --- a/lib/puppet/functions/get_sub_paths.rb +++ b/lib/puppet/functions/grafana/get_sub_paths.rb @@ -16,28 +16,25 @@ # # input = '/first/second/' # output = [ '/first' ] -Puppet::Functions.create_function(:'get_sub_paths') do +Puppet::Functions.create_function(:'grafana::get_sub_paths') do dispatch :get_sub_paths do param 'String', :inputpath return_type 'Array' end def get_sub_paths(inputpath) - ip = inputpath.gsub(/\/+/,"/") - allsubs = Array.new + ip = inputpath.gsub(%r{/+}, '/') + allsubs = [] parts = ip.split('/') parts.each_with_index do |value, index| - if (index==0) or (index==(parts.length-1)) - next - end + next if (index.zero?) || (index == (parts.length - 1)) - if index==1 + if index == 1 allsubs << '/' + value else - allsubs << allsubs[index-2] + '/' + value + allsubs << allsubs[index - 2] + '/' + value end end - return allsubs + allsubs end - end diff --git a/manifests/config.pp b/manifests/config.pp index a8aaf2835..7acaa3ddf 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -88,7 +88,7 @@ if ((versioncmp($::grafana::version, '5.0.0') >= 0) and ($myprovision)) { $pdashboards = $::grafana::provisioning_dashboards if (length($pdashboards) >= 1 ) { - $dashboardpaths = flatten(deep_find_and_remove('options', $pdashboards)) + $dashboardpaths = flatten(grafana::deep_find_and_remove('options', $pdashboards)) # template uses: # - pdashboards file { '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml': @@ -104,12 +104,12 @@ $dashboardpaths.each | Integer $index, Hash $options | { if has_key($options, 'path') { # get sub paths of 'path' and create subdirs if necessary - $subpaths = get_sub_paths($options['path']) + $subpaths = grafana::get_sub_paths($options['path']) # @todo - consider a boolean parameter for users to choose whether or not subpaths are created. if ($::grafana::create_subdirs_provisioning and (length($subpaths) >= 1)) { file { $subpaths : ensure => directory, - before => File["${options['path']}"], + before => File[$options['path']], } } From 0d83b3a9387226ae0b4df0afbf843addf30b8b8e Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Thu, 5 Jul 2018 13:54:34 -0500 Subject: [PATCH 128/146] Additional changes for Travis CI - ruby style/syntax --- lib/puppet/functions/grafana/get_sub_paths.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/puppet/functions/grafana/get_sub_paths.rb b/lib/puppet/functions/grafana/get_sub_paths.rb index 203d7dc72..a3c22cd25 100644 --- a/lib/puppet/functions/grafana/get_sub_paths.rb +++ b/lib/puppet/functions/grafana/get_sub_paths.rb @@ -27,12 +27,11 @@ def get_sub_paths(inputpath) allsubs = [] parts = ip.split('/') parts.each_with_index do |value, index| - next if (index.zero?) || (index == (parts.length - 1)) - - if index == 1 - allsubs << '/' + value + next if index.zero? || index == (parts.length - 1) + allsubs << if index == 1 + '/' + value else - allsubs << allsubs[index - 2] + '/' + value + allsubs[index - 2] + '/' + value end end allsubs From d464e95d754a9c0b1a7e9bf22748c04c5a6393d5 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Fri, 6 Jul 2018 09:31:31 -0500 Subject: [PATCH 129/146] metadata.json - bumped version requirement for puppetlabs-stdlib Changed spacing in params.pp Removed absolute top-scope and changed templates to use epp files Refactored .erb templates into .epp templates. --- manifests/config.pp | 17 +++++++------- manifests/params.pp | 22 +++++++++---------- metadata.json | 2 +- ...shboards.yaml.erb => pdashboards.yaml.epp} | 2 +- ...sources.yaml.erb => pdatasources.yaml.epp} | 2 +- 5 files changed, 22 insertions(+), 23 deletions(-) rename templates/{pdashboards.yaml.erb => pdashboards.yaml.epp} (58%) rename templates/{pdatasources.yaml.erb => pdatasources.yaml.epp} (58%) diff --git a/manifests/config.pp b/manifests/config.pp index 7acaa3ddf..96bc7322c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -85,8 +85,8 @@ # and datasources are placed in # /etc/grafana/provisioning/[dashboards|datasources]. # --dashboards-- - if ((versioncmp($::grafana::version, '5.0.0') >= 0) and ($myprovision)) { - $pdashboards = $::grafana::provisioning_dashboards + if ((versioncmp($grafana::version, '5.0.0') >= 0) and ($myprovision)) { + $pdashboards = $grafana::provisioning_dashboards if (length($pdashboards) >= 1 ) { $dashboardpaths = flatten(grafana::deep_find_and_remove('options', $pdashboards)) # template uses: @@ -96,8 +96,8 @@ owner => 'grafana', group => 'grafana', mode => '0640', - content => template('grafana/pdashboards.yaml.erb'), - notify => Service[$::grafana::service_name], + content => epp('grafana/pdashboards.yaml.epp'), + notify => Service[$grafana::service_name], } # Loop over all providers, extract the paths and create # directories for each path of dashboards. @@ -105,8 +105,7 @@ if has_key($options, 'path') { # get sub paths of 'path' and create subdirs if necessary $subpaths = grafana::get_sub_paths($options['path']) - # @todo - consider a boolean parameter for users to choose whether or not subpaths are created. - if ($::grafana::create_subdirs_provisioning and (length($subpaths) >= 1)) { + if ($grafana::create_subdirs_provisioning and (length($subpaths) >= 1)) { file { $subpaths : ensure => directory, before => File[$options['path']], @@ -127,7 +126,7 @@ } # --datasources-- - $pdatasources = $::grafana::provisioning_datasources + $pdatasources = $grafana::provisioning_datasources if (length($pdatasources) >= 1) { # template uses: # - pdatasources @@ -136,8 +135,8 @@ owner => 'grafana', group => 'grafana', mode => '0640', - content => template('grafana/pdatasources.yaml.erb'), - notify => Service[$::grafana::service_name], + content => epp('grafana/pdatasources.yaml.epp'), + notify => Service[$grafana::service_name], } } diff --git a/manifests/params.pp b/manifests/params.pp index b2553a422..410416782 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,17 +4,17 @@ # It sets variables according to platform # class grafana::params { - $cfg = {} - $container_cfg = false - $container_params = {} - $data_dir = '/var/lib/grafana' - $docker_image = 'grafana/grafana' - $docker_ports = '3000:3000' - $install_dir = '/usr/share/grafana' - $package_name = 'grafana' - $rpm_iteration = '1' - $repo_name = 'stable' - $version = '4.5.1' + $cfg = {} + $container_cfg = false + $container_params = {} + $data_dir = '/var/lib/grafana' + $docker_image = 'grafana/grafana' + $docker_ports = '3000:3000' + $install_dir = '/usr/share/grafana' + $package_name = 'grafana' + $rpm_iteration = '1' + $repo_name = 'stable' + $version = '4.5.1' $create_subdirs_provisioning = false case $facts['os']['family'] { 'Archlinux': { diff --git a/metadata.json b/metadata.json index a0715c9e5..65427efd1 100644 --- a/metadata.json +++ b/metadata.json @@ -14,7 +14,7 @@ }, { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.6.0 < 5.0.0" + "version_requirement": ">=4.20.0 < 5.0.0" } ], "operatingsystem_support": [ diff --git a/templates/pdashboards.yaml.erb b/templates/pdashboards.yaml.epp similarity index 58% rename from templates/pdashboards.yaml.erb rename to templates/pdashboards.yaml.epp index 3b74872aa..4dc594a0f 100644 --- a/templates/pdashboards.yaml.erb +++ b/templates/pdashboards.yaml.epp @@ -1,3 +1,3 @@ # This file is managed by Puppet, any changes will be overwritten -<%= @pdashboards.to_yaml %> +<%= to_yaml($grafana::config::pdashboards) -%> diff --git a/templates/pdatasources.yaml.erb b/templates/pdatasources.yaml.epp similarity index 58% rename from templates/pdatasources.yaml.erb rename to templates/pdatasources.yaml.epp index b6ba42eba..aec0289fc 100644 --- a/templates/pdatasources.yaml.erb +++ b/templates/pdatasources.yaml.epp @@ -1,3 +1,3 @@ # This file is managed by Puppet, any changes will be overwritten -<%= @pdatasources.to_yaml %> +<%= to_yaml($grafana::config::pdatasources) -%> From 43247bfe428e9d561eec663c08c718596e0f589d Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Fri, 6 Jul 2018 11:33:59 -0500 Subject: [PATCH 130/146] Changed spacing to resolve Travis CI build error. --- lib/puppet/functions/grafana/get_sub_paths.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/puppet/functions/grafana/get_sub_paths.rb b/lib/puppet/functions/grafana/get_sub_paths.rb index a3c22cd25..b2ff27f2c 100644 --- a/lib/puppet/functions/grafana/get_sub_paths.rb +++ b/lib/puppet/functions/grafana/get_sub_paths.rb @@ -29,10 +29,10 @@ def get_sub_paths(inputpath) parts.each_with_index do |value, index| next if index.zero? || index == (parts.length - 1) allsubs << if index == 1 - '/' + value - else - allsubs[index - 2] + '/' + value - end + '/' + value + else + allsubs[index - 2] + '/' + value + end end allsubs end From 4beaf83ba357cb81fcddbe180df31edca9e19280 Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Fri, 6 Jul 2018 12:04:57 -0500 Subject: [PATCH 131/146] Added missing comma to docs. No functional changes. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fe7a975b..aa7f3cb41 100644 --- a/README.md +++ b/README.md @@ -690,7 +690,7 @@ class { 'grafana': apiVersion => 1, providers => [ { - name => 'default' + name => 'default', orgId => 1, fiolder => '', type => 'file', From d976622d06114648e1b8cbaa8068bcf539bb635d Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Fri, 6 Jul 2018 12:41:58 -0500 Subject: [PATCH 132/146] Added acceptance test, written by @bastelfreak. --- spec/acceptance/class_spec.rb | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 4e65250a9..60396cd83 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -22,4 +22,45 @@ class { 'grafana': } it { is_expected.to be_running } end end + + context 'with fancy dashboard config' do + it 'works idempotently with no errors' do + pp = <<-EOS + class { 'grafana': + provisioning_datasources => { + apiVersion => 1, + datasources => [ + { + name => 'Prometheus', + type => 'prometheus', + access => 'proxy', + url => 'http://localhost:9090/prometheus', + isDefault => true, + }, + ], + }, + provisioning_dashboards => { + apiVersion => 1, + providers => [ + { + name => 'default', + orgId => 1, + fiolder => '', + type => 'file', + disableDeletion => true, + options => { + path => '/var/lib/grafana/dashboards', + puppetsource => 'puppet:///modules/my_custom_module/dashboards', + }, + }, + ], + } + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + end end From bd89e5a7192fe784baf2e7e9a7600a0261a527da Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 15 Jul 2018 00:27:36 +0200 Subject: [PATCH 133/146] modulesync 1.9.3 --- .msync.yml | 2 +- .travis.yml | 4 ++-- Gemfile | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.msync.yml b/.msync.yml index 1a132115d..c39f6b7d7 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.2' +modulesync_config_version: '1.9.3' diff --git a/.travis.yml b/.travis.yml index 15b4f8780..9cf5ccd79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,13 +31,13 @@ matrix: - rvm: 2.5.1 bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker services: docker sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker services: docker sudo: required branches: diff --git a/Gemfile b/Gemfile index 90a43fdc8..e7d7e074d 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.6.0', :require => false + gem 'puppetlabs_spec_helper', '~> 2.6', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false @@ -56,13 +56,16 @@ group :system_tests do gem 'beaker-hostgenerator', '>= 1.1.10', :require => false gem 'beaker-puppet_install_helper', :require => false gem 'beaker-module_install_helper', :require => false + gem 'rbnacl', '~> 4', :require => false if RUBY_VERSION >= '2.2.6' + gem 'rbnacl-libsodium', :require => false if RUBY_VERSION >= '2.2.6' + gem 'bcrypt_pbkdf', :require => false end group :release do gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator' if RUBY_VERSION >= '2.2.2' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' - gem 'puppet-strings', '~> 1.0', :require => false + gem 'puppet-strings', '>= 1.0', :require => false end From 9f2623c6d345d41c28c5cddb62c11e95b07f1611 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 15 Jul 2018 20:29:29 +0200 Subject: [PATCH 134/146] release 4.5.0 --- CHANGELOG.md | 9 +++++++++ metadata.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cbe051fe..7e73e528e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.5.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.5.0) (2018-07-15) + +[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.4.1...v4.5.0) + +**Implemented enhancements:** + +- Use provisioning backend for dashboards, providers [\#103](https://github.com/voxpupuli/puppet-grafana/issues/103) +- Feature: Add grafana provisioning to this module. [\#120](https://github.com/voxpupuli/puppet-grafana/pull/120) ([drshawnkwang](https://github.com/drshawnkwang)) + ## [v4.4.1](https://github.com/voxpupuli/puppet-grafana/tree/v4.4.1) (2018-07-04) [Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.4.0...v4.4.1) diff --git a/metadata.json b/metadata.json index 65427efd1..1357ec5fa 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.4.2-rc0", + "version": "4.5.0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From dab530f39e6ffc38e14b43bc9d523fcc9710296e Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 16 Jul 2018 09:47:00 +0200 Subject: [PATCH 135/146] [blacksmith] Bump version to 4.5.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 1357ec5fa..5e26c43e7 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-grafana", - "version": "4.5.0", + "version": "4.5.1-rc0", "author": "Vox Pupuli", "summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.", "license": "Apache-2.0", From 387cd4468fcbf4517dbeb3bb9017e3c86308bf8d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 25 Jul 2018 21:36:23 +0200 Subject: [PATCH 136/146] modulesync 1.9.4 --- .msync.yml | 2 +- .travis.yml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.msync.yml b/.msync.yml index c39f6b7d7..1115a3fb8 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.3' +modulesync_config_version: '1.9.4' diff --git a/.travis.yml b/.travis.yml index 9cf5ccd79..13131606b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,8 @@ sudo: false dist: trusty language: ruby cache: bundler -# related to https://github.com/rubygems/rubygems/issues/2123 before_install: - - 'rm -f Gemfile.lock' - - 'gem update --system' - - 'gem install bundler' + - rm -f Gemfile.lock script: - 'bundle exec rake $CHECK' matrix: From 918857167f1c9d7f6994174026c383cfd5ea8b96 Mon Sep 17 00:00:00 2001 From: Borja Garrido Date: Tue, 24 Jul 2018 16:05:14 +0200 Subject: [PATCH 137/146] Parametrize provisioning files names --- manifests/config.pp | 6 ++--- manifests/init.pp | 56 +++++++++++++++++++++++++++------------------ manifests/params.pp | 26 +++++++++++---------- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 96bc7322c..71cce61a0 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -83,7 +83,7 @@ # If grafana version is > 5.0.0, and the install method is package, # repo, or archive, then use the provisioning feature. Dashboards # and datasources are placed in - # /etc/grafana/provisioning/[dashboards|datasources]. + # /etc/grafana/provisioning/[dashboards|datasources] by default. # --dashboards-- if ((versioncmp($grafana::version, '5.0.0') >= 0) and ($myprovision)) { $pdashboards = $grafana::provisioning_dashboards @@ -91,7 +91,7 @@ $dashboardpaths = flatten(grafana::deep_find_and_remove('options', $pdashboards)) # template uses: # - pdashboards - file { '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml': + file { $grafana::provisioning_dashboards_file: ensure => file, owner => 'grafana', group => 'grafana', @@ -130,7 +130,7 @@ if (length($pdatasources) >= 1) { # template uses: # - pdatasources - file { '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml': + file { $grafana::provisioning_datasources_file: ensure => file, owner => 'grafana', group => 'grafana', diff --git a/manifests/init.pp b/manifests/init.pp index b2c05cf2d..b7c498c61 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -76,6 +76,16 @@ # required. Hash will be converted into YAML and used by granfana to # configure datasources. # +# [*provisioning_dashboards_file*] +# String with the fully qualified path to place the provisioning file +# for dashboards, only used if provisioning_dashboards is specified. +# Defaults to '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml' +# +# [*provisioning_datasources_file*] +# String with the fully qualified path to place the provisioning file +# for datasources, only used if provisioning_datasources is specified. +# Default to '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml' +# # [*create_subdirs_provisioning*] # Boolean, defaults to false. If true puppet will create any # subdirectories in the given path when provisioning dashboards. @@ -97,28 +107,30 @@ # } # class grafana ( - Optional[String] $archive_source = undef, - String $cfg_location = $::grafana::params::cfg_location, - Hash $cfg = $::grafana::params::cfg, - Optional[Hash] $ldap_cfg = undef, - Boolean $container_cfg = $::grafana::params::container_cfg, - Hash $container_params = $::grafana::params::container_params, - String $data_dir = $::grafana::params::data_dir, - String $install_dir = $::grafana::params::install_dir, - String $install_method = $::grafana::params::install_method, - Boolean $manage_package_repo = $::grafana::params::manage_package_repo, - String $package_name = $::grafana::params::package_name, - Optional[String] $package_source = undef, - Enum['stable', 'testing'] $repo_name = $::grafana::params::repo_name, - String $rpm_iteration = $::grafana::params::rpm_iteration, - String $service_name = $::grafana::params::service_name, - String $version = $::grafana::params::version, - Hash $plugins = {}, - Hash $provisioning_dashboards = {}, - Hash $provisioning_datasources = {}, - Boolean $create_subdirs_provisioning = $::grafana::params::create_subdirs_provisioning, - Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location, - Optional[Hash] $sysconfig = undef, + Optional[String] $archive_source = undef, + String $cfg_location = $::grafana::params::cfg_location, + Hash $cfg = $::grafana::params::cfg, + Optional[Hash] $ldap_cfg = undef, + Boolean $container_cfg = $::grafana::params::container_cfg, + Hash $container_params = $::grafana::params::container_params, + String $data_dir = $::grafana::params::data_dir, + String $install_dir = $::grafana::params::install_dir, + String $install_method = $::grafana::params::install_method, + Boolean $manage_package_repo = $::grafana::params::manage_package_repo, + String $package_name = $::grafana::params::package_name, + Optional[String] $package_source = undef, + Enum['stable', 'testing'] $repo_name = $::grafana::params::repo_name, + String $rpm_iteration = $::grafana::params::rpm_iteration, + String $service_name = $::grafana::params::service_name, + String $version = $::grafana::params::version, + Hash $plugins = {}, + Hash $provisioning_dashboards = {}, + Hash $provisioning_datasources = {}, + String $provisioning_dashboards_file = $::grafana::params::provisioning_dashboards_file, + String $provisioning_datasources_file = $::grafana::params::provisioning_datasources_file, + Boolean $create_subdirs_provisioning = $::grafana::params::create_subdirs_provisioning, + Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location, + Optional[Hash] $sysconfig = undef, ) inherits grafana::params { contain grafana::install diff --git a/manifests/params.pp b/manifests/params.pp index 410416782..9e92700d6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,18 +4,20 @@ # It sets variables according to platform # class grafana::params { - $cfg = {} - $container_cfg = false - $container_params = {} - $data_dir = '/var/lib/grafana' - $docker_image = 'grafana/grafana' - $docker_ports = '3000:3000' - $install_dir = '/usr/share/grafana' - $package_name = 'grafana' - $rpm_iteration = '1' - $repo_name = 'stable' - $version = '4.5.1' - $create_subdirs_provisioning = false + $cfg = {} + $container_cfg = false + $container_params = {} + $data_dir = '/var/lib/grafana' + $docker_image = 'grafana/grafana' + $docker_ports = '3000:3000' + $install_dir = '/usr/share/grafana' + $package_name = 'grafana' + $rpm_iteration = '1' + $repo_name = 'stable' + $version = '4.5.1' + $create_subdirs_provisioning = false + $provisioning_dashboards_file = '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml' + $provisioning_datasources_file = '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml' case $facts['os']['family'] { 'Archlinux': { $manage_package_repo = false From 8043840be54362edc526d0acb905ccff6ecac31d Mon Sep 17 00:00:00 2001 From: Borja Garrido Date: Tue, 24 Jul 2018 16:09:12 +0200 Subject: [PATCH 138/146] Update documentation about provisioning paths --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aa7f3cb41..5717a505f 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,20 @@ which is not part of grafana's syntax. This option will be extracted from the hash, and used to "source" a directory of dashboards. See **Advanced Usage** for details. +#### `provisioning_dashboards_file` + +A String that is used as the target file name for the dashabords +provisioning file. This way the module can be used to generate placeholder +files so password can be sepecified in a different iteration, avoiding them +to be put in the module code. + +#### `provisioning_datasources_file` + +A String that is used as the target file name for the datasources +provisioning file. This way the module can be used to generate placeholder +files so password can be sepecified in a different iteration, avoiding them +to be put in the module code. + ##### `rpm_iteration` Used when installing Grafana from package ('package' or 'repo' install methods) @@ -641,7 +655,7 @@ provisioning](http://docs.grafana.org/administration/provisioning/). This module will provision grafana by placing yaml files into `/etc/grafana/provisioning/datasources` and -`/etc/grafana/provisioning/dashboards`. +`/etc/grafana/provisioning/dashboards` by default. ##### Example datasource @@ -682,7 +696,7 @@ grafana::provisioning_datasources: An example puppet hash for provisioning dashboards. The module will place the hash as a yaml file into -`/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml`. More details follow the examples. +`/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml` by default. More details follow the examples. ```puppet class { 'grafana': From 80ca0ce1a8a77ab5dd28238be63d9fce95a2dbe8 Mon Sep 17 00:00:00 2001 From: Borja Garrido Date: Tue, 24 Jul 2018 16:13:19 +0200 Subject: [PATCH 139/146] Add acceptance test for provisioning paths --- spec/acceptance/class_spec.rb | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 60396cd83..3a959aaab 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -63,4 +63,47 @@ class { 'grafana': apply_manifest(pp, catch_changes: true) end end + + context 'with fancy dashboard config and custom target file' do + it 'works idempotently with no errors' do + pp = <<-EOS + class { 'grafana': + provisioning_datasources => { + apiVersion => 1, + datasources => [ + { + name => 'Prometheus', + type => 'prometheus', + access => 'proxy', + url => 'http://localhost:9090/prometheus', + isDefault => true, + }, + ], + }, + provisioning_dashboards => { + apiVersion => 1, + providers => [ + { + name => 'default', + orgId => 1, + fiolder => '', + type => 'file', + disableDeletion => true, + options => { + path => '/var/lib/grafana/dashboards', + puppetsource => 'puppet:///modules/my_custom_module/dashboards', + }, + }, + ], + }, + provisioning_dashboards_file => '/opt/grafana/conf/provisioning/dashboards/dashboard.yaml', + provisioning_datasources_file => '/opt/grafana/conf/provisioning/datasources/datasources.yaml' + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + end end From 18f56994764fbe613dfa878cb411ea96a7d39213 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 13 Aug 2018 22:33:50 +0200 Subject: [PATCH 140/146] modulesync 1.9.6 --- .msync.yml | 2 +- .travis.yml | 4 ++-- Gemfile | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.msync.yml b/.msync.yml index 1115a3fb8..c632e462e 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.4' +modulesync_config_version: '1.9.6' diff --git a/.travis.yml b/.travis.yml index 13131606b..b273d3c14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,13 +28,13 @@ matrix: - rvm: 2.5.1 bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker services: docker sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker services: docker sudo: required branches: diff --git a/Gemfile b/Gemfile index e7d7e074d..d0df621f6 100644 --- a/Gemfile +++ b/Gemfile @@ -54,9 +54,11 @@ group :system_tests do end gem 'serverspec', :require => false gem 'beaker-hostgenerator', '>= 1.1.10', :require => false + gem 'beaker-docker', :require => false + gem 'beaker-puppet', :require => false gem 'beaker-puppet_install_helper', :require => false gem 'beaker-module_install_helper', :require => false - gem 'rbnacl', '~> 4', :require => false if RUBY_VERSION >= '2.2.6' + gem 'rbnacl', '>= 4', :require => false if RUBY_VERSION >= '2.2.6' gem 'rbnacl-libsodium', :require => false if RUBY_VERSION >= '2.2.6' gem 'bcrypt_pbkdf', :require => false end From 9e241292bb6125202bd660106527942aa38890da Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 13 Aug 2018 22:36:48 +0200 Subject: [PATCH 141/146] update spec_helper_acceptance --- spec/spec_helper_acceptance.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index f60ee4a59..9b76b7f2f 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,4 +1,5 @@ require 'beaker-rspec' +require 'beaker-puppet' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' @@ -7,7 +8,7 @@ install_module_dependencies # Install additional modules for soft deps -install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 5.0.0') +install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 6.0.0') RSpec.configure do |c| # Readable test descriptions From d4d665c0533f6c12c00b2e99026d1b37017762b4 Mon Sep 17 00:00:00 2001 From: Raffaela Wuest Date: Wed, 15 Aug 2018 13:43:27 +0200 Subject: [PATCH 142/146] added optional --repo option to grafana_cli plugin install --- README.md | 9 ++++++++ .../provider/grafana_plugin/grafana_cli.rb | 7 ++++++- lib/puppet/type/grafana_plugin.rb | 16 ++++++++++++++ spec/acceptance/grafana_plugin_spec.rb | 21 +++++++++++++++++++ spec/classes/grafana_spec.rb | 7 ++++++- .../grafana_plugin/grafana_cli_spec.rb | 14 +++++++++++++ spec/unit/puppet/type/grafana_plugin_spec.rb | 5 +++++ 7 files changed, 77 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5717a505f..9f4ae5fe4 100644 --- a/README.md +++ b/README.md @@ -631,6 +631,15 @@ grafana_plugin { 'grafana-simple-json-datasource': } ``` +It is possible to specify a custom plugin repository to install a plugin. This will use the --repo option for plugin installation with grafana_cli. + +```puppet +grafana_plugin { 'grafana-simple-json-datasource': + ensure => present, + repo => 'https://nexus.company.com/grafana/plugins', +} +``` + ##### `grafana::user` Creates and manages a global grafana user via the API. diff --git a/lib/puppet/provider/grafana_plugin/grafana_cli.rb b/lib/puppet/provider/grafana_plugin/grafana_cli.rb index 153e1b1ce..41fb01b4b 100644 --- a/lib/puppet/provider/grafana_plugin/grafana_cli.rb +++ b/lib/puppet/provider/grafana_plugin/grafana_cli.rb @@ -45,7 +45,12 @@ def exists? end def create - grafana_cli('plugins', 'install', resource[:name]) + if resource[:repo] + repo = "--repo #{resource[:repo]}" + grafana_cli(repo, 'plugins', 'install', resource[:name]) + else + grafana_cli('plugins', 'install', resource[:name]) + end @property_hash[:ensure] = :present end diff --git a/lib/puppet/type/grafana_plugin.rb b/lib/puppet/type/grafana_plugin.rb index 4f2d95572..8832af817 100644 --- a/lib/puppet/type/grafana_plugin.rb +++ b/lib/puppet/type/grafana_plugin.rb @@ -5,6 +5,12 @@ @example Install a grafana plugin grafana_plugin { 'grafana-simple-json-datasource': } +@example Install a grafana plugin from different repo + grafana_plugin { 'grafana-simple-json-datasource': + ensure => present, + repo => 'https://nexus.company.com/grafana/plugins', + } + @example Uninstall a grafana plugin grafana_plugin { 'grafana-simple-json-datasource': ensure => absent, @@ -28,4 +34,14 @@ desc 'The name of the plugin to enable' newvalues(%r{^\S+$}) end + + newparam(:repo) do + desc 'The URL of an internal plugin server' + + validate do |value| + unless value =~ %r{^https?://} + raise ArgumentError, format('%s is not a valid URL', value) + end + end + end end diff --git a/spec/acceptance/grafana_plugin_spec.rb b/spec/acceptance/grafana_plugin_spec.rb index 49bdde3d9..2781b9721 100644 --- a/spec/acceptance/grafana_plugin_spec.rb +++ b/spec/acceptance/grafana_plugin_spec.rb @@ -17,6 +17,27 @@ class { 'grafana':} end end end + + context 'create plugin resource with repo' do + it 'runs successfully' do + pp = <<-EOS + class { 'grafana':} + grafana_plugin { 'grafana-simple-json-datasource': + ensure => present, + repo => 'https://nexus.company.com/grafana/plugins', + } + EOS + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + + it 'has the plugin' do + shell('grafana-cli plugins ls') do |r| + expect(r.stdout).to match(%r{grafana-simple-json-datasource}) + end + end + end + context 'destroy plugin resource' do it 'runs successfully' do pp = <<-EOS diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 9237efa67..b7df042d4 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -79,13 +79,18 @@ plugins: { 'grafana-wizzle' => { 'ensure' => 'present' }, - 'grafana-woozle' => { 'ensure' => 'absent' } + 'grafana-woozle' => { 'ensure' => 'absent' }, + 'grafana-plugin' => { 'ensure' => 'present', 'repo' => 'https://nexus.company.com/grafana/plugins' } } } end it { is_expected.to contain_grafana_plugin('grafana-wizzle').with(ensure: 'present') } it { is_expected.to contain_grafana_plugin('grafana-woozle').with(ensure: 'absent').that_notifies('Class[grafana::service]') } + + describe 'install plugin with pluginurl' do + it { is_expected.to contain_grafana_plugin('grafana-plugin').with(ensure: 'present', repo: 'https://nexus.company.com/grafana/plugins') } + end end context 'with parameter install_method is set to repo' do diff --git a/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb b/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb index 3c6914a08..e19ea2ad1 100644 --- a/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb +++ b/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb @@ -50,4 +50,18 @@ provider.expects(:grafana_cli).with('plugins', 'uninstall', 'grafana-wizzle') provider.destroy end + + describe 'create with repo' do + let(:resource) do + Puppet::Type::Grafana_plugin.new( + name: 'grafana-plugin', + repo: 'https://nexus.company.com/grafana/plugins' + ) + end + + it '#create with repo' do + provider.expects(:grafana_cli).with('--repo https://nexus.company.com/grafana/plugins', 'plugins', 'install', 'grafana-plugin') + provider.create + end + end end diff --git a/spec/unit/puppet/type/grafana_plugin_spec.rb b/spec/unit/puppet/type/grafana_plugin_spec.rb index 29e7ea50f..100c0ff91 100644 --- a/spec/unit/puppet/type/grafana_plugin_spec.rb +++ b/spec/unit/puppet/type/grafana_plugin_spec.rb @@ -13,4 +13,9 @@ Puppet::Type.type(:grafana_plugin).new({}) end.to raise_error(Puppet::Error, 'Title or name must be provided') end + + it 'accepts a plugin repo' do + plugin[:repo] = 'https://nexus.company.com/grafana/plugins' + expect(plugin[:repo]).to eq('https://nexus.company.com/grafana/plugins') + end end From d783ed61c2729b30c1ef3b1588d5c77cefc9e269 Mon Sep 17 00:00:00 2001 From: Matthias Baur Date: Tue, 17 Jul 2018 13:30:37 +0200 Subject: [PATCH 143/146] Change default of version parameter to 'installed' Fixes GH-125. --- README.md | 3 +-- manifests/init.pp | 4 ++-- manifests/params.pp | 2 +- spec/acceptance/class_spec.rb | 11 +++++++---- spec/classes/grafana_spec.rb | 10 ++++++---- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9f4ae5fe4..ff46080b2 100644 --- a/README.md +++ b/README.md @@ -342,8 +342,7 @@ Defaults to 'grafana-server'. ##### `version` -The version of Grafana to install and manage. Defaults to the latest version of -Grafana available at the time of module release. +The version of Grafana to install and manage. Defaults to 'installed' ##### `sysconfig_location` diff --git a/manifests/init.pp b/manifests/init.pp index b7c498c61..302b589e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,7 +54,7 @@ # # [*version*] # The version of Grafana to install and manage. -# Defaults to the latest version of Grafana available at the time of module release. +# Defaults to 'installed' # # [*repo_name*] # When using 'repo' install_method, the repo to look for packages in. @@ -122,7 +122,7 @@ Enum['stable', 'testing'] $repo_name = $::grafana::params::repo_name, String $rpm_iteration = $::grafana::params::rpm_iteration, String $service_name = $::grafana::params::service_name, - String $version = $::grafana::params::version, + String $version = 'installed', Hash $plugins = {}, Hash $provisioning_dashboards = {}, Hash $provisioning_datasources = {}, diff --git a/manifests/params.pp b/manifests/params.pp index 9e92700d6..3d4c0affa 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -14,10 +14,10 @@ $package_name = 'grafana' $rpm_iteration = '1' $repo_name = 'stable' - $version = '4.5.1' $create_subdirs_provisioning = false $provisioning_dashboards_file = '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml' $provisioning_datasources_file = '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml' + case $facts['os']['family'] { 'Archlinux': { $manage_package_repo = false diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 3a959aaab..dfaaa70dd 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper_acceptance' describe 'grafana class' do + # Create dummy module directorty + shell('mkdir -p /etc/puppetlabs/code/environments/production/modules/my_custom_module/files/dashboards') + context 'default parameters' do # Using puppet_apply as a helper it 'works idempotently with no errors' do @@ -35,7 +38,7 @@ class { 'grafana': type => 'prometheus', access => 'proxy', url => 'http://localhost:9090/prometheus', - isDefault => true, + isDefault => false, }, ], }, @@ -76,7 +79,7 @@ class { 'grafana': type => 'prometheus', access => 'proxy', url => 'http://localhost:9090/prometheus', - isDefault => true, + isDefault => false, }, ], }, @@ -96,8 +99,8 @@ class { 'grafana': }, ], }, - provisioning_dashboards_file => '/opt/grafana/conf/provisioning/dashboards/dashboard.yaml', - provisioning_datasources_file => '/opt/grafana/conf/provisioning/datasources/datasources.yaml' + provisioning_dashboards_file => '/etc/grafana/provisioning/dashboards/dashboard.yaml', + provisioning_datasources_file => '/etc/grafana/provisioning/datasources/datasources.yaml' } EOS diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index b7df042d4..334e8b22b 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -37,7 +37,8 @@ context 'with parameter install_method is set to package' do let(:params) do { - install_method: 'package' + install_method: 'package', + version: '4.5.1' } end @@ -113,7 +114,7 @@ end describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('4.5.1') } + it { is_expected.to contain_package('grafana').with_ensure('installed') } end when 'RedHat' describe 'yum repo dependencies first' do @@ -126,7 +127,7 @@ end describe 'install the package' do - it { is_expected.to contain_package('grafana').with_ensure('4.5.1-1') } + it { is_expected.to contain_package('grafana').with_ensure('installed') } end end end @@ -167,7 +168,8 @@ context 'with parameter install_method is set to archive' do let(:params) do { - install_method: 'archive' + install_method: 'archive', + version: '4.5.1' } end From abfcc13fbefffda5c5eac3526f5dac1793ded7dc Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 26 Aug 2018 09:09:54 +0200 Subject: [PATCH 144/146] allow puppetlabs/stdlib 5.x --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 5e26c43e7..3e1613ec1 100644 --- a/metadata.json +++ b/metadata.json @@ -14,7 +14,7 @@ }, { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.20.0 < 5.0.0" + "version_requirement": ">= 4.20.0 < 6.0.0" } ], "operatingsystem_support": [ From 4b6cba4f5b431c7b8684cf725455f737c1698aa2 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 27 Aug 2018 10:28:38 +0200 Subject: [PATCH 145/146] allow puppetlabs/apt 6.x --- spec/spec_helper_acceptance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 9b76b7f2f..0f3ec5423 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -8,7 +8,7 @@ install_module_dependencies # Install additional modules for soft deps -install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 6.0.0') +install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 7.0.0') RSpec.configure do |c| # Readable test descriptions From 7248a1d7afc54889d8180d7ee024f458a163f193 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 5 Sep 2018 14:51:49 +0200 Subject: [PATCH 146/146] modulesync 2.0.0 --- .msync.yml | 2 +- .overcommit.yml | 1 + .travis.yml | 12 ++++++++++++ Gemfile | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.msync.yml b/.msync.yml index c632e462e..e1cef550d 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.6' +modulesync_config_version: '2.0.0' diff --git a/.overcommit.yml b/.overcommit.yml index 31699e747..1b03fad73 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -58,6 +58,7 @@ PrePush: enabled: true description: 'Run rake targets' targets: + - 'validate' - 'test' - 'rubocop' command: [ 'bundle', 'exec', 'rake' ] diff --git a/.travis.yml b/.travis.yml index b273d3c14..d452e35d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,12 +31,24 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required branches: only: - master diff --git a/Gemfile b/Gemfile index d0df621f6..3549a4448 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,7 @@ group :system_tests do end group :release do - gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator' if RUBY_VERSION >= '2.2.2' + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' if RUBY_VERSION >= '2.2.2' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' gem 'puppet-strings', '>= 1.0', :require => false