voxpupuli / puppet-grafana

Puppet module to manage Grafana
Apache License 2.0
15 stars 106 forks source link

hardcode path to /etc/grafana ( ldap.toml ) #257

Open olevole opened 2 years ago

olevole commented 2 years ago

I would like to avoid hardcode paths in the module code: https://github.com/voxpupuli/puppet-grafana/blob/v9.0.1/manifests/config.pp#L94 (was added by https://github.com/voxpupuli/puppet-grafana/commit/8f1f6e92 )

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Try using any arbitrary directory instead of /etc/grafana

What are you seeing

What behaviour did you expect instead

I would like to be able to choose file paths, getting rid of the hardcode.

Output log

Any additional information you'd like to impart

I would like to use an additional variable, by analogy with cfg_location:

diff --git a/data/common.yaml b/data/common.yaml
index 28bb0ac..0db6045 100644
--- a/data/common.yaml
+++ b/data/common.yaml
@@ -3,6 +3,7 @@ grafana::archive_source: ~
 grafana::cfg_location: '/etc/grafana/grafana.ini'
 grafana::cfg: {}
 grafana::ldap_cfg: ~
+grafana::ldap_cfg_location: '/etc/grafana/ldap.toml'
 grafana::container_cfg: false
 grafana::container_params: {}
 grafana::docker_image: 'grafana/grafana'
diff --git a/manifests/config.pp b/manifests/config.pp
index 341269f..f593701 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -91,7 +91,7 @@ class grafana::config {

     $ldap_cfg_toml = inline_template($template_body.join(''))

-    file { '/etc/grafana/ldap.toml':
+    file { $grafana::ldap_cfg_location:
       ensure  => file,
       content => $ldap_cfg_toml,
       owner   => 'grafana',
diff --git a/manifests/init.pp b/manifests/init.pp
index 69a4552..14eb11c 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -138,6 +138,7 @@ class grafana (
   String $cfg_location,
   Hash $cfg,
   Optional[Variant[Hash,Array]] $ldap_cfg,
+  String $ldap_cfg_location,
   Boolean $container_cfg,
   Hash $container_params,
   String $docker_image,
olevole commented 2 years ago

my version: https://github.com/olevole/puppet-grafana/commit/7dae575c3c07d237b9925bf6112569a99c3d455e

ghoneycutt commented 2 years ago

Could you please open a PR?