init.sls 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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://packages.grafana.com/oss/deb stable main
  10. - file: /etc/apt/sources.list.d/grafana.list
  11. - key_url: https://packages.grafana.com/gpg.key
  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://packages.grafana.com/oss/deb stable main
  42. # - file: /etc/apt/sources.list.d/grafana.list
  43. # - key_url: https://packages.grafana.com/gpg.key
  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
  73. grafana-imagerenderer-deps:
  74. pkg.installed:
  75. - pkgs:
  76. - libxdamage1
  77. - libxext6
  78. - libxi6
  79. - libxtst6
  80. - libnss3
  81. - libnss3
  82. - libcups2
  83. - libxss1
  84. - libxrandr2
  85. - libasound2
  86. - libatk1.0-0
  87. - libatk-bridge2.0-0
  88. - libpangocairo-1.0-0
  89. - libpango-1.0-0
  90. - libcairo2
  91. - libatspi2.0-0
  92. - libgtk3.0-cil
  93. - libgdk3.0-cil
  94. - libx11-xcb-dev
  95. grafana-imagerenderer:
  96. cmd.run:
  97. - name: grafana-cli plugins install grafana-image-renderer
  98. - creates: /var/lib/grafana/plugins/grafana-image-renderer
  99. - watch_in:
  100. - service: grafana
  101. - require:
  102. - pkg: grafana-imagerenderer-deps