Showing with 91 additions and 4 deletions.
  1. +12 −0 CHANGELOG.md
  2. +19 −0 README.md
  3. +12 −0 manifests/config.pp
  4. +13 −1 manifests/init.pp
  5. +11 −1 manifests/params.pp
  6. +2 −2 metadata.json
  7. +22 −0 spec/classes/grafana_spec.rb
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v4.4.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.4.0) (2018-06-21)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.3.0...v4.4.0)

**Implemented enhancements:**

- Manage sysconfig files [\#115](https://github.com/voxpupuli/puppet-grafana/pull/115) ([ZeroPointEnergy](https://github.com/ZeroPointEnergy))

**Merged pull requests:**

- bump archive upper version boundary to \<4.0.0 [\#116](https://github.com/voxpupuli/puppet-grafana/pull/116) ([bastelfreak](https://github.com/bastelfreak))

## [v4.3.0](https://github.com/voxpupuli/puppet-grafana/tree/v4.3.0) (2018-06-18)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v4.2.0...v4.3.0)
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,25 @@ Defaults to 'grafana-server'.
The version of Grafana to install and manage. Defaults to the latest version of
Grafana available at the time of module release.

##### `sysconfig_location`

The RPM and DEB packages bring with them the default environment files for the
services. The default location of this file for Debian is /etc/default/grafana-server
and for RedHat /etc/sysconfig/grafana-server.

##### `sysconfig`

A hash of environment variables for the service. This only has an effect for installations
with RPM and DEB packages (if install_method is set to 'package' or 'repo').

Example:

```puppet
sysconfig => {
'http_proxy' => 'http://proxy.example.com',
}
```

### Advanced usage

The archive install method will create the user and a "command line" service by
Expand Down
12 changes: 12 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
owner => 'grafana',
group => 'grafana',
}

$sysconfig = $::grafana::sysconfig
$sysconfig_location = $::grafana::sysconfig_location

if $sysconfig_location and $sysconfig {
$changes = $sysconfig.map |$key, $value| { "set ${key} ${value}" }

augeas{'sysconfig/grafana-server':
context => "/files${$sysconfig_location}",
changes => $changes,
}
}
}
'archive': {
$cfg = $::grafana::cfg
Expand Down
14 changes: 13 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
# A hash of plugins to be passed to `create_resources`, wraps around the
# `grafana_plugin` resource.
#
# [*sysconfig_location*]
# Location of the sysconfig file for the environment of the grafana-server service.
# This is only used when the install_method is 'package' or 'repo'.
#
# [*sysconfig*]
# A hash of environment variables for the grafana-server service
#
# Example:
# sysconfig => { 'http_proxy' => 'http://proxy.example.com/' }
#
# === Examples
#
# class { '::grafana':
Expand All @@ -89,7 +99,9 @@
String $rpm_iteration = $::grafana::params::rpm_iteration,
String $service_name = $::grafana::params::service_name,
String $version = $::grafana::params::version,
Hash $plugins = {}
Hash $plugins = {},
Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location,
Optional[Hash] $sysconfig = undef,
) inherits grafana::params {

contain grafana::install
Expand Down
12 changes: 11 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@
$install_method = 'repo'
$cfg_location = '/etc/grafana.ini'
$service_name = 'grafana'
$sysconfig_location = undef
}
'Debian', 'RedHat': {
'Debian': {
$manage_package_repo = true
$install_method = 'repo'
$cfg_location = '/etc/grafana/grafana.ini'
$service_name = 'grafana-server'
$sysconfig_location = '/etc/default/grafana-server'
}
'RedHat': {
$manage_package_repo = true
$install_method = 'repo'
$cfg_location = '/etc/grafana/grafana.ini'
$service_name = 'grafana-server'
$sysconfig_location = '/etc/sysconfig/grafana-server'
}
default: {
$manage_package_repo = true
$install_method = 'package'
$cfg_location = '/etc/grafana/grafana.ini'
$service_name = 'grafana-server'
$sysconfig_location = undef
}
}
}
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-grafana",
"version": "4.3.0",
"version": "4.4.0",
"author": "Vox Pupuli",
"summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.",
"license": "Apache-2.0",
Expand All @@ -10,7 +10,7 @@
"dependencies": [
{
"name": "puppet/archive",
"version_requirement": ">= 1.0.1 < 3.0.0"
"version_requirement": ">= 1.0.1 < 4.0.0"
},
{
"name": "puppetlabs/stdlib",
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,28 @@
it { is_expected.to contain_file('/etc/grafana/ldap.toml').with_content(ldap_expected) }
end
end

context 'sysconfig environment variables' do
let(:params) do
{
install_method: 'repo',
sysconfig: { http_proxy: 'http://proxy.example.com/' }
}
end

case facts[:osfamily]
when 'Debian'
describe 'Add the environment variable to the config file' do
it { is_expected.to contain_augeas('sysconfig/grafana-server').with_context('/files/etc/default/grafana-server') }
it { is_expected.to contain_augeas('sysconfig/grafana-server').with_changes(['set http_proxy http://proxy.example.com/']) }
end
when 'RedHat'
describe 'Add the environment variable to the config file' do
it { is_expected.to contain_augeas('sysconfig/grafana-server').with_context('/files/etc/sysconfig/grafana-server') }
it { is_expected.to contain_augeas('sysconfig/grafana-server').with_changes(['set http_proxy http://proxy.example.com/']) }
end
end
end
end
end
end