3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
skip-changelog:
- head-branch: ['^release-*', 'release']
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
with:
pidfile_workaround: 'false'
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '7.5.0'
modulesync_config_version: '9.0.0'
8 changes: 5 additions & 3 deletions .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ PreCommit:
enabled: true
description: 'Runs rubocop on modified files only'
command: ['bundle', 'exec', 'rubocop']
PuppetLint:
RakeTarget:
enabled: true
description: 'Runs puppet-lint on modified files only'
command: ['bundle', 'exec', 'puppet-lint']
description: 'Runs lint on modified files only'
targets:
- 'lint'
command: ['bundle', 'exec', 'rake']
YamlSyntax:
enabled: true
JsonSyntax:
Expand Down
5 changes: 0 additions & 5 deletions .rspec

This file was deleted.

4 changes: 0 additions & 4 deletions .rspec_parallel

This file was deleted.

26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ 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.

## [v14.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v14.0.0) (2024-06-14)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v13.2.0...v14.0.0)

**Breaking changes:**

- Drop support for EoL Grafana 8 & 9 [\#361](https://github.com/voxpupuli/puppet-grafana/pull/361) ([bastelfreak](https://github.com/bastelfreak))
- Drop EoL RedHat 7, CentOS 7 & 8 support [\#359](https://github.com/voxpupuli/puppet-grafana/pull/359) ([bastelfreak](https://github.com/bastelfreak))
- Drop EoL Ubuntu 18.04 support [\#358](https://github.com/voxpupuli/puppet-grafana/pull/358) ([bastelfreak](https://github.com/bastelfreak))
- Drop EoL Debian 10 support [\#357](https://github.com/voxpupuli/puppet-grafana/pull/357) ([bastelfreak](https://github.com/bastelfreak))

**Implemented enhancements:**

- Add Grafana 11 as supported version [\#355](https://github.com/voxpupuli/puppet-grafana/pull/355) ([sebastianrakel](https://github.com/sebastianrakel))
- Add Debian 12 support [\#341](https://github.com/voxpupuli/puppet-grafana/pull/341) ([bastelfreak](https://github.com/bastelfreak))

**Fixed bugs:**

- Create subpaths for provisioning\_datasources [\#362](https://github.com/voxpupuli/puppet-grafana/pull/362) ([sebastianrakel](https://github.com/sebastianrakel))

**Merged pull requests:**

- CI: Enhance cleanup script [\#363](https://github.com/voxpupuli/puppet-grafana/pull/363) ([bastelfreak](https://github.com/bastelfreak))
- CI: Run on latest grafana patch versions [\#360](https://github.com/voxpupuli/puppet-grafana/pull/360) ([bastelfreak](https://github.com/bastelfreak))
- Use modern apt keyrings [\#351](https://github.com/voxpupuli/puppet-grafana/pull/351) ([saz](https://github.com/saz))

## [v13.2.0](https://github.com/voxpupuli/puppet-grafana/tree/v13.2.0) (2024-05-24)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v13.1.0...v13.2.0)
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
gem 'voxpupuli-test', '~> 7.0', :require => false
gem 'voxpupuli-test', '~> 8.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 3.5', :require => false
gem 'puppet_metadata', '~> 4.0', :require => false
gem 'toml', :require => false
end

Expand Down
17 changes: 13 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following parameters are available in the `grafana` class:
* [`repo_release`](#-grafana--repo_release)
* [`repo_url`](#-grafana--repo_url)
* [`plugins`](#-grafana--plugins)
* [`provisioning_dir`](#-grafana--provisioning_dir)
* [`provisioning_dashboards`](#-grafana--provisioning_dashboards)
* [`provisioning_datasources`](#-grafana--provisioning_datasources)
* [`provisioning_dashboards_file`](#-grafana--provisioning_dashboards_file)
Expand Down Expand Up @@ -251,6 +252,14 @@ Plugins to be passed to `create_resources`, wraps around the

Default value: `{}`

##### <a name="-grafana--provisioning_dir"></a>`provisioning_dir`

Data type: `Stdlib::Absolutepath`

Path to the grafana provisioning dir e.g /etc/grafana/provisioning

Default value: `'/etc/grafana/provisioning'`

##### <a name="-grafana--provisioning_dashboards"></a>`provisioning_dashboards`

Data type: `Hash`
Expand All @@ -273,21 +282,21 @@ Default value: `{}`

##### <a name="-grafana--provisioning_dashboards_file"></a>`provisioning_dashboards_file`

Data type: `String`
Data type: `Stdlib::Absolutepath`

Fully qualified path to place the provisioning file
for dashboards, only used if provisioning_dashboards is specified.

Default value: `'/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml'`
Default value: `"${provisioning_dir}/dashboards/puppetprovisioned.yaml"`

##### <a name="-grafana--provisioning_datasources_file"></a>`provisioning_datasources_file`

Data type: `String`
Data type: `Stdlib::Absolutepath`

Fully qualified path to place the provisioning file
for datasources, only used if provisioning_datasources is specified.

Default value: `'/etc/grafana/provisioning/datasources/puppetprovisioned.yaml'`
Default value: `"${provisioning_dir}/datasources/puppetprovisioned.yaml"`

##### <a name="-grafana--create_subdirs_provisioning"></a>`create_subdirs_provisioning`

Expand Down
1 change: 1 addition & 0 deletions data/family/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
grafana::cfg_location: '/usr/local/etc/grafana.ini'
grafana::provisioning_dir: '/usr/local/etc/grafana/provisioning'
grafana::data_dir: '/var/db/grafana'
grafana::install_method: 'repo'
grafana::manage_package_repo: false
Expand Down
11 changes: 1 addition & 10 deletions lib/puppet/provider/grafana_team/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ def setup_save_preferences_data
theme: resource[:theme],
timezone: resource[:timezone]
}
if major_version >= 10
request_data[:homeDashboardUID] = dash[:uid]
else
request_data[:homeDashboardId] = dash[:id]
end
request_data[:homeDashboardUID] = dash[:uid]
['PUT', endpoint, request_data]
end

Expand Down Expand Up @@ -159,11 +155,6 @@ def version
@version = data['version']
end

def major_version
version unless @version
@version.split('.').first.to_i
end

def setup_search_path(ident, folder_id = nil, search = false)
query = if search
{
Expand Down
11 changes: 11 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@
if (length($pdatasources) >= 1) {
# template uses:
# - pdatasources

$datasources_provisioning_dir = "${grafana::provisioning_dir}/datasources"

file { $datasources_provisioning_dir:
ensure => directory,
owner => 'grafana',
group => 'grafana',
mode => '0750',
before => File[$grafana::provisioning_datasources_file],
}

file { $grafana::provisioning_datasources_file:
ensure => file,
owner => 'grafana',
Expand Down
8 changes: 6 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
# Plugins to be passed to `create_resources`, wraps around the
# `grafana_plugin` resource.
#
# @param provisioning_dir
# Path to the grafana provisioning dir e.g /etc/grafana/provisioning
#
# @param provisioning_dashboards
# Dashboards to provision into grafana. grafana > v5.0.0
# required. Will be converted into YAML and used by grafana to
Expand Down Expand Up @@ -167,8 +170,9 @@
Hash $plugins = {},
Hash $provisioning_dashboards = {},
Hash $provisioning_datasources = {},
String $provisioning_dashboards_file = '/etc/grafana/provisioning/dashboards/puppetprovisioned.yaml',
String $provisioning_datasources_file = '/etc/grafana/provisioning/datasources/puppetprovisioned.yaml',
Stdlib::Absolutepath $provisioning_dir = '/etc/grafana/provisioning',
Stdlib::Absolutepath $provisioning_dashboards_file = "${provisioning_dir}/dashboards/puppetprovisioned.yaml",
Stdlib::Absolutepath $provisioning_datasources_file = "${provisioning_dir}/datasources/puppetprovisioned.yaml",
Boolean $create_subdirs_provisioning = false,
Optional[Hash] $sysconfig = undef,
Hash[String[1], Hash] $ldap_servers = {},
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
architecture => 'amd64,arm64,armhf',
repos => 'main',
key => {
'id' => $grafana::repo_key_id,
'name' => 'grafana.asc',
'source' => $grafana::repo_gpg_key_url,
},
before => Package['grafana'],
Expand Down
10 changes: 3 additions & 7 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-grafana",
"version": "13.2.0",
"version": "14.0.0",
"author": "Vox Pupuli",
"summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.",
"license": "Apache-2.0",
Expand All @@ -21,31 +21,27 @@
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"10",
"11"
"11",
"12"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"18.04",
"20.04",
"22.04"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
Expand Down
45 changes: 45 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,51 @@ class { 'grafana':
apply_manifest(pp, catch_changes: true)
end
end

context 'with fancy dashboard config and custom target file and create_subdirs_provisioning' do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'grafana':
version => "#{grafana_version}",
create_subdirs_provisioning => true,
provisioning_datasources => {
apiVersion => 1,
datasources => [
{
name => 'Prometheus',
type => 'prometheus',
access => 'proxy',
url => 'http://localhost:9090/prometheus',
isDefault => false,
},
],
},
provisioning_dashboards => {
apiVersion => 1,
providers => [
{
name => 'default',
orgId => 1,
folder => '',
type => 'file',
disableDeletion => true,
options => {
path => '/var/lib/grafana/dashboards',
puppetsource => 'puppet:///modules/my_custom_module/dashboards',
},
},
],
},
provisioning_dashboards_file => '/etc/grafana/provisioning/dashboards/dashboard.yaml',
provisioning_datasources_file => '/etc/grafana/provisioning/datasources/datasources.yaml'
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
end
end

Expand Down
Loading