2015-12-04 10:43:48 -05:00
|
|
|
{%- from "grafana/map.jinja" import server with context %}
|
2016-11-28 06:04:11 -05:00
|
|
|
{%- if server.get('enabled', False) %}
|
2015-12-04 10:43:48 -05:00
|
|
|
|
|
|
|
grafana_packages:
|
|
|
|
pkg.installed:
|
2019-03-04 02:05:32 -05:00
|
|
|
- names: {{ server.pkgs|tojson }}
|
2015-12-04 10:43:48 -05:00
|
|
|
|
2015-12-08 04:23:39 -05:00
|
|
|
/etc/grafana/grafana.ini:
|
2015-12-04 10:43:48 -05:00
|
|
|
file.managed:
|
2015-12-08 04:23:39 -05:00
|
|
|
- source: salt://grafana/files/grafana.ini
|
2015-12-04 10:43:48 -05:00
|
|
|
- template: jinja
|
2015-12-08 05:23:30 -05:00
|
|
|
- user: grafana
|
|
|
|
- group: grafana
|
2015-12-04 10:43:48 -05:00
|
|
|
- require:
|
|
|
|
- pkg: grafana_packages
|
|
|
|
|
2016-12-05 07:11:53 -05:00
|
|
|
{%- 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 %}
|
|
|
|
|
|
|
|
|
2017-08-06 21:30:31 -04:00
|
|
|
/etc/default/grafana-server:
|
|
|
|
file.managed:
|
|
|
|
- name: /etc/default/grafana-server
|
|
|
|
- source: salt://grafana/files/default
|
|
|
|
- template: jinja
|
|
|
|
- require:
|
|
|
|
- pkg: grafana_packages
|
|
|
|
|
2016-10-26 05:25:37 -04:00
|
|
|
{%- if server.dashboards.enabled %}
|
2016-10-29 18:27:24 -04:00
|
|
|
|
2016-10-26 05:25:37 -04:00
|
|
|
grafana_copy_default_dashboards:
|
|
|
|
file.recurse:
|
|
|
|
- name: {{ server.dashboards.path }}
|
|
|
|
- source: salt://grafana/files/dashboards
|
|
|
|
- user: grafana
|
|
|
|
- group: grafana
|
|
|
|
- require:
|
|
|
|
- pkg: grafana_packages
|
2016-10-29 18:27:24 -04:00
|
|
|
- require_in:
|
|
|
|
- service: grafana_service
|
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- for theme_name, theme in server.get('theme', {}).iteritems() %}
|
|
|
|
|
|
|
|
{%- 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
|
|
|
|
|
2016-10-26 05:25:37 -04:00
|
|
|
{%- endif %}
|
|
|
|
|
2016-10-29 18:27:24 -04:00
|
|
|
{%- endfor %}
|
|
|
|
|
2017-08-06 21:30:31 -04:00
|
|
|
{{server.path.data}}:
|
|
|
|
file.directory:
|
|
|
|
- makedirs: True
|
|
|
|
- mode: 755
|
|
|
|
- user: {{ server.user }}
|
|
|
|
- group: {{ server.group }}
|
|
|
|
|
|
|
|
{{server.path.logs}}:
|
|
|
|
file.directory:
|
|
|
|
- makedirs: True
|
|
|
|
- mode: 755
|
|
|
|
- user: {{ server.user }}
|
|
|
|
- group: {{ server.group }}
|
|
|
|
|
2015-12-08 04:26:39 -05:00
|
|
|
grafana_service:
|
|
|
|
service.running:
|
|
|
|
- name: {{ server.service }}
|
|
|
|
- enable: true
|
2016-11-02 04:04:42 -04:00
|
|
|
# It is needed if client is trying to set datasource or dashboards before
|
|
|
|
# server is ready.
|
|
|
|
- init_delay: 5
|
2015-12-08 04:26:39 -05:00
|
|
|
- watch:
|
|
|
|
- file: /etc/grafana/grafana.ini
|
2017-08-06 21:30:31 -04:00
|
|
|
- file: /etc/default/grafana-server
|
2015-12-08 04:26:39 -05:00
|
|
|
|
2017-03-09 11:01:26 -05:00
|
|
|
{%- for plugin_name, plugin in server.get('plugins', {}).iteritems() %}
|
|
|
|
{%- if plugin.get('enabled', False) %}
|
|
|
|
install_{{ plugin_name }}:
|
|
|
|
cmd.run:
|
|
|
|
- name: grafana-cli plugins install {{ plugin_name }}
|
2017-03-21 05:02:49 -04:00
|
|
|
- unless: grafana-cli plugins ls | grep {{ plugin_name }}
|
2017-03-09 11:01:26 -05:00
|
|
|
- watch_in:
|
|
|
|
- service: grafana_service
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2016-10-26 05:25:37 -04:00
|
|
|
{%- endif %}
|