Grafana SaltStack Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.4 KiB

  1. {%- if pillar.get('grafana', {}).get('collector') %}
  2. {%- if pillar.grafana.collector.get('enabled', False) %}
  3. {%- set service_grains = {} %}
  4. {%- for service_name, service in pillar.items() %}
  5. {%- if service.get('_support', {}).get('grafana', {}).get('enabled', False) %}
  6. {%- macro load_grains_file(grains_fragment_file) %}{% include grains_fragment_file ignore missing %}{% endmacro %}
  7. {%- set grains_fragment_file = service_name+'/meta/grafana.yml' %}
  8. {%- set grains_yaml = load_grains_file(grains_fragment_file)|load_yaml %}
  9. {%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge=grains_yaml) %}
  10. {%- endif %}
  11. {%- endfor %}
  12. grain:
  13. grafana:
  14. grafana:
  15. {{ service_grains|yaml(False)|indent(6) }}
  16. {%- endif %}
  17. {%- endif %}
  18. minion:
  19. {%- if pillar.get('grafana', {}).client is defined %}
  20. grafana:
  21. {%- from "grafana/map.jinja" import client with context %}
  22. grafana_version: {{ client.server.get('version', 3) }}
  23. grafana:
  24. grafana_timeout: 3
  25. {%- if client.server.token is defined %}
  26. grafana_token: {{ client.server.token }}
  27. {%- else %}
  28. grafana_user: {{ client.server.user }}
  29. grafana_password: {{ client.server.password }}
  30. {%- endif %}
  31. grafana_url: '{{ client.server.get('protocol', 'http') }}://{{ client.server.host }}:{{ client.server.get('port', 80) }}'
  32. {%- endif %}