23 changes: 19 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,34 @@ You can install all needed gems for spec tests into the modules directory by
running:

```sh
bundle install --path .vendor/ --without development system_tests release
bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)"
```

If you also want to run acceptance tests:

```sh
bundle install --path .vendor/ --with system_tests --without development release
bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"
```

Our all in one solution if you don't know if you need to install or update gems:

```sh
bundle install --path .vendor/ --with system_tests --without development release; bundle update; bundle clean
bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean
```

As an alternative to the `--jobs "$(nproc)` parameter, you can set an
environment variable:

```sh
BUNDLE_JOBS="$(nproc)"
```

### Note for OS X users

`nproc` isn't a valid command unter OS x. As an alternative, you can do:

```sh
--jobs "$(sysctl -n hw.ncpu)"
```

## Syntax and style
Expand Down Expand Up @@ -160,7 +175,7 @@ created virtual machines will be in `.vagrant/beaker_vagrant_files`.
Beaker also supports docker containers. We also use that in our automated CI
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:

```
```sh
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
```

Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '2.5.1'
modulesync_config_version: '2.8.0'
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ matrix:
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker
Expand All @@ -43,10 +39,6 @@ matrix:
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
branches:
only:
- master
Expand Down
46 changes: 41 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v6.1.0](https://github.com/voxpupuli/puppet-grafana/tree/v6.1.0) (2019-10-30)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v6.0.0...v6.1.0)

**Implemented enhancements:**

- Feature request: add basicAuth for grafana\_datasource [\#43](https://github.com/voxpupuli/puppet-grafana/issues/43)
- Add FreeBSD 12 support [\#179](https://github.com/voxpupuli/puppet-grafana/pull/179) ([olevole](https://github.com/olevole))
- Update grafana\_dashboard resource for folders [\#172](https://github.com/voxpupuli/puppet-grafana/pull/172) ([alexconrey](https://github.com/alexconrey))
- Implement grafana\_folder resource type [\#170](https://github.com/voxpupuli/puppet-grafana/pull/170) ([alexconrey](https://github.com/alexconrey))
- Mark passwords as sensitive [\#165](https://github.com/voxpupuli/puppet-grafana/pull/165) ([alexjfisher](https://github.com/alexjfisher))

**Fixed bugs:**

- Fix version, because 6.0.0-beta1 does not exist anymore [\#163](https://github.com/voxpupuli/puppet-grafana/pull/163) ([dhoppe](https://github.com/dhoppe))
- Fix value of variables base\_url and real\_archive\_source [\#161](https://github.com/voxpupuli/puppet-grafana/pull/161) ([dhoppe](https://github.com/dhoppe))
- Fix value of variable real\_package\_source [\#160](https://github.com/voxpupuli/puppet-grafana/pull/160) ([dhoppe](https://github.com/dhoppe))

**Closed issues:**

- How to create Notification channels [\#188](https://github.com/voxpupuli/puppet-grafana/issues/188)
- Cannot install puppet/grafana, most recent puppet/archive version is v4.2 [\#184](https://github.com/voxpupuli/puppet-grafana/issues/184)
- \[UBUNTU 14.04\] Package not found [\#85](https://github.com/voxpupuli/puppet-grafana/issues/85)
- Puppet module exposes passwords - current and previous in plane text during puppet runs [\#82](https://github.com/voxpupuli/puppet-grafana/issues/82)
- using docker install with container\_cfg attempts to use incorrect permissions [\#52](https://github.com/voxpupuli/puppet-grafana/issues/52)
- Hide sensitive data values [\#45](https://github.com/voxpupuli/puppet-grafana/issues/45)
- Feature request: support auth.proxy config option [\#40](https://github.com/voxpupuli/puppet-grafana/issues/40)

**Merged pull requests:**

- Clean up acceptance spec helper [\#189](https://github.com/voxpupuli/puppet-grafana/pull/189) ([ekohl](https://github.com/ekohl))
- DOC Add Provisioning with dashboards from grafana.com [\#185](https://github.com/voxpupuli/puppet-grafana/pull/185) ([mfaure](https://github.com/mfaure))
- Allow puppet/archive 4.x and puppetlabs/stdlib 6.x [\#176](https://github.com/voxpupuli/puppet-grafana/pull/176) ([alexjfisher](https://github.com/alexjfisher))
- Corrected invalid database config example [\#169](https://github.com/voxpupuli/puppet-grafana/pull/169) ([Rovanion](https://github.com/Rovanion))
- Use data in modules instead of params.pp [\#167](https://github.com/voxpupuli/puppet-grafana/pull/167) ([dhoppe](https://github.com/dhoppe))
- Remove Puppet 3 specific syntax [\#166](https://github.com/voxpupuli/puppet-grafana/pull/166) ([dhoppe](https://github.com/dhoppe))

## [v6.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v6.0.0) (2019-02-14)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v5.0.0...v6.0.0)
Expand Down Expand Up @@ -136,7 +173,6 @@ These should not affect the functionality of the module.
**Fixed bugs:**

- grafana\_datasource provider with\_credentials\(\) returns is\_default value [\#89](https://github.com/voxpupuli/puppet-grafana/issues/89)
- fix datasource provider error [\#90](https://github.com/voxpupuli/puppet-grafana/pull/90) ([brandonrdn](https://github.com/brandonrdn))

## [v4.1.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.1.0) (2018-02-03)

Expand All @@ -146,6 +182,10 @@ These should not affect the functionality of the module.

- \(SIMP-4206\) Added organization provider and updated datasource provider [\#86](https://github.com/voxpupuli/puppet-grafana/pull/86) ([heliocentric](https://github.com/heliocentric))

**Fixed bugs:**

- fix datasource provider error [\#90](https://github.com/voxpupuli/puppet-grafana/pull/90) ([brandonrdn](https://github.com/brandonrdn))

**Closed issues:**

- "Could not autoload" error in grafana\_dashboard with ruby 2.4 on Centos 6 [\#83](https://github.com/voxpupuli/puppet-grafana/issues/83)
Expand Down Expand Up @@ -185,10 +225,6 @@ These should not affect the functionality of the module.

- Module doesn't work on Ubuntu Xenial [\#56](https://github.com/voxpupuli/puppet-grafana/issues/56)

**Merged pull requests:**

- Release 4.0.1 [\#68](https://github.com/voxpupuli/puppet-grafana/pull/68) ([wyardley](https://github.com/wyardley))

## [v4.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.0.0) (2017-09-20)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v3.0.0...v4.0.0)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.5.1
FROM ruby:2.5.3

WORKDIR /opt/puppet

Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false
gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false
gem 'rspec-puppet-facts', '>= 1.8.0', :require => false
gem 'rspec-puppet-utils', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
Expand All @@ -20,6 +20,8 @@ group :test do
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 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-topscope-variable-check', :require => false
gem 'metadata-json-lint', :require => false
gem 'redcarpet', :require => false
gem 'rubocop', '~> 0.49.1', :require => false
Expand Down Expand Up @@ -65,7 +67,7 @@ group :release do
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator'
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem'
gem 'puppet-strings', '>= 1.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end


Expand Down
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ result in...
http_port => 8080,
},
database => {
type => 'sqlite3',
type => 'mysql',
host => '127.0.0.1:3306',
name => 'grafana',
user => 'root',
Expand Down Expand Up @@ -404,6 +404,7 @@ If you are using a sub-path for the Grafana API, you will need to set the `grafa
- `grafana_datasource`
- `grafana_organization`
- `grafana_user`
- `grafana_folder`

For instance, if your sub-path is `/grafana`, the `grafana_api_path` must
be set to `/grafana/api`. Do not add a trailing `/` (slash) at the end of the value.
Expand Down Expand Up @@ -442,6 +443,7 @@ grafana_dashboard { 'example_dashboard':
grafana_user => 'admin',
grafana_password => '5ecretPassw0rd',
grafana_api_path => '/grafana/api',
folder => 'folder-name',
organization => 'NewOrg',
content => template('path/to/exported/file.json'),
}
Expand All @@ -450,6 +452,7 @@ grafana_dashboard { 'example_dashboard':
`content` must be valid JSON, and is parsed before imported.
`grafana_user` and `grafana_password` are optional, and required when
authentication is enabled in Grafana. `grafana_api_path` is optional, and only used when using sub-paths for the API. `organization` is optional, and used when creating a dashboard for a specific organization.
`folder` is an optional parameter, but the folder resource must exist.

Example:
Make sure the `grafana-server` service is up and running before creating the `grafana_dashboard` definition. One option is to use the `http_conn_validator` from the [healthcheck](https://forge.puppet.com/puppet/healthcheck) module
Expand Down Expand Up @@ -640,6 +643,21 @@ grafana_plugin { 'grafana-simple-json-datasource':
}
```

##### `grafana_folder`

Creates and manages Grafana folders via the API.

The following example creates a folder named 'folder1':
```puppet
grafana_folder { 'folder1':
grafana_url => 'http://localhost:3000',
grafana_api_path => '/grafana/api',
grafana_user => 'admin',
grafana_password => '5ecretPassw0rd',
}
```
`grafana_api_path` is only required if using sub-paths for the API

##### `grafana::user`

Creates and manages a global grafana user via the API.
Expand Down Expand Up @@ -865,6 +883,44 @@ the filesystem of the puppetserver/master. Thus you may specify a
local directory with grafana dashboards you wish to provision into
grafana.

##### Provisioning with dashboards from grafana.com

GrafanaLabs provides lots of [dashboards that may be reused](https://grafana.com/grafana/dashboards).
Those ones are **not directly usable** for provisioning (this is
a Grafana issue, not a Puppet one).

In order to have a "provisionable" dashboard in JSON format, you have
to prepare it before adding it in your Puppet code. Here are the steps
to follow:

1. Use a Grafana instance
1. Import the desired dashboard
1. Define its datasource
1. From the dashboard view:
* Click the "Share dashboard" icon (top left corner of screen)
* Select the "Export" tab,
* Activate "Export for sharing externally"
* Click "Save to file"
1. In the JSON file:
* Remove the keys `__imports` and `__requires`
* Replace all `${DS_PROMETHEUS}` by your datasource name
1. Once saved, you may place this JSON file in your
`puppet:///modules/my_custom_module/dashboards` directory

**Note:**

This procedure have been tested with Grafana 6.x. It may not work for
any dashboard, depending on how it's been coded.

Dashboards known to be "provisionable":

* [Node Exporter Server Metric](https://grafana.com/dashboards/405)
* [Prometheus Blackbox Exporter](https://grafana.com/dashboards/7587)

Dashboards known not to be "provisionable":

* [HTTP Services Status](https://grafana.com/dashboards/4859)

## Tasks

### `change_grafana_admin_password`
Expand Down
41 changes: 8 additions & 33 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@ require 'puppetlabs_spec_helper/rake_tasks'
# load optional tasks for releases
# only available if gem group releases is installed
begin
require 'puppet_blacksmith/rake_tasks'
require 'voxpupuli/release/rake_tasks'
require 'puppet-strings/tasks'
rescue LoadError
end

PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
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')
PuppetLint.configuration.absolute_classname_reverse = true

exclude_paths = %w(
pkg/**/*
Expand All @@ -28,19 +21,16 @@ PuppetSyntax.exclude_paths = exclude_paths

desc 'Auto-correct puppet-lint offenses'
task 'lint:auto_correct' do
PuppetLint.configuration.fix = true
Rake::Task[:lint].invoke
Rake::Task[:lint_fix].invoke
end

desc 'Run acceptance tests'
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end

desc 'Run tests release_checks'
task test: [
:release_checks,
]
desc 'Run tests'
task test: [:release_checks]

namespace :check do
desc 'Check for trailing whitespace'
Expand Down Expand Up @@ -69,25 +59,10 @@ task test_with_coveralls: [:test] do
end
end

desc "Print supported beaker sets"
task 'beaker_sets', [:directory] do |t, args|
directory = args[:directory]

metadata = JSON.load(File.read('metadata.json'))

(metadata['operatingsystem_support'] || []).each do |os|
(os['operatingsystemrelease'] || []).each do |release|
if directory
beaker_set = "#{directory}/#{os['operatingsystem'].downcase}-#{release}"
else
beaker_set = "#{os['operatingsystem'].downcase}-#{release}-x64"
end

filename = "spec/acceptance/nodesets/#{beaker_set}.yml"

puts beaker_set if File.exists? filename
end
end
desc 'Generate REFERENCE.md'
task :reference, [:debug, :backtrace] do |t, args|
patterns = ''
Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace])
end

begin
Expand Down
27 changes: 27 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
grafana::archive_source: ~
grafana::cfg_location: '/etc/grafana/grafana.ini'
grafana::cfg: {}
grafana::ldap_cfg: ~
grafana::container_cfg: false
grafana::container_params: {}
grafana::docker_image: 'grafana/grafana'
grafana::docker_ports: '3000:3000'
grafana::data_dir: '/var/lib/grafana'
grafana::install_dir: '/usr/share/grafana'
grafana::install_method: 'package'
grafana::manage_package_repo: true
grafana::package_name: 'grafana'
grafana::package_source: ~
grafana::repo_name: 'stable'
grafana::rpm_iteration: '1'
grafana::service_name: 'grafana-server'
grafana::version: 'installed'
grafana::plugins: {}
grafana::provisioning_dashboards: {}
grafana::provisioning_datasources: {}
grafana::provisioning_dashboards_file: '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml'
grafana::provisioning_datasources_file: '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml'
grafana::create_subdirs_provisioning: false
grafana::sysconfig_location: ~
grafana::sysconfig: ~
5 changes: 5 additions & 0 deletions data/family/Archlinux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
grafana::cfg_location: '/etc/grafana.ini'
grafana::install_method: 'repo'
grafana::manage_package_repo: false
grafana::service_name: 'grafana'
3 changes: 3 additions & 0 deletions data/family/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
grafana::install_method: 'repo'
grafana::sysconfig_location: '/etc/default/grafana-server'
7 changes: 7 additions & 0 deletions data/family/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
grafana::cfg_location: '/usr/local/etc/grafana.ini'
grafana::data_dir: '/var/db/grafana'
grafana::install_method: 'repo'
grafana::manage_package_repo: false
grafana::package_name: 'grafana6'
grafana::service_name: 'grafana'
Loading