1
0
Fork 0
mirror of synced 2024-05-29 21:31:09 -04:00
formula-grafana/grafana/server.sls
Marcin 1d8fd0a106
Add user invite max lifetime duration parameter (#43)
* Add option to configure domain and root_url in grafana config

* Add external_image_storage S3 in grafana config

* Revert external_image_storage settings

* Update ldap.toml to work with salt 2018.3

See 8393560642/doc/topics/releases/2018.3.0.rst

* Add recurse option when creating grafana dirs.

Should not hurt if they are empty and can avoid issues when moving data between servers

* Make compatible with Salt 2019.2.0

* Change to items for py3 compat

Signed-off-by: Felipe Zipitria <fzipitria@perceptyx.com>

* Add user_invite_max_lifetime_duration configuration parameter

Co-authored-by: abednarik <alejandro.bednarik@gmail.com>
Co-authored-by: Felipe Zipitria <fzipitria@perceptyx.com>
Co-authored-by: Nicolas Fernandez <nookynet@gmail.com>
2021-10-18 10:21:06 +02:00

123 lines
2.8 KiB
Plaintext

{%- from "grafana/map.jinja" import server with context %}
{%- if server.get('enabled', False) %}
grafana_packages:
pkg.installed:
- names: {{ server.pkgs|tojson }}
/etc/grafana/grafana.ini:
file.managed:
- source: salt://grafana/files/grafana.ini
- template: jinja
- user: grafana
- group: grafana
- require:
- pkg: grafana_packages
{%- if server.auth.get('ldap', {}).get('enabled', False) %}
/etc/grafana/ldap.toml:
file.managed:
- source: salt://grafana/files/ldap.toml
- template: jinja
- user: grafana
- group: grafana
- require:
- pkg: grafana_packages
- watch_in:
- service: grafana_service
{%- endif %}
/etc/default/grafana-server:
file.managed:
- name: /etc/default/grafana-server
- source: salt://grafana/files/default
- template: jinja
- require:
- pkg: grafana_packages
{%- if server.dashboards.enabled %}
grafana_copy_default_dashboards:
file.recurse:
- name: {{ server.dashboards.path }}
- source: salt://grafana/files/dashboards
- user: grafana
- group: grafana
- require:
- pkg: grafana_packages
- require_in:
- service: grafana_service
{%- endif %}
{%- for theme_name, theme in server.get('theme', {}).items() %}
{%- if theme.css_override is defined %}
grafana_{{ theme_name }}_css_override:
file.managed:
- names:
- {{ server.dir.static }}/css/grafana.{{ theme_name }}.min.css
{%- if theme.css_override.build is defined %}
- {{ server.dir.static }}/css/grafana.{{ theme_name }}.min.{{ theme.css_override.build }}.css
{%- endif %}
- source: {{ theme.css_override.source }}
{%- if theme.css_override.source_hash is defined %}
- source_hash: {{ theme.css_override.source_hash }}
{%- endif %}
- user: grafana
- group: grafana
- require:
- pkg: grafana_packages
- require_in:
- service: grafana_service
{%- endif %}
{%- endfor %}
{{server.path.data}}:
file.directory:
- makedirs: True
- mode: 755
- user: {{ server.user }}
- group: {{ server.group }}
- recurse:
- user
- group
{{server.path.logs}}:
file.directory:
- makedirs: True
- mode: 755
- user: {{ server.user }}
- group: {{ server.group }}
- recurse:
- user
- group
grafana_service:
service.running:
- name: {{ server.service }}
- enable: true
# It is needed if client is trying to set datasource or dashboards before
# server is ready.
- init_delay: 5
- watch:
- file: /etc/grafana/grafana.ini
- file: /etc/default/grafana-server
{%- for plugin_name, plugin in server.get('plugins', {}).items() %}
{%- if plugin.get('enabled', False) %}
install_{{ plugin_name }}:
cmd.run:
- name: grafana-cli plugins install {{ plugin_name }}
- unless: grafana-cli plugins ls | grep {{ plugin_name }}
- watch_in:
- service: grafana_service
{%- endif %}
{%- endfor %}
{%- endif %}