Browse Source

Merge pull request #30 from Perceptyx/master

Add default file and custom path dir creation
pull/32/head
Petr Michalec 5 years ago committed by GitHub
parent
commit
75438bf474
  1. 23
      grafana/files/default
  2. 5
      grafana/files/grafana.ini
  3. 7
      grafana/map.jinja
  4. 23
      grafana/server.sls

23
grafana/files/default

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
{%- from "grafana/map.jinja" import server with context %}
GRAFANA_USER={{ server.user }}
GRAFANA_GROUP={{ server.group }}
GRAFANA_HOME=/usr/share/grafana
LOG_DIR={{ server.path.logs }}
DATA_DIR={{ server.path.data }}
MAX_OPEN_FILES=10000
CONF_DIR=/etc/grafana
CONF_FILE=/etc/grafana/grafana.ini
RESTART_ON_UPGRADE=true
PLUGINS_DIR={{ server.path.data }}/plugins
# Only used on systemd systems
PID_FILE_DIR={{ server.path.pid_file_dir }}

5
grafana/files/grafana.ini

@ -11,11 +11,11 @@ @@ -11,11 +11,11 @@
[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
#
;data = /var/lib/grafana
data = {{ server.path.data }}
#
# Directory where grafana can store logs
#
;logs = /var/log/grafana
logs = {{ server.path.logs }}
#################################### Server ####################################
[server]
@ -288,4 +288,3 @@ path = {{ server.dashboards.path }} @@ -288,4 +288,3 @@ path = {{ server.dashboards.path }}
;enabled = false
;path = /var/lib/grafana/dashboards
{%- endif %}

7
grafana/map.jinja

@ -4,6 +4,13 @@ Debian: @@ -4,6 +4,13 @@ Debian:
pkgs:
- grafana
service: grafana-server
user: grafana
group: grafana
path:
home: /usr/share/grafana
data: /var/lib/grafana
logs: /var/log/grafana
pid_file_dir: /var/run/grafana
bind:
address: 0.0.0.0
port: 3000

23
grafana/server.sls

@ -28,6 +28,14 @@ grafana_packages: @@ -28,6 +28,14 @@ grafana_packages:
{%- 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:
@ -69,6 +77,20 @@ grafana_{{ theme_name }}_css_override: @@ -69,6 +77,20 @@ grafana_{{ theme_name }}_css_override:
{%- endfor %}
{{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 }}
grafana_service:
service.running:
- name: {{ server.service }}
@ -78,6 +100,7 @@ grafana_service: @@ -78,6 +100,7 @@ grafana_service:
- init_delay: 5
- watch:
- file: /etc/grafana/grafana.ini
- file: /etc/default/grafana-server
{%- for plugin_name, plugin in server.get('plugins', {}).iteritems() %}
{%- if plugin.get('enabled', False) %}

Loading…
Cancel
Save