init.sls 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #
  2. # grafana
  3. #
  4. {% set node_config = salt['pillar.get']('nodes:' ~ grains['id']) %}
  5. grafana:
  6. # add Grafana Repo
  7. file.managed:
  8. - names:
  9. - /usr/share/keyrings/grafana.key:
  10. - source: salt://grafana/grafana.key
  11. - /etc/apt/sources.list.d/grafana.list:
  12. - source: salt://grafana/grafana.list.tmpl
  13. - template: jinja
  14. - require:
  15. - file: /usr/share/keyrings/grafana.key
  16. # install grafana
  17. pkg.installed:
  18. - name: grafana
  19. - require:
  20. - file: /etc/apt/sources.list.d/grafana.list
  21. # - pkgrepo: grafana-src
  22. service.running:
  23. - name: grafana-server
  24. - enable: True
  25. - require:
  26. - pkg: grafana
  27. - file: /etc/grafana/grafana.ini
  28. - file: /etc/grafana/ldap.toml
  29. - user: grafana
  30. - watch:
  31. - file: /etc/grafana/grafana.ini
  32. - file: /etc/grafana/ldap.toml
  33. # add user 'grafana' to group 'ssl-cert' to access ssl-key file
  34. user.present:
  35. - name: grafana
  36. - system: True
  37. - groups:
  38. - ssl-cert
  39. - require:
  40. - pkg: grafana
  41. # add Grafana src-Repo
  42. #grafana-src:
  43. # pkgrepo.managed:
  44. # - humanname: Grafana Repo
  45. # - name: deb-src https://packages.grafana.com/oss/deb stable main
  46. # - file: /etc/apt/sources.list.d/grafana.list
  47. # - key_url: https://packages.grafana.com/gpg.key
  48. # copy custom config
  49. /etc/grafana/grafana.ini:
  50. file.managed:
  51. - source: salt://grafana/grafana.ini.tmpl
  52. - template: jinja
  53. config: {{node_config.grafana}}
  54. - require:
  55. - pkg: grafana
  56. # copy LDAP config
  57. /etc/grafana/ldap.toml:
  58. {% if 'ldap' in node_config.grafana %}
  59. file.managed:
  60. - source: salt://grafana/ldap.toml.tmpl
  61. - template: jinja
  62. config: {{node_config.grafana.ldap}}
  63. {% else %}
  64. file.absent:
  65. {% endif %}
  66. - require:
  67. - pkg: grafana
  68. #
  69. # Plugins
  70. # Grafana-Piechart-Panel
  71. grafana-piechart:
  72. cmd.run:
  73. - name: grafana-cli plugins install grafana-piechart-panel
  74. - creates: /var/lib/grafana/plugins/grafana-piechart-panel
  75. - watch_in:
  76. - service: grafana
  77. grafana-imagerenderer-deps:
  78. pkg.installed:
  79. - pkgs:
  80. - libxdamage1
  81. - libxext6
  82. - libxi6
  83. - libxtst6
  84. - libnss3
  85. - libnss3
  86. - libcups2
  87. - libxss1
  88. - libxrandr2
  89. - libasound2
  90. - libatk1.0-0
  91. - libatk-bridge2.0-0
  92. - libpangocairo-1.0-0
  93. - libpango-1.0-0
  94. - libcairo2
  95. - libatspi2.0-0
  96. - libgtk3.0-cil
  97. - libgdk3.0-cil
  98. - libx11-xcb-dev
  99. grafana-imagerenderer:
  100. cmd.run:
  101. - name: grafana-cli plugins install grafana-image-renderer
  102. - creates: /var/lib/grafana/plugins/grafana-image-renderer
  103. - watch_in:
  104. - service: grafana
  105. - require:
  106. - pkg: grafana-imagerenderer-deps