1
0
Fork 0
mirror of synced 2024-11-05 01:08:57 -05:00
formula-grafana/grafana/collector.sls

51 lines
1.2 KiB
Text
Raw Normal View History

2016-10-22 06:30:30 -04:00
{%- from "grafana/map.jinja" import collector with context %}
{%- if collector.enabled %}
grafana_grains_dir:
file.directory:
- name: /etc/salt/grains.d
- mode: 700
- makedirs: true
- user: root
{%- set service_grains = {} %}
{# Loading the other service support metadata for localhost #}
{%- for service_name, service in pillar.iteritems() %}
{%- macro load_grains_file(grains_fragment_file) %}{% include grains_fragment_file ignore missing %}{% endmacro %}
{%- set grains_fragment_file = service_name+'/meta/grafana.yml' %}
{%- set grains_yaml = load_grains_file(grains_fragment_file)|load_yaml %}
{%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge=grains_yaml) %}
{%- endfor %}
grafana_grain:
file.managed:
- name: /etc/salt/grains.d/grafana
- source: salt://grafana/files/grafana.grain
- template: jinja
- user: root
- mode: 600
- defaults:
service_grains:
grafana: {{ service_grains|yaml }}
- require:
- file: grafana_grains_dir
grafana_grains_file:
cmd.wait:
- name: cat /etc/salt/grains.d/* > /etc/salt/grains
- watch:
- file: grafana_grain
grafana_grains_publish:
module.run:
- name: mine.update
- watch:
- cmd: grafana_grains_file
{%- endif %}