Merge branch '21379-user-activity-remote-collection'
[arvados.git] / tools / salt-install / config_examples / multi_host / aws / states / grafana_dashboards.sls
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 {%- set grafana_server = salt['pillar.get']('grafana', {}) %}
6 {%- set grafana_dashboards_orig_dir = '/srv/salt/dashboards' %}
7 {%- set grafana_dashboards_dest_dir = '/var/lib/grafana/dashboards' %}
8
9 {%- if grafana_server %}
10 extra_grafana_dashboard_directory:
11   file.directory:
12     - name: {{ grafana_dashboards_dest_dir }}
13     - require:
14       - pkg: grafana-package-install-pkg-installed
15
16 extra_grafana_dashboard_default_yaml:
17   file.managed:
18     - name: /etc/grafana/provisioning/dashboards/default.yaml
19     - contents: |
20         apiVersion: 1
21         providers:
22           - name: 'General'
23             folder: 'Arvados Cluster'
24             type: file
25             options:
26               path: {{ grafana_dashboards_dest_dir }}
27     - require:
28       - pkg: grafana-package-install-pkg-installed
29       - file: extra_grafana_dashboard_directory
30
31 extra_grafana_dashboard_files:
32   file.copy:
33     - name: {{ grafana_dashboards_dest_dir }}
34     - source: {{ grafana_dashboards_orig_dir }}
35     - force: true
36     - recurse: true
37     - require:
38       - file: extra_grafana_dashboard_default_yaml
39
40 extra_grafana_dashboards_service_restart:
41   cmd.run:
42     - name: systemctl restart grafana-server
43     - require:
44       - file: extra_grafana_dashboard_default_yaml
45     - onchanges:
46       - file: extra_grafana_dashboard_default_yaml
47       - file: extra_grafana_dashboard_files
48 {%- endif %}