File tree Expand file tree Collapse file tree 5 files changed +77
-2
lines changed
Expand file tree Collapse file tree 5 files changed +77
-2
lines changed Original file line number Diff line number Diff line change @@ -304,6 +304,25 @@ Defaults to 'grafana-server'.
304304The version of Grafana to install and manage. Defaults to the latest version of
305305Grafana available at the time of module release.
306306
307+ ##### ` sysconfig_location `
308+
309+ The RPM and DEB packages bring with them the default environment files for the
310+ services. The default location of this file for Debian is /etc/default/grafana-server
311+ and for RedHat /etc/sysconfig/grafana-server.
312+
313+ ##### ` sysconfig `
314+
315+ A hash of environment variables for the service. This only has an effect for installations
316+ with RPM and DEB packages (if install_method is set to 'package' or 'repo').
317+
318+ Example:
319+
320+ ``` puppet
321+ sysconfig => {
322+ 'http_proxy' => 'http://proxy.example.com',
323+ }
324+ ```
325+
307326### Advanced usage
308327
309328The archive install method will create the user and a "command line" service by
Original file line number Diff line number Diff line change 2525 owner => ' grafana' ,
2626 group => ' grafana' ,
2727 }
28+
29+ $sysconfig = $::grafana::sysconfig
30+ $sysconfig_location = $::grafana::sysconfig_location
31+
32+ if $sysconfig_location and $sysconfig {
33+ $changes = $sysconfig .map |$key , $value | { " set ${key} ${value} " }
34+
35+ augeas {'sysconfig/grafana-server' :
36+ context => " /files${$sysconfig_location} " ,
37+ changes => $changes ,
38+ }
39+ }
2840 }
2941 ' archive' : {
3042 $cfg = $::grafana::cfg
Original file line number Diff line number Diff line change 6666# A hash of plugins to be passed to `create_resources`, wraps around the
6767# `grafana_plugin` resource.
6868#
69+ # [*sysconfig_location*]
70+ # Location of the sysconfig file for the environment of the grafana-server service.
71+ # This is only used when the install_method is 'package' or 'repo'.
72+ #
73+ # [*sysconfig*]
74+ # A hash of environment variables for the grafana-server service
75+ #
76+ # Example:
77+ # sysconfig => { 'http_proxy' => 'http://proxy.example.com/' }
78+ #
6979# === Examples
7080#
7181# class { '::grafana':
8999 String $rpm_iteration = $::grafana::params::rpm_iteration,
90100 String $service_name = $::grafana::params::service_name,
91101 String $version = $::grafana::params::version,
92- Hash $plugins = {}
102+ Hash $plugins = {},
103+ Optional[String] $sysconfig_location = $::grafana::params::sysconfig_location ,
104+ Optional[Hash] $sysconfig = undef ,
93105) inherits grafana::params {
94106
95107 contain grafana::install
Original file line number Diff line number Diff line change 2121 $install_method = ' repo'
2222 $cfg_location = ' /etc/grafana.ini'
2323 $service_name = ' grafana'
24+ $sysconfig_location = undef
2425 }
25- ' Debian' , ' RedHat ' : {
26+ ' Debian' : {
2627 $manage_package_repo = true
2728 $install_method = ' repo'
2829 $cfg_location = ' /etc/grafana/grafana.ini'
2930 $service_name = ' grafana-server'
31+ $sysconfig_location = ' /etc/default/grafana-server'
32+ }
33+ ' RedHat' : {
34+ $manage_package_repo = true
35+ $install_method = ' repo'
36+ $cfg_location = ' /etc/grafana/grafana.ini'
37+ $service_name = ' grafana-server'
38+ $sysconfig_location = ' /etc/sysconfig/grafana-server'
3039 }
3140 default: {
3241 $manage_package_repo = true
3342 $install_method = ' package'
3443 $cfg_location = ' /etc/grafana/grafana.ini'
3544 $service_name = ' grafana-server'
45+ $sysconfig_location = undef
3646 }
3747 }
3848}
Original file line number Diff line number Diff line change 309309 it { is_expected . to contain_file ( '/etc/grafana/ldap.toml' ) . with_content ( ldap_expected ) }
310310 end
311311 end
312+
313+ context 'sysconfig environment variables' do
314+ let ( :params ) do
315+ {
316+ install_method : 'repo' ,
317+ sysconfig : { http_proxy : 'http://proxy.example.com/' }
318+ }
319+ end
320+
321+ case facts [ :osfamily ]
322+ when 'Debian'
323+ describe 'Add the environment variable to the config file' do
324+ it { is_expected . to contain_augeas ( 'sysconfig/grafana-server' ) . with_context ( '/files/etc/default/grafana-server' ) }
325+ it { is_expected . to contain_augeas ( 'sysconfig/grafana-server' ) . with_changes ( [ 'set http_proxy http://proxy.example.com/' ] ) }
326+ end
327+ when 'RedHat'
328+ describe 'Add the environment variable to the config file' do
329+ it { is_expected . to contain_augeas ( 'sysconfig/grafana-server' ) . with_context ( '/files/etc/sysconfig/grafana-server' ) }
330+ it { is_expected . to contain_augeas ( 'sysconfig/grafana-server' ) . with_changes ( [ 'set http_proxy http://proxy.example.com/' ] ) }
331+ end
332+ end
333+ end
312334 end
313335 end
314336end
You can’t perform that action at this time.
0 commit comments