Skip to content

Commit

Permalink
LDAP: use stdlib::to_toml() instead of toml gem
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Aug 9, 2023
1 parent 145b3e7 commit eb1506a
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,14 @@
if $grafana::ldap_cfg {
if $grafana::ldap_cfg =~ Sensitive {
$ldap_cfg = $grafana::ldap_cfg.unwrap
$ldap_cfg_toml = Sensitive($ldap_cfg.flatten.map |$data| { stdlib::to_toml($data) + "\n" })
} else {
$ldap_cfg = $grafana::ldap_cfg
}

$template_body = [
"<% [scope['ldap_cfg']].flatten(1).each do |v| %>",
"<%= require 'toml'; TOML::Generator.new(v).body %>\n",
'<% end %>',
]

if $grafana::ldap_cfg =~ Sensitive {
$ldap_cfg_toml = Sensitive(inline_template($template_body.join('')))
} else {
$ldap_cfg_toml = inline_template($template_body.join(''))
$ldap_cfg_toml = $grafana::ldap_cfg.flatten.map |$data| { stdlib::to_toml($data) + "\n" }
}

file { '/etc/grafana/ldap.toml':
ensure => file,
content => $ldap_cfg_toml,
content => $ldap_cfg_toml.join("\n"),
owner => 'grafana',
group => 'grafana',
notify => Class['grafana::service'],
Expand Down

0 comments on commit eb1506a

Please sign in to comment.