From cec2ab0110a851a3ba4a9c81e816a927cd6c1461 Mon Sep 17 00:00:00 2001 From: fnoop Date: Thu, 21 Sep 2017 08:40:15 +0100 Subject: [PATCH] Update puppet-grafana to 4.1.0rc0, #576 --- .../puppet-modules/grafana.bak/.fixtures.yml | 9 + .../puppet-modules/grafana.bak/.msync.yml | 1 + .../grafana.bak/.overcommit.yml | 63 +++ .../puppet-modules/grafana.bak/.pmtignore | 20 + manifests/puppet-modules/grafana.bak/.rspec | 2 + .../grafana.bak/.rspec_parallel | 1 + .../puppet-modules/grafana.bak/.rubocop.yml | 535 ++++++++++++++++++ .../puppet-modules/grafana.bak/.sync.yml | 7 + .../puppet-modules/grafana.bak/.travis.yml | 52 ++ .../puppet-modules/grafana.bak/.yardopts | 2 + .../puppet-modules/grafana.bak/CHANGELOG.md | 159 ++++++ .../grafana.bak/CONTRIBUTING.md | 83 +++ .../puppet-modules/grafana.bak/CONTRIBUTORS | 2 + manifests/puppet-modules/grafana.bak/Gemfile | 73 +++ manifests/puppet-modules/grafana.bak/LICENSE | 201 +++++++ .../puppet-modules/grafana.bak/README.md | 404 +++++++++++++ manifests/puppet-modules/grafana.bak/Rakefile | 44 ++ .../grafana.bak/examples/init.pp | 12 + .../lib/puppet/provider/grafana.rb | 81 +++ .../provider/grafana_dashboard/grafana.rb | 96 ++++ .../provider/grafana_datasource/grafana.rb | 188 ++++++ .../lib/puppet/type/grafana_dashboard.rb | 76 +++ .../lib/puppet/type/grafana_datasource.rb | 93 +++ .../grafana.bak/manifests/config.pp | 53 ++ .../grafana.bak/manifests/init.pp | 100 ++++ .../grafana.bak/manifests/install.pp | 168 ++++++ .../grafana.bak/manifests/params.pp | 41 ++ .../grafana.bak/manifests/plugin.pp | 10 + .../grafana.bak/manifests/service.pp | 46 ++ .../puppet-modules/grafana.bak/metadata.json | 73 +++ .../grafana.bak/spec/acceptance/class_spec.rb | 25 + .../acceptance/nodesets/archlinux-2-x64.yml | 13 + .../acceptance/nodesets/centos-511-x64.yml | 15 + .../spec/acceptance/nodesets/centos-6-x64.yml | 15 + .../acceptance/nodesets/centos-66-x64-pe.yml | 17 + .../acceptance/nodesets/centos-66-x64.yml | 15 + .../spec/acceptance/nodesets/centos-7-x64.yml | 15 + .../acceptance/nodesets/centos-72-x64.yml | 15 + .../acceptance/nodesets/debian-78-x64.yml | 15 + .../acceptance/nodesets/debian-82-x64.yml | 15 + .../acceptance/nodesets/docker/centos-5.yml | 19 + .../acceptance/nodesets/docker/centos-6.yml | 20 + .../acceptance/nodesets/docker/centos-7.yml | 19 + .../acceptance/nodesets/docker/debian-7.yml | 19 + .../acceptance/nodesets/docker/debian-8.yml | 21 + .../nodesets/docker/ubuntu-12.04.yml | 19 + .../nodesets/docker/ubuntu-14.04.yml | 21 + .../nodesets/docker/ubuntu-16.04.yml | 19 + .../nodesets/ec2/amazonlinux-2016091.yml | 31 + .../nodesets/ec2/image_templates.yaml | 34 ++ .../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 + .../acceptance/nodesets/fedora-24-x64.yml | 15 + .../acceptance/nodesets/fedora-25-x64.yml | 18 + .../nodesets/ubuntu-server-1204-x64.yml | 15 + .../nodesets/ubuntu-server-1404-x64.yml | 15 + .../nodesets/ubuntu-server-1604-x64.yml | 15 + .../grafana.bak/spec/classes/coverage_spec.rb | 4 + .../grafana.bak/spec/classes/grafana_spec.rb | 307 ++++++++++ .../grafana.bak/spec/default_facts.yml | 14 + .../grafana.bak/spec/defines/plugin_spec.rb | 20 + .../grafana.bak/spec/spec_helper.rb | 32 ++ .../spec/spec_helper_acceptance.rb | 24 + .../type/grafana_dashboard_type_spec.rb | 63 +++ .../type/grafana_datasource_type_spec.rb | 57 ++ .../grafana.bak/templates/config.ini.erb | 16 + .../grafana/.github/CONTRIBUTING.md | 104 ++++ .../grafana/.github/ISSUE_TEMPLATE.md | 26 + .../grafana/.github/PULL_REQUEST_TEMPLATE.md | 8 + manifests/puppet-modules/grafana/.gitignore | 20 + manifests/puppet-modules/grafana/HISTORY.md | 135 +++++ .../provider/grafana_plugin/grafana_cli.rb | 56 ++ .../puppet/provider/grafana_user/grafana.rb | 149 +++++ .../grafana/lib/puppet/type/grafana_plugin.rb | 31 + .../grafana/lib/puppet/type/grafana_user.rb | 54 ++ .../spec/acceptance/grafana_plugin_spec.rb | 38 ++ .../grafana_plugin/grafana_cli_spec.rb | 53 ++ .../unit/puppet/type/grafana_plugin_spec.rb | 16 + .../puppet/type/grafana_user_type_spec.rb | 50 ++ 81 files changed, 4548 insertions(+) create mode 100644 manifests/puppet-modules/grafana.bak/.fixtures.yml create mode 100644 manifests/puppet-modules/grafana.bak/.msync.yml create mode 100644 manifests/puppet-modules/grafana.bak/.overcommit.yml create mode 100644 manifests/puppet-modules/grafana.bak/.pmtignore create mode 100644 manifests/puppet-modules/grafana.bak/.rspec create mode 100644 manifests/puppet-modules/grafana.bak/.rspec_parallel create mode 100644 manifests/puppet-modules/grafana.bak/.rubocop.yml create mode 100644 manifests/puppet-modules/grafana.bak/.sync.yml create mode 100644 manifests/puppet-modules/grafana.bak/.travis.yml create mode 100644 manifests/puppet-modules/grafana.bak/.yardopts create mode 100644 manifests/puppet-modules/grafana.bak/CHANGELOG.md create mode 100644 manifests/puppet-modules/grafana.bak/CONTRIBUTING.md create mode 100644 manifests/puppet-modules/grafana.bak/CONTRIBUTORS create mode 100644 manifests/puppet-modules/grafana.bak/Gemfile create mode 100644 manifests/puppet-modules/grafana.bak/LICENSE create mode 100644 manifests/puppet-modules/grafana.bak/README.md create mode 100644 manifests/puppet-modules/grafana.bak/Rakefile create mode 100644 manifests/puppet-modules/grafana.bak/examples/init.pp create mode 100644 manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana.rb create mode 100644 manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_dashboard/grafana.rb create mode 100644 manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_datasource/grafana.rb create mode 100644 manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_dashboard.rb create mode 100644 manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_datasource.rb create mode 100644 manifests/puppet-modules/grafana.bak/manifests/config.pp create mode 100644 manifests/puppet-modules/grafana.bak/manifests/init.pp create mode 100644 manifests/puppet-modules/grafana.bak/manifests/install.pp create mode 100644 manifests/puppet-modules/grafana.bak/manifests/params.pp create mode 100644 manifests/puppet-modules/grafana.bak/manifests/plugin.pp create mode 100644 manifests/puppet-modules/grafana.bak/manifests/service.pp create mode 100644 manifests/puppet-modules/grafana.bak/metadata.json create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/class_spec.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/archlinux-2-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-511-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-6-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-66-x64-pe.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-66-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-7-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-72-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/debian-78-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/debian-82-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-5.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-6.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-7.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-7.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-8.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-12.04.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-14.04.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-16.04.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/image_templates.yaml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/rhel-73-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/fedora-24-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/fedora-25-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1204-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/classes/coverage_spec.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/classes/grafana_spec.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/default_facts.yml create mode 100644 manifests/puppet-modules/grafana.bak/spec/defines/plugin_spec.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/spec_helper.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/spec_helper_acceptance.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_dashboard_type_spec.rb create mode 100644 manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_datasource_type_spec.rb create mode 100644 manifests/puppet-modules/grafana.bak/templates/config.ini.erb create mode 100644 manifests/puppet-modules/grafana/.github/CONTRIBUTING.md create mode 100644 manifests/puppet-modules/grafana/.github/ISSUE_TEMPLATE.md create mode 100644 manifests/puppet-modules/grafana/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 manifests/puppet-modules/grafana/.gitignore create mode 100644 manifests/puppet-modules/grafana/HISTORY.md create mode 100644 manifests/puppet-modules/grafana/lib/puppet/provider/grafana_plugin/grafana_cli.rb create mode 100644 manifests/puppet-modules/grafana/lib/puppet/provider/grafana_user/grafana.rb create mode 100644 manifests/puppet-modules/grafana/lib/puppet/type/grafana_plugin.rb create mode 100644 manifests/puppet-modules/grafana/lib/puppet/type/grafana_user.rb create mode 100644 manifests/puppet-modules/grafana/spec/acceptance/grafana_plugin_spec.rb create mode 100644 manifests/puppet-modules/grafana/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb create mode 100644 manifests/puppet-modules/grafana/spec/unit/puppet/type/grafana_plugin_spec.rb create mode 100644 manifests/puppet-modules/grafana/spec/unit/puppet/type/grafana_user_type_spec.rb diff --git a/manifests/puppet-modules/grafana.bak/.fixtures.yml b/manifests/puppet-modules/grafana.bak/.fixtures.yml new file mode 100644 index 00000000..d478d5be --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.fixtures.yml @@ -0,0 +1,9 @@ +fixtures: + repositories: + 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/puppet-modules/grafana.bak/.msync.yml b/manifests/puppet-modules/grafana.bak/.msync.yml new file mode 100644 index 00000000..4abde220 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.msync.yml @@ -0,0 +1 @@ +modulesync_config_version: '0.21.3' diff --git a/manifests/puppet-modules/grafana.bak/.overcommit.yml b/manifests/puppet-modules/grafana.bak/.overcommit.yml new file mode 100644 index 00000000..31699e74 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.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/manifests/puppet-modules/grafana.bak/.pmtignore b/manifests/puppet-modules/grafana.bak/.pmtignore new file mode 100644 index 00000000..fb589575 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.pmtignore @@ -0,0 +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/manifests/puppet-modules/grafana.bak/.rspec b/manifests/puppet-modules/grafana.bak/.rspec new file mode 100644 index 00000000..8c18f1ab --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/manifests/puppet-modules/grafana.bak/.rspec_parallel b/manifests/puppet-modules/grafana.bak/.rspec_parallel new file mode 100644 index 00000000..e4d136b7 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.rspec_parallel @@ -0,0 +1 @@ +--format progress diff --git a/manifests/puppet-modules/grafana.bak/.rubocop.yml b/manifests/puppet-modules/grafana.bak/.rubocop.yml new file mode 100644 index 00000000..d92e4e45 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.rubocop.yml @@ -0,0 +1,535 @@ +require: rubocop-rspec +AllCops: + TargetRubyVersion: 1.9 + Include: + - ./**/*.rb + Exclude: + - files/**/* + - vendor/**/* + - .vendor/**/* + - pkg/**/* + - spec/fixtures/**/* + - Gemfile + - Rakefile + - Guardfile +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 + +Security/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/MethodCallWithoutArgsParentheses: + 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 + +RSpec/BeforeAfterAll: + Exclude: + - spec/acceptance/**/* + +# 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 + +# 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 + +# 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/manifests/puppet-modules/grafana.bak/.sync.yml b/manifests/puppet-modules/grafana.bak/.sync.yml new file mode 100644 index 00000000..928d81f7 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.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/manifests/puppet-modules/grafana.bak/.travis.yml b/manifests/puppet-modules/grafana.bak/.travis.yml new file mode 100644 index 00000000..3784ed44 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.travis.yml @@ -0,0 +1,52 @@ +--- +sudo: false +dist: trusty +language: ruby +cache: bundler +before_install: + - bundle -v + - rm Gemfile.lock || true + - gem update --system + - gem update bundler + - gem --version + - bundle -v +script: + - 'bundle exec rake $CHECK' +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.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 + - rvm: 2.4.1 + bundler_args: --without system_tests development + env: PUPPET_VERSION="~> 4.0" CHECK=rubocop + - rvm: 2.4.1 + bundler_args: --without system_tests development + env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes +branches: + only: + - master + - /^v\d/ +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/manifests/puppet-modules/grafana.bak/.yardopts b/manifests/puppet-modules/grafana.bak/.yardopts new file mode 100644 index 00000000..3687f518 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/.yardopts @@ -0,0 +1,2 @@ +--markup markdown +--output-dir docs/ diff --git a/manifests/puppet-modules/grafana.bak/CHANGELOG.md b/manifests/puppet-modules/grafana.bak/CHANGELOG.md new file mode 100644 index 00000000..70cd7f6b --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/CHANGELOG.md @@ -0,0 +1,159 @@ +# 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! +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/manifests/puppet-modules/grafana.bak/CONTRIBUTING.md b/manifests/puppet-modules/grafana.bak/CONTRIBUTING.md new file mode 100644 index 00000000..be66bda8 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/CONTRIBUTING.md @@ -0,0 +1,83 @@ +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 + +1. Fork the repo. + +2. Run the tests. We only take pull requests with passing tests, and + it's great to know that you have a clean slate + +3. 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. + +4. Make the test pass. + +5. Push to your fork and submit a pull request. + + +## 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="~> 3.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 syntax + +## 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. Running the test suite is done +with: + + bundle exec rake spec + +Note also you can run the syntax, style and unit tests in one go with: + + 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.5 with. + + RS_SET=centos-64-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/manifests/puppet-modules/grafana.bak/CONTRIBUTORS b/manifests/puppet-modules/grafana.bak/CONTRIBUTORS new file mode 100644 index 00000000..c8e461e3 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/CONTRIBUTORS @@ -0,0 +1,2 @@ +bfraser +rplessl diff --git a/manifests/puppet-modules/grafana.bak/Gemfile b/manifests/puppet-modules/grafana.bak/Gemfile new file mode 100644 index 00000000..425e4941 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/Gemfile @@ -0,0 +1,73 @@ +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 '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 + 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', '~> 1.0', :require => false + gem 'redcarpet', :require => false + 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 + 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 + +group :development do + 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 + 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/manifests/puppet-modules/grafana.bak/LICENSE b/manifests/puppet-modules/grafana.bak/LICENSE new file mode 100644 index 00000000..ad410e11 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/manifests/puppet-modules/grafana.bak/README.md b/manifests/puppet-modules/grafana.bak/README.md new file mode 100644 index 00000000..9b8a5a77 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/README.md @@ -0,0 +1,404 @@ +# 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 + +1. [Overview](#overview) +1. [Module Description](#module-description) +1. [Setup](#setup) + * [Beginning with Grafana](#beginning-with-grafana) +1. [Usage](#usage) + * [Classes and Defined Types](#classes-and-defined-types) + * [Advanced usage](#advanced-usage) +1. [Limitations](#limitations) +1. [Copyright and License](#copyright-and-license) + +## Overview + +This module installs Grafana, a dashboard and graph editor for Graphite, +InfluxDB and OpenTSDB. + +## 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. + +## 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 +* Perform basic configuration of Grafana + +### Beginning with Grafana + +To install Grafana with the default parameters: + +```puppet + class { 'grafana': } +``` + +This assumes that you want to install Grafana using the 'package' method. To +establish customized parameters: + +```puppet + class { 'grafana': + install_method => 'docker', + } +``` + +## Usage + +### Classes and Defined Types + +#### Class: `grafana` + +The Grafana module's primary class, `grafana`, guides the basic setup of Grafana +on your system. + +```puppet + class { 'grafana': } +``` + +**Parameters within `grafana`:** + +##### `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. + +##### `cfg_location` + +Configures the location to which the Grafana configuration is written. The +default location is '/etc/grafana/grafana.ini'. + +##### `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. + +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': + cfg => { + app_mode => 'production', + server => { + http_port => 8080, + }, + database => { + type => 'sqlite3', + host => '127.0.0.1:3306', + name => 'grafana', + user => 'root', + password => '', + }, + users => { + allow_sign_up => false, + }, + }, + } +``` + +...the following Grafana configuration: + +```ini +# This file is managed by Puppet, any changes will be overwritten + +app_mode = production + +[server] +http_port = 8080 + +[database] +type = sqlite3 +host = 127.0.0.1:3306 +name = grafana +user = root +password = + +[users] +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. + +#### `ldap_cfg` + +##### 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 + # PE apply + /opt/puppet/bin/gem install toml + # AIO or PE puppetserver + /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: + +``` +'auth.ldap' => { + enabled => 'true', + config_file => '/etc/grafana/ldap.toml', +}, +``` + +#### 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. + +See the [LDAP documentation](http://docs.grafana.org/v2.1/installation/ldap/) +for more information. + +#### Example LDAP config + +``` +ldap_cfg => { + servers => [ + { host => 'ldapserver1.domain1.com', + port => 636+0, + use_ssl => true, + search_filter => '(sAMAccountName=%s)', + search_base_dns => [ 'dc=domain1,dc=com' ], + bind_dn => 'user@domain1.com', + bind_password => 'passwordhere', + }, + ], + 'servers.attributes' => { + name => 'givenName', + surname => 'sn', + username => 'sAMAccountName', + member_of => 'memberOf', + email => 'email', + } +}, +``` + +##### `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. + +##### `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: + +```puppet +container_params => { + 'image' => 'grafana/grafana:latest', + 'ports' => '3000:3000' +} +``` + +##### `data_dir` + +The directory Grafana will use for storing its data. Defaults to '/var/lib/grafana'. + +##### `install_dir` + +The installation directory to be used with the 'archive' install method. Defaults +to '/usr/share/grafana'. + +##### `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. + +##### `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. + +##### `package_name` + +The name of the package managed with the 'package' install method. Defaults to +'grafana'. + +##### `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. + +##### `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. + +##### `service_name` + +The name of the service managed with the 'archive' and 'package' install methods. +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. + +### 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':} + +Example: + +```puppet + user { 'grafana': + ensure => present, + uid => '1234', + } + -> + class { 'grafana': + install_method => 'archive', + } + + include sensu_install::grafana::service + + # run your service after install/config but before grafana::service + Class[::grafana::install] + -> + Class[sensu_install::grafana::service] + -> + Class[::grafana::service] + +``` + +#### Custom Types and Providers + +The module includes two custom types: `grafana_dashboard` and `grafana_datasource` + +##### `grafana_dashboard` + +In order to use the dashboard resource, add the following to your manifest: + +```puppet +grafana_dashboard { 'example_dashboard': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => '5ecretPassw0rd', + 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_datasource` + +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', + 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'), +} +``` + +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. + +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' +and 'package' installation methods. Other configurations should work with minimal, +if any, additional effort. + +## Copyright and License + +Copyright (C) 2015 Bill Fraser + +Bill can be contacted at: fraser@pythian.com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + + +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. diff --git a/manifests/puppet-modules/grafana.bak/Rakefile b/manifests/puppet-modules/grafana.bak/Rakefile new file mode 100644 index 00000000..82c89608 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/Rakefile @@ -0,0 +1,44 @@ +require 'puppetlabs_spec_helper/rake_tasks' +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' +RSpec::Core::RakeTask.new(:acceptance) do |t| + t.pattern = 'spec/acceptance' +end + +desc 'Run tests metadata_lint, release_checks' +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 = "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 +rescue LoadError +end +# vim: syntax=ruby diff --git a/manifests/puppet-modules/grafana.bak/examples/init.pp b/manifests/puppet-modules/grafana.bak/examples/init.pp new file mode 100644 index 00000000..ddf3cc94 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/examples/init.pp @@ -0,0 +1,12 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# http://docs.puppetlabs.com/guides/tests_smoke.html +# +include ::grafana diff --git a/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana.rb b/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana.rb new file mode 100644 index 00000000..2229f852 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana.rb @@ -0,0 +1,81 @@ +# 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' + +class Puppet::Provider::Grafana < Puppet::Provider + # Helper methods + def grafana_host + @grafana_host = URI.parse(resource[:grafana_url]).host unless @grafana_host + @grafana_host + 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 + end + + # 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 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, format('Unsupported HTTP operation %s', operation) + end + + request.content_type = 'application/json' + if resource[:grafana_user] && resource[:grafana_user] + request.basic_auth resource[:grafana_user], resource[:grafana_password] + 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/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_dashboard/grafana.rb b/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_dashboard/grafana.rb new file mode 100644 index 00000000..fb215d98 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_dashboard/grafana.rb @@ -0,0 +1,96 @@ +# 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')) + +# 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 = 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 + + begin + JSON.parse(response.body) + rescue JSON::ParserError + raise format('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 + return unless dashboards.find { |x| x['title'] == resource[:title] } + + 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 + + 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{[ \+]+}, '-').gsub(%r{[^\w\- ]}, '') + end + + def content + @dashboard.reject { |k, _| k =~ %r{^id|version|title$} } + end + + def content=(value) + save_dashboard(value) + end + + def create + save_dashboard(resource[:content]) + end + + def destroy + 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) + end + + def exists? + find_dashboard + end +end diff --git a/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_datasource/grafana.rb b/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_datasource/grafana.rb new file mode 100644 index 00000000..79d7d5de --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/lib/puppet/provider/grafana_datasource/grafana.rb @@ -0,0 +1,188 @@ +# 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')) + +Puppet::Type.type(:grafana_datasource).provide(:grafana, parent: Puppet::Provider::Grafana) do + desc 'Support for Grafana datasources' + + defaultfor kernel: 'Linux' + + 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 + + begin + datasources = JSON.parse(response.body) + + 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) + 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 + + # rubocop:disable Style/PredicateName + def is_default + datasource[:is_default] + end + + def is_default=(value) + resource[:is_default] = value + save_datasource + end + # rubocop:enable Style/PredicateName + + 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 'PUT', format('/api/datasources/%s', 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 + self.datasource = nil + end + + def delete_datasource + 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) + end + self.datasource = nil + end + + def create + save_datasource + end + + def destroy + delete_datasource + end + + def exists? + datasource + end +end diff --git a/manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_dashboard.rb b/manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_dashboard.rb new file mode 100644 index 00000000..96cdd9b9 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_dashboard.rb @@ -0,0 +1,76 @@ +# 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 + @doc = 'Manage dashboards in Grafana' + + ensurable + + newparam(:title, namevar: true) do + desc 'The title of the dashboard.' + end + + 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 + + munge do |value| + new_value = JSON.parse(value).reject { |k, _| k =~ %r{^id|version|title$} } + new_value.sort.to_h + end + + def should_to_s(value) + if value.length > 12 + "#{value.to_s.slice(0, 12)}..." + else + value + end + end + 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 (optional)' + end + + newparam(:grafana_password) do + desc 'The password for the Grafana server (optional)' + 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/manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_datasource.rb b/manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_datasource.rb new file mode 100644 index 00000000..6cb41324 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/lib/puppet/type/grafana_datasource.rb @@ -0,0 +1,93 @@ +# 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' + + 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 =~ %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(: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' + 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/manifests/puppet-modules/grafana.bak/manifests/config.pp b/manifests/puppet-modules/grafana.bak/manifests/config.pp new file mode 100644 index 00000000..725b10d9 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/manifests/config.pp @@ -0,0 +1,53 @@ +# == Class grafana::config +# +# This class is called from grafana +# +class grafana::config { + case $::grafana::install_method { + 'docker': { + if $::grafana::container_cfg { + $cfg = $::grafana::cfg + + file { $::grafana::cfg_location: + ensure => file, + content => template('grafana/config.ini.erb'), + owner => 'grafana', + group => 'grafana', + } + } + } + 'package','repo': { + $cfg = $::grafana::cfg + + file { $::grafana::cfg_location: + ensure => file, + content => template('grafana/config.ini.erb'), + owner => 'grafana', + group => 'grafana', + } + } + 'archive': { + $cfg = $::grafana::cfg + + file { "${::grafana::install_dir}/conf/custom.ini": + ensure => file, + content => template('grafana/config.ini.erb'), + owner => 'grafana', + group => 'grafana', + } + } + default: { + fail("Installation method ${::grafana::install_method} not supported") + } + } + + if $::grafana::ldap_cfg { + $ldap_cfg = $::grafana::ldap_cfg + file { '/etc/grafana/ldap.toml': + ensure => file, + content => inline_template("<%= require 'toml'; TOML::Generator.new(@ldap_cfg).body %>\n"), + owner => 'grafana', + group => 'grafana', + } + } +} diff --git a/manifests/puppet-modules/grafana.bak/manifests/init.pp b/manifests/puppet-modules/grafana.bak/manifests/init.pp new file mode 100644 index 00000000..d68a3928 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/manifests/init.pp @@ -0,0 +1,100 @@ +# == Class: grafana +# +# Installs and configures Grafana. +# +# === Parameters +# [*archive_source*] +# Download location of tarball to be used with the 'archive' install method. +# Defaults to the URL of the latest version of Grafana available at the time of module release. +# +# [*container_cfg*] +# Boolean. Determines 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*] +# 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` module for details of available parameters. +# Defaults to: +# +# container_params => { +# 'image' => 'grafana/grafana:latest', +# 'ports' => '3000' +# } +# +# [*data_dir*] +# The directory Grafana will use for storing its data. +# Defaults to '/var/lib/grafana'. +# +# [*install_dir*] +# Installation directory to be used with the 'archive' install method. +# Defaults to '/usr/share/grafana'. +# +# [*install_method*] +# Set to 'archive' to install Grafana using the tar archive. +# Set to 'docker' to install Grafana using the official Docker container. +# Set to 'package' to install Grafana using .deb or .rpm packages. +# Set to 'repo' to install Grafana using an apt or yum repository. +# Defaults to 'package'. +# +# [*manage_package_repo*] +# If true this will setup the official grafana repositories on your host. Defaults to true. +# +# [*package_name*] +# The name of the package managed with the 'package' install method. +# Defaults to 'grafana'. +# +# [*package_source*] +# Download location of 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. +# +# [*service_name*] +# The name of the service managed with the 'archive' and 'package' install methods. +# 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. +# +# [*repo_name*] +# When using 'repo' install_method, the repo to look for packages in. +# Set to 'stable' to install only stable versions +# Set to 'testing' to install beta versions +# Defaults to stable. +# +# === Examples +# +# class { '::grafana': +# install_method => 'docker', +# } +# +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 +) inherits grafana::params { + + # validate parameters here + if !is_hash($cfg) { + fail('cfg parameter must be a hash') + } + + anchor { 'grafana::begin': } + -> class { '::grafana::install': } + -> class { '::grafana::config': } + ~> class { '::grafana::service': } + -> anchor { 'grafana::end': } +} diff --git a/manifests/puppet-modules/grafana.bak/manifests/install.pp b/manifests/puppet-modules/grafana.bak/manifests/install.pp new file mode 100644 index 00000000..db9a1ae0 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/manifests/install.pp @@ -0,0 +1,168 @@ +# == Class grafana::install +# +class grafana::install { + 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" + } + + if $::grafana::package_source != undef { + $real_package_source = $::grafana::package_source + } + 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", + default => $real_archive_source, + } + } + + case $::grafana::install_method { + 'docker': { + docker::image { 'grafana/grafana': + image_tag => $::grafana::version, + require => Class['docker'], + } + } + 'package': { + case $::osfamily { + 'Debian': { + package { 'libfontconfig1': + ensure => present, + } + + wget::fetch { 'grafana': + source => $real_package_source, + destination => '/var/tmp/grafana.deb', + } + + package { $::grafana::package_name: + ensure => present, + provider => 'dpkg', + source => '/var/tmp/grafana.deb', + require => [Wget::Fetch['grafana'],Package['libfontconfig1']], + } + } + 'RedHat': { + package { 'fontconfig': + ensure => present, + } + + package { $::grafana::package_name: + ensure => present, + provider => 'rpm', + source => $real_package_source, + require => Package['fontconfig'], + } + } + default: { + fail("${::operatingsystem} not supported") + } + } + } + 'repo': { + case $::osfamily { + 'Debian': { + package { 'libfontconfig1': + ensure => present, + } + + if ( $::grafana::manage_package_repo ){ + if !defined( Class['apt'] ) { + class { '::apt': } + } + apt::source { 'grafana': + location => "https://packagecloud.io/grafana/${::grafana::repo_name}/debian", + release => 'jessie', + repos => 'main', + key => { + 'id' => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB', + 'source' => 'https://packagecloud.io/gpg.key', + }, + before => Package[$::grafana::package_name], + } + Class['apt::update'] -> Package[$::grafana::package_name] + } + + package { $::grafana::package_name: + ensure => $::grafana::version, + require => Package['libfontconfig1'], + } + } + 'RedHat': { + package { 'fontconfig': + ensure => present, + } + + if ( $::grafana::manage_package_repo ){ + yumrepo { 'grafana': + descr => 'grafana repo', + 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, + before => Package[$::grafana::package_name], + } + } + + if $::grafana::version =~ /(installed|latest|present)/ { + $real_version = $::grafana::version + } else { + $real_version = "${::grafana::version}-${::grafana::rpm_iteration}" + } + + package { $::grafana::package_name: + ensure => $real_version, + require => Package['fontconfig'], + } + } + 'Archlinux': { + if $::grafana::manage_package_repo { + fail('manage_package_repo is not supported on Archlinux') + } + package { $::grafana::package_name: + ensure => 'present', # pacman provider doesn't have feature versionable + } + } + default: { + fail("${::operatingsystem} not supported") + } + } + } + 'archive': { + # create log directory /var/log/grafana (or parameterize) + + if !defined(User['grafana']){ + user { 'grafana': + ensure => present, + home => $::grafana::install_dir, + } + } + + file { $::grafana::install_dir: + ensure => directory, + group => 'grafana', + owner => 'grafana', + require => User['grafana'], + } + + archive { '/tmp/grafana.tar.gz': + ensure => present, + extract => true, + extract_command => 'tar xfz %s --strip-components=1', + extract_path => $::grafana::install_dir, + source => $real_archive_source, + user => 'grafana', + group => 'grafana', + cleanup => true, + require => File[$::grafana::install_dir], + } + + } + default: { + fail("Installation method ${::grafana::install_method} not supported") + } + } +} diff --git a/manifests/puppet-modules/grafana.bak/manifests/params.pp b/manifests/puppet-modules/grafana.bak/manifests/params.pp new file mode 100644 index 00000000..fb8aa07a --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/manifests/params.pp @@ -0,0 +1,41 @@ +# == Class grafana::params +# +# This class is meant to be called from grafana +# It sets variables according to platform +# +class grafana::params { + $archive_source = undef + $cfg = {} + $container_cfg = false + $container_params = {} + $data_dir = '/var/lib/grafana' + $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 = '2.5.0' + case $::osfamily { + 'Archlinux': { + $manage_package_repo = false + $install_method = 'repo' + $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' + $cfg_location = '/etc/grafana/grafana.ini' + $service_name = 'grafana-server' + } + } +} diff --git a/manifests/puppet-modules/grafana.bak/manifests/plugin.pp b/manifests/puppet-modules/grafana.bak/manifests/plugin.pp new file mode 100644 index 00000000..ff10a907 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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}", + } +} diff --git a/manifests/puppet-modules/grafana.bak/manifests/service.pp b/manifests/puppet-modules/grafana.bak/manifests/service.pp new file mode 100644 index 00000000..6b1b991c --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/manifests/service.pp @@ -0,0 +1,46 @@ +# == Class grafana::service +# +# This class is meant to be called from grafana +# It ensure the service is running +# +class grafana::service { + case $::grafana::install_method { + 'docker': { + $container = { + 'grafana' => $::grafana::container_params, + } + + $defaults = { + image => "${::grafana::params::docker_image}:${::grafana::version}", + ports => $::grafana::params::docker_ports, + } + + create_resources(docker::run, $container, $defaults) + } + 'package','repo': { + service { $::grafana::service_name: + ensure => running, + enable => true, + subscribe => Package[$::grafana::package_name], + } + } + 'archive': { + $service_path = "${::grafana::install_dir}/bin/${::grafana::service_name}" + $service_config = "${::grafana::install_dir}/conf/custom.ini" + + if !defined(Service[$::grafana::service_name]){ + service { $::grafana::service_name: + ensure => running, + provider => base, + 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", + } + } + } + default: { + fail("Installation method ${::grafana::install_method} not supported") + } + } +} diff --git a/manifests/puppet-modules/grafana.bak/metadata.json b/manifests/puppet-modules/grafana.bak/metadata.json new file mode 100644 index 00000000..934975e7 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/metadata.json @@ -0,0 +1,73 @@ +{ + "name": "puppet-grafana", + "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", + "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": [ + { + "name": "garethr/docker", + "version_requirement": ">= 5.0.0 < 6.0.0" + }, + { + "name": "maestrodev/wget", + "version_requirement": ">= 1.7.3 < 2.0.0" + }, + { + "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" + } + ], + "operatingsystem_support": [ + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "14.04" + ] + }, + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "6" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "6" + ] + }, + { + "operatingsystem": "Archlinux" + } + ], + "requirements": [ + { + "name": "puppet", + "version_requirement": ">= 4.6.1 < 5.0.0" + } + ], + "tags": [ + "grafana", + "graphite", + "influxdb", + "monitoring" + ] +} diff --git a/manifests/puppet-modules/grafana.bak/spec/acceptance/class_spec.rb b/manifests/puppet-modules/grafana.bak/spec/acceptance/class_spec.rb new file mode 100644 index 00000000..759ad09f --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/acceptance/class_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper_acceptance' + +describe 'grafana class' do + context 'default parameters' do + # Using puppet_apply as a helper + 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) + end + + describe package('grafana') do + it { is_expected.to be_installed } + end + + describe service('grafana') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + end +end diff --git a/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/archlinux-2-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/archlinux-2-x64.yml new file mode 100644 index 00000000..89b63003 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-511-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-511-x64.yml new file mode 100644 index 00000000..089d646a --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-6-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-6-x64.yml new file mode 100644 index 00000000..16abc8f1 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-66-x64-pe.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-66-x64-pe.yml new file mode 100644 index 00000000..1e7aea6d --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-66-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-66-x64.yml new file mode 100644 index 00000000..42455e7a --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-7-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-7-x64.yml new file mode 100644 index 00000000..e05a3ae1 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-72-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/centos-72-x64.yml new file mode 100644 index 00000000..85af89d3 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/debian-78-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/debian-78-x64.yml new file mode 100644 index 00000000..6ef6de8c --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/debian-82-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/debian-82-x64.yml new file mode 100644 index 00000000..9897a8fc --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-5.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-5.yml new file mode 100644 index 00000000..c17bc3d0 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-6.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-6.yml new file mode 100644 index 00000000..d93f884c --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-7.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-7.yml new file mode 100644 index 00000000..41e924b5 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/centos-7.yml @@ -0,0 +1,19 @@ +--- +# 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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-7.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-7.yml new file mode 100644 index 00000000..071acbf9 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-8.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-8.yml new file mode 100644 index 00000000..7a1f35c3 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/debian-8.yml @@ -0,0 +1,21 @@ +--- +# 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' + - 'systemctl mask getty@tty1.service getty-static.service' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-12.04.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-12.04.yml new file mode 100644 index 00000000..ab77cda4 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-14.04.yml new file mode 100644 index 00000000..54d5e5a5 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/docker/ubuntu-16.04.yml new file mode 100644 index 00000000..bac2d5b3 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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 locales' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml new file mode 100644 index 00000000..19dd43ed --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/image_templates.yaml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/image_templates.yaml new file mode 100644 index 00000000..e50593ee --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/rhel-73-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/rhel-73-x64.yml new file mode 100644 index 00000000..7fac8236 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml new file mode 100644 index 00000000..8542154d --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml new file mode 100644 index 00000000..9cf59d59 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml new file mode 100644 index 00000000..0932e29c --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/fedora-24-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/fedora-24-x64.yml new file mode 100644 index 00000000..820b62d2 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/fedora-25-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/fedora-25-x64.yml new file mode 100644 index 00000000..60ae0117 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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-25-x86_64 + box: fedora/25-cloud-base + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1204-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1204-x64.yml new file mode 100644 index 00000000..29102c56 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 00000000..054e6588 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml b/manifests/puppet-modules/grafana.bak/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml new file mode 100644 index 00000000..bc85e0e8 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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/manifests/puppet-modules/grafana.bak/spec/classes/coverage_spec.rb b/manifests/puppet-modules/grafana.bak/spec/classes/coverage_spec.rb new file mode 100644 index 00000000..de446548 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/classes/coverage_spec.rb @@ -0,0 +1,4 @@ +require 'rspec-puppet' + +at_exit { RSpec::Puppet::Coverage.report! } +# vim: syntax=ruby diff --git a/manifests/puppet-modules/grafana.bak/spec/classes/grafana_spec.rb b/manifests/puppet-modules/grafana.bak/spec/classes/grafana_spec.rb new file mode 100644 index 00000000..4f1e152a --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/classes/grafana_spec.rb @@ -0,0 +1,307 @@ +require 'spec_helper' + +describe 'grafana' do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + 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.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::service') } + it { is_expected.to contain_anchor('grafana::end') } + 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' + + 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 + + context 'with parameter install_method is set to repo' do + let(:params) do + { + install_method: 'repo' + } + end + + 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: 'jessie', 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/' + 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 + + 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 + + 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 + + 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 + when 'Archlinux' + describe 'install the package' do + it { is_expected.to contain_package('grafana').with_ensure('present') } + end + end + end + + context 'with parameter install_method is set to archive' 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('file') } + end + + describe 'run grafana as service' do + 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 + 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 '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 + + 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 + { + cfg: {} + } + end + + it { is_expected.to contain_package('grafana') } + end + end + end + + context 'configuration file' do + describe 'should not contain any configuration when cfg param is empty' do + 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 + 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' + } + } + } + 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(config_path).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 + end +end diff --git a/manifests/puppet-modules/grafana.bak/spec/default_facts.yml b/manifests/puppet-modules/grafana.bak/spec/default_facts.yml new file mode 100644 index 00000000..13c41657 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/default_facts.yml @@ -0,0 +1,14 @@ +# 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" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/manifests/puppet-modules/grafana.bak/spec/defines/plugin_spec.rb b/manifests/puppet-modules/grafana.bak/spec/defines/plugin_spec.rb new file mode 100644 index 00000000..6b1fb995 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/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 diff --git a/manifests/puppet-modules/grafana.bak/spec/spec_helper.rb b/manifests/puppet-modules/grafana.bak/spec/spec_helper.rb new file mode 100644 index 00000000..2aa9da74 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/spec_helper.rb @@ -0,0 +1,32 @@ +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts + +if Dir.exist?(File.expand_path('../../lib', __FILE__)) + 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 diff --git a/manifests/puppet-modules/grafana.bak/spec/spec_helper_acceptance.rb b/manifests/puppet-modules/grafana.bak/spec/spec_helper_acceptance.rb new file mode 100644 index 00000000..3882833d --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/spec_helper_acceptance.rb @@ -0,0 +1,24 @@ +require 'beaker-rspec/spec_helper' +require 'beaker-rspec/helpers/serverspec' + +hosts.each do |_host| # rubocop: disable RSpec/IteratedExpectation + # Install Puppet + install_puppet +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # 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 diff --git a/manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_dashboard_type_spec.rb b/manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_dashboard_type_spec.rb new file mode 100644 index 00000000..18f9a88e --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_dashboard_type_spec.rb @@ -0,0 +1,63 @@ +# 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 'spec_helper' + +describe Puppet::Type.type(:grafana_dashboard) do + 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 "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 "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 + + # 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 '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 gdashboard + + relationship = gdashboard.autorequire.find do |rel| + (rel.source.to_s == 'Service[grafana-server]') && (rel.target.to_s == gdashboard.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 gdashboard + expect(gdashboard.autorequire).to be_empty + end + end +end diff --git a/manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_datasource_type_spec.rb b/manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_datasource_type_spec.rb new file mode 100644 index 00000000..8688f4b3 --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/spec/unit/puppet/type/grafana_datasource_type_spec.rb @@ -0,0 +1,57 @@ +# 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 'spec_helper' + +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' + 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 "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 + + # 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 '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 gdatasource + + relationship = gdatasource.autorequire.find do |rel| + (rel.source.to_s == 'Service[grafana-server]') && (rel.target.to_s == gdatasource.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 gdatasource + expect(gdatasource.autorequire).to be_empty + end + end +end diff --git a/manifests/puppet-modules/grafana.bak/templates/config.ini.erb b/manifests/puppet-modules/grafana.bak/templates/config.ini.erb new file mode 100644 index 00000000..f29c57db --- /dev/null +++ b/manifests/puppet-modules/grafana.bak/templates/config.ini.erb @@ -0,0 +1,16 @@ +# 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) -%> + +[<%= key %>] + <%- @cfg[key].keys.sort.each do |valkey| -%> +<%= valkey %> = <%= @cfg[key][valkey] %> + <%- end -%> + <%- end +end -%> diff --git a/manifests/puppet-modules/grafana/.github/CONTRIBUTING.md b/manifests/puppet-modules/grafana/.github/CONTRIBUTING.md new file mode 100644 index 00000000..602f324b --- /dev/null +++ b/manifests/puppet-modules/grafana/.github/CONTRIBUTING.md @@ -0,0 +1,104 @@ +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`. + +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/manifests/puppet-modules/grafana/.github/ISSUE_TEMPLATE.md b/manifests/puppet-modules/grafana/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..593e7aa8 --- /dev/null +++ b/manifests/puppet-modules/grafana/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,26 @@ + + +## 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/manifests/puppet-modules/grafana/.github/PULL_REQUEST_TEMPLATE.md b/manifests/puppet-modules/grafana/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..66f80444 --- /dev/null +++ b/manifests/puppet-modules/grafana/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ + diff --git a/manifests/puppet-modules/grafana/.gitignore b/manifests/puppet-modules/grafana/.gitignore new file mode 100644 index 00000000..e9b3cf4b --- /dev/null +++ b/manifests/puppet-modules/grafana/.gitignore @@ -0,0 +1,20 @@ +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/ +Guardfile diff --git a/manifests/puppet-modules/grafana/HISTORY.md b/manifests/puppet-modules/grafana/HISTORY.md new file mode 100644 index 00000000..f7ccd886 --- /dev/null +++ b/manifests/puppet-modules/grafana/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/manifests/puppet-modules/grafana/lib/puppet/provider/grafana_plugin/grafana_cli.rb b/manifests/puppet-modules/grafana/lib/puppet/provider/grafana_plugin/grafana_cli.rb new file mode 100644 index 00000000..153e1b1c --- /dev/null +++ b/manifests/puppet-modules/grafana/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/manifests/puppet-modules/grafana/lib/puppet/provider/grafana_user/grafana.rb b/manifests/puppet-modules/grafana/lib/puppet/provider/grafana_user/grafana.rb new file mode 100644 index 00000000..fc8b79ca --- /dev/null +++ b/manifests/puppet-modules/grafana/lib/puppet/provider/grafana_user/grafana.rb @@ -0,0 +1,149 @@ +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/manifests/puppet-modules/grafana/lib/puppet/type/grafana_plugin.rb b/manifests/puppet-modules/grafana/lib/puppet/type/grafana_plugin.rb new file mode 100644 index 00000000..4f2d9557 --- /dev/null +++ b/manifests/puppet-modules/grafana/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/puppet-modules/grafana/lib/puppet/type/grafana_user.rb b/manifests/puppet-modules/grafana/lib/puppet/type/grafana_user.rb new file mode 100644 index 00000000..6714dac5 --- /dev/null +++ b/manifests/puppet-modules/grafana/lib/puppet/type/grafana_user.rb @@ -0,0 +1,54 @@ +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/manifests/puppet-modules/grafana/spec/acceptance/grafana_plugin_spec.rb b/manifests/puppet-modules/grafana/spec/acceptance/grafana_plugin_spec.rb new file mode 100644 index 00000000..49bdde3d --- /dev/null +++ b/manifests/puppet-modules/grafana/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/manifests/puppet-modules/grafana/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb b/manifests/puppet-modules/grafana/spec/unit/puppet/provider/grafana_plugin/grafana_cli_spec.rb new file mode 100644 index 00000000..3c6914a0 --- /dev/null +++ b/manifests/puppet-modules/grafana/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/manifests/puppet-modules/grafana/spec/unit/puppet/type/grafana_plugin_spec.rb b/manifests/puppet-modules/grafana/spec/unit/puppet/type/grafana_plugin_spec.rb new file mode 100644 index 00000000..29e7ea50 --- /dev/null +++ b/manifests/puppet-modules/grafana/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 diff --git a/manifests/puppet-modules/grafana/spec/unit/puppet/type/grafana_user_type_spec.rb b/manifests/puppet-modules/grafana/spec/unit/puppet/type/grafana_user_type_spec.rb new file mode 100644 index 00000000..f8f63b99 --- /dev/null +++ b/manifests/puppet-modules/grafana/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