init.sls 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #
  2. # grafana
  3. #
  4. {% set node_config = salt['pillar.get']('nodes:' ~ grains['id']) %}
  5. grafana:
  6. # add Grafana Repo
  7. pkgrepo.managed:
  8. - humanname: Grafana Repo
  9. - name: deb https://packagecloud.io/grafana/stable/debian/ jessie main
  10. - file: /etc/apt/sources.list.d/grafana.list
  11. - key_url: https://packagecloud.io/grafana/stable/gpgkey
  12. # install grafana
  13. pkg.installed:
  14. - name: grafana
  15. - require:
  16. - pkgrepo: grafana
  17. - pkgrepo: grafana-src
  18. service.running:
  19. - name: grafana-server
  20. - enable: True
  21. - require:
  22. - pkg: grafana
  23. - file: /etc/grafana/grafana.ini
  24. - file: /etc/grafana/ldap.toml
  25. - user: grafana
  26. - watch:
  27. - file: /etc/grafana/grafana.ini
  28. - file: /etc/grafana/ldap.toml
  29. # add user 'grafana' to group 'ssl-cert' to access ssl-key file
  30. user.present:
  31. - name: grafana
  32. - system: True
  33. - groups:
  34. - ssl-cert
  35. - require:
  36. - pkg: grafana
  37. # add Grafana src-Repo
  38. grafana-src:
  39. pkgrepo.managed:
  40. - humanname: Grafana Repo
  41. - name: deb-src https://packagecloud.io/grafana/stable/debian/ jessie main
  42. - file: /etc/apt/sources.list.d/grafana.list
  43. - key_url: https://packagecloud.io/grafana/stable/gpgkey
  44. # copy custom config
  45. /etc/grafana/grafana.ini:
  46. file.managed:
  47. - source: salt://grafana/grafana.ini.tmpl
  48. - template: jinja
  49. config: {{node_config.grafana}}
  50. - require:
  51. - pkg: grafana
  52. # copy LDAP config
  53. /etc/grafana/ldap.toml:
  54. {% if 'ldap' in node_config.grafana %}
  55. file.managed:
  56. - source: salt://grafana/ldap.toml.tmpl
  57. - template: jinja
  58. config: {{node_config.grafana.ldap}}
  59. {% else %}
  60. file.absent:
  61. {% endif %}
  62. - require:
  63. - pkg: grafana
  64. #
  65. # Plugins
  66. # Grafana-Piechart-Panel
  67. grafana-piechart:
  68. cmd.run:
  69. - name: grafana-cli plugins install grafana-piechart-panel
  70. - creates: /var/lib/grafana/plugins/grafana-piechart-panel
  71. - watch_in:
  72. - service: grafana