4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ spec/fixtures/manifests/
spec/fixtures/modules/
.vagrant/
.bundle/
.ruby-version
coverage/
log/
.idea/
.dependencies/
.librarian/
Puppetfile.lock
*.iml
.*.sw?
.yardoc/
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '0.16.8'
modulesync_config_version: '0.20.1'
20 changes: 20 additions & 0 deletions .pmtignore
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,7 @@ RSpec/RepeatedDescription:

RSpec/NestedGroups:
Enabled: False

# disable Yaml safe_load. This is needed to support ruby2.0.0 development envs
Security/YAMLLoad:
Enabled: false
17 changes: 5 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sudo: false
dist: trusty
language: ruby
cache: bundler
bundler_args: --without system_tests development
Expand All @@ -15,26 +16,18 @@ script:
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test
- rvm: 2.1.9
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.1.9
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.2.6
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=rubocop
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=test
allow_failures:
- rvm: 2.4.0
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=rubocop
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes
branches:
only:
- master
Expand Down
1 change: 1 addition & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--markup markdown
--output-dir docs/
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Releasing v3.0.0 (2017-03-29)

**Implemented enhancements:**

- Implement package\_ensure param for Arch Linux [\#34](https://github.com/voxpupuli/puppet-grafana/pull/34) ([bastelfreak](https://github.com/bastelfreak))

**Fixed bugs:**

- FIX configuration file ownership [\#30](https://github.com/voxpupuli/puppet-grafana/pull/30) ([cassianoleal](https://github.com/cassianoleal))

**Closed issues:**

- Configured Grafana Debian repo should contain current distribution [\#27](https://github.com/voxpupuli/puppet-grafana/issues/27)
- Error while creating dashboard [\#25](https://github.com/voxpupuli/puppet-grafana/issues/25)

**Merged pull requests:**

- Debian and RedHat based operating systems should use the repository by default [\#36](https://github.com/voxpupuli/puppet-grafana/pull/36) ([dhoppe](https://github.com/dhoppe))
- Add support for Arch Linux [\#32](https://github.com/voxpupuli/puppet-grafana/pull/32) ([bastelfreak](https://github.com/bastelfreak))
- Fix grafana\_dashboards [\#31](https://github.com/voxpupuli/puppet-grafana/pull/31) ([cassianoleal](https://github.com/cassianoleal))
- Supoort jessie for install method repo [\#28](https://github.com/voxpupuli/puppet-grafana/pull/28) ([roock](https://github.com/roock))
- Use operatinsystemmajrelease fact in repo url [\#24](https://github.com/voxpupuli/puppet-grafana/pull/24) ([mirekys](https://github.com/mirekys))
- The puppet 4-only release will start at 3.0.0 [\#21](https://github.com/voxpupuli/puppet-grafana/pull/21) ([rnelson0](https://github.com/rnelson0))

# Releasing v2.6.1 (2017-01-18)

Just a notice: The next release will be a major one without Puppet 3 support!
Expand Down
11 changes: 7 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'puppetlabs_spec_helper', '~> 1.2.2', :require => false
gem 'puppetlabs_spec_helper', '~> 2.0.1', :require => false
gem 'parallel_tests', :require => false
gem 'rspec-puppet', '~> 2.5', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-utils', :require => false
Expand All @@ -29,10 +30,12 @@ group :test do
gem 'redcarpet', :require => false
gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0'
gem 'mocha', '>= 1.2.1', :require => false
gem 'coveralls', :require => false if RUBY_VERSION >= '2.0.0'
gem 'simplecov-console', :require => false if RUBY_VERSION >= '2.0.0'
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'github_changelog_generator', '~> 1.13.0', :require => false if RUBY_VERSION < '2.2.2'
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2'
gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2'
gem 'toml', :require => false
end

Expand Down
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ task test: [
:metadata_lint,
:release_checks,
]

begin
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
version = (Blacksmith::Modulefile.new).version
config.future_release = "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
8 changes: 4 additions & 4 deletions lib/puppet/provider/grafana_dashboard/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def dashboards
def find_dashboard
return unless dashboards.find { |x| x['title'] == resource[:title] }

response = send_request format('GET, /api/dashboards/db/%s', slug)
response = send_request('GET', format('/api/dashboards/db/%s', slug))
if response.code != '200'
raise format('Fail to retrieve dashboard %s (HTTP response: %s/%s)', resource[:title], response.code, response.body)
end
Expand All @@ -68,11 +68,11 @@ def save_dashboard(dashboard)
end

def slug
resource[:title].downcase.gsub(%r{[^\w\- ]}, '').gsub(%r{ +}, '-')
resource[:title].downcase.gsub(%r{[ \+]+}, '-').gsub(%r{[^\w\- ]}, '')
end

def content
@dashboard
@dashboard.reject { |k, _| k =~ %r{^id|version|title$} }
end

def content=(value)
Expand All @@ -84,7 +84,7 @@ def create
end

def destroy
response = send_request format('DELETE, /api/dashboards/db/%s', slug)
response = send_request('DELETE', format('/api/dashboards/db/%s', slug))

return unless response.code != '200'
raise Puppet::Error, format('Failed to delete dashboard %s (HTTP response: %s/%s', resource[:title], response.code, response.body)
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/grafana_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
end

munge do |value|
JSON.parse(value)
new_value = JSON.parse(value).reject { |k, _| k =~ %r{^id|version|title$} }
new_value.sort.to_h
end

def should_to_s(value)
Expand All @@ -44,10 +45,6 @@ def should_to_s(value)
value
end
end

def to_s(value)
should_to_s(value)
end
end

newparam(:grafana_url) do
Expand Down
8 changes: 8 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
file { $::grafana::cfg_location:
ensure => file,
content => template('grafana/config.ini.erb'),
owner => 'grafana',
group => 'grafana',
}
}
}
Expand All @@ -20,6 +22,8 @@
file { $::grafana::cfg_location:
ensure => file,
content => template('grafana/config.ini.erb'),
owner => 'grafana',
group => 'grafana',
}
}
'archive': {
Expand All @@ -28,6 +32,8 @@
file { "${::grafana::install_dir}/conf/custom.ini":
ensure => file,
content => template('grafana/config.ini.erb'),
owner => 'grafana',
group => 'grafana',
}
}
default: {
Expand All @@ -40,6 +46,8 @@
file { '/etc/grafana/ldap.toml':
ensure => file,
content => inline_template("<%= require 'toml'; TOML::Generator.new(@ldap_cfg).body %>\n"),
owner => 'grafana',
group => 'grafana',
}
}
}
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
fail('cfg parameter must be a hash')
}

anchor { 'grafana::begin': } ->
class { '::grafana::install': } ->
class { '::grafana::config': } ~>
class { '::grafana::service': } ->
anchor { 'grafana::end': }
anchor { 'grafana::begin': }
-> class { '::grafana::install': }
-> class { '::grafana::config': }
~> class { '::grafana::service': }
-> anchor { 'grafana::end': }
}
12 changes: 10 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}
apt::source { 'grafana':
location => "https://packagecloud.io/grafana/${::grafana::repo_name}/debian",
release => 'wheezy',
release => $::lsbdistcodename,
repos => 'main',
key => {
'id' => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB',
Expand All @@ -99,7 +99,7 @@
if ( $::grafana::manage_package_repo ){
yumrepo { 'grafana':
descr => 'grafana repo',
baseurl => 'https://packagecloud.io/grafana/stable/el/6/$basearch',
baseurl => "https://packagecloud.io/grafana/${::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,
Expand All @@ -118,6 +118,14 @@
require => Package['fontconfig'],
}
}
'Archlinux': {
if $::grafana::manage_package_repo {
fail('manage_package_repo is not supported on Archlinux')
}
package { $::grafana::package_name:
ensure => 'present', # pacman provider doesn't have feature versionable
}
}
default: {
fail("${::operatingsystem} not supported")
}
Expand Down
26 changes: 21 additions & 5 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,37 @@
#
class grafana::params {
$archive_source = undef
$cfg_location = '/etc/grafana/grafana.ini'
$cfg = {}
$container_cfg = false
$container_params = {}
$data_dir = '/var/lib/grafana'
$docker_image = 'grafana/grafana'
$docker_ports = '3000:3000'
$install_dir = '/usr/share/grafana'
$install_method = 'package'
$ldap_cfg = false
$manage_package_repo = true
$package_name = 'grafana'
$package_source = undef
$rpm_iteration = '1'
$service_name = 'grafana-server'
$version = '2.5.0'
$repo_name = 'stable'
$version = '2.5.0'
case $::osfamily {
'Archlinux': {
$manage_package_repo = false
$install_method = 'repo'
$cfg_location = '/etc/grafana.ini'
$service_name = 'grafana'
}
'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'
}
}
}
7 changes: 5 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-grafana",
"version": "2.6.1",
"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",
Expand Down Expand Up @@ -53,12 +53,15 @@
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "Archlinux"
}
],
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 3.8.7 < 5.0.0"
"version_requirement": ">= 4.6.1 < 5.0.0"
}
],
"tags": [
Expand Down
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/centos-6-x64.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/centos-7-x64.yml
Original file line number Diff line number Diff line change
@@ -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
Loading