Browse Source

Grafana: Add Grafana config into its own pillar

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 11 months ago
parent
commit
ac553e6aaf
2 changed files with 10 additions and 17 deletions
  1. 9 16
      grafana/init.sls
  2. 1 1
      grafana/ldap.toml.tmpl

+ 9 - 16
grafana/init.sls

@@ -2,6 +2,8 @@
 # grafana
 #
 
+{% set grafana_cfg = salt['pillar.get']('grafana') %}
+
 {% set node_config = salt['pillar.get']('nodes:' ~ grains['id']) %}
 
 
@@ -16,12 +18,13 @@ grafana:
         - template: jinja
         - require:
           - file: /usr/share/keyrings/grafana.key
+
 # install grafana
   pkg.installed:
     - name: grafana
     - require:
       - file: /etc/apt/sources.list.d/grafana.list
-#      - pkgrepo: grafana-src
+
   service.running:
     - name: grafana-server
     - enable: True
@@ -33,6 +36,7 @@ grafana:
     - watch:
       - file: /etc/grafana/grafana.ini
       - file: /etc/grafana/ldap.toml
+
 # add user 'grafana' to group 'ssl-cert' to access ssl-key file
   user.present:
     - name: grafana
@@ -42,30 +46,21 @@ grafana:
     - require:
       - pkg: grafana
 
-# add Grafana src-Repo
-#grafana-src:
-#  pkgrepo.managed:
-#    - humanname: Grafana Repo
-#    - name: deb-src https://packages.grafana.com/oss/deb stable main
-#    - file: /etc/apt/sources.list.d/grafana.list
-#    - key_url: https://packages.grafana.com/gpg.key 
-
-# copy custom config
 /etc/grafana/grafana.ini:
   file.managed:
     - source: salt://grafana/grafana.ini.tmpl
     - template: jinja
-      config: {{node_config.grafana}}
+      config: {{ grafana_cfg }}
     - require:
       - pkg: grafana
 
-# copy LDAP config
+
 /etc/grafana/ldap.toml:
-{% if 'ldap' in node_config.grafana %}
+{% if 'ldap' in grafana_cfg %}
   file.managed:
     - source: salt://grafana/ldap.toml.tmpl
     - template: jinja
-      config: {{node_config.grafana.ldap}}
+      config: {{ grafana_cfg.ldap }}
 {% else %}
   file.absent:
 {% endif %}
@@ -114,5 +109,3 @@ grafana-imagerenderer:
       - service: grafana
     - require:
       - pkg: grafana-imagerenderer-deps
-
-

+ 1 - 1
grafana/ldap.toml.tmpl

@@ -21,7 +21,7 @@ ssl_skip_verify = false
 # root_ca_cert = /path/to/certificate.crt
 
 # Search user bind dn
-bind_dn = "uid=grafana,ou=Services,dc=ffho,dc=net"
+bind_dn = "{{ config.bind_dn }}"
 # Search user bind password
 # If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
 bind_password = "{{ config.bind_password }}"