2019-04-24 18:18:44 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
|
|
|
|
|
|
|
{#- Get the `tplroot` from `tpldir` #}
|
|
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
2019-06-22 19:24:19 +02:00
|
|
|
{%- set sls_config_args = tplroot ~ '.config.args' %}
|
|
|
|
{%- set sls_config_file = tplroot ~ '.config.file' %}
|
2019-04-24 18:18:44 +02:00
|
|
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
|
|
|
|
|
|
|
include:
|
2019-04-26 14:02:30 +02:00
|
|
|
- {{ sls_config_args }}
|
2019-04-24 18:18:44 +02:00
|
|
|
- {{ sls_config_file }}
|
|
|
|
|
2019-10-04 01:10:32 +02:00
|
|
|
{%- if 'prometheus' in prometheus.wanted %}
|
2019-06-22 19:24:19 +02:00
|
|
|
prometheus-config-file-var-file-directory:
|
|
|
|
file.directory:
|
|
|
|
- name: {{ prometheus.dir.var }}
|
|
|
|
- user: prometheus
|
|
|
|
- group: prometheus
|
|
|
|
- mode: 755
|
|
|
|
- makedirs: True
|
|
|
|
- require:
|
|
|
|
- file: prometheus-config-file-etc-file-directory
|
2019-10-04 01:10:32 +02:00
|
|
|
{%- endif %}
|
2019-06-22 19:24:19 +02:00
|
|
|
|
2019-06-20 02:36:58 +02:00
|
|
|
{%- for name in prometheus.wanted %}
|
|
|
|
{%- if name in prometheus.service %}
|
2019-10-04 12:13:24 +02:00
|
|
|
|
|
|
|
{%- set service_name = prometheus.service.get(name, {}).get('name', False) %}
|
|
|
|
{%- if not service_name %}
|
|
|
|
{%- set service_name = name %}
|
|
|
|
{%- endif %}
|
|
|
|
|
2019-06-23 15:04:48 +02:00
|
|
|
{%- if grains.kernel|lower == 'linux' %}
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
prometheus-service-running-{{ name }}-service-unmasked:
|
2019-06-08 19:39:21 +02:00
|
|
|
service.unmasked:
|
2019-10-04 12:13:24 +02:00
|
|
|
- name: {{ service_name }}
|
2019-10-04 01:10:32 +02:00
|
|
|
{%- if 'prometheus' in prometheus.wanted %}
|
2019-06-20 02:36:58 +02:00
|
|
|
- require:
|
2019-06-22 19:24:19 +02:00
|
|
|
- file: prometheus-config-file-var-file-directory
|
2019-10-04 01:10:32 +02:00
|
|
|
{%- endif %}
|
2019-06-20 02:36:58 +02:00
|
|
|
- onlyif:
|
2019-10-04 12:13:24 +02:00
|
|
|
- systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
|
2019-06-20 02:36:58 +02:00
|
|
|
{%- endif %}
|
2019-06-08 19:39:21 +02:00
|
|
|
|
2019-06-20 02:36:58 +02:00
|
|
|
prometheus-service-running-{{ name }}-service-running:
|
2019-04-24 18:18:44 +02:00
|
|
|
service.running:
|
2019-10-04 12:13:24 +02:00
|
|
|
- name: {{ service_name }}
|
2019-04-24 18:18:44 +02:00
|
|
|
- enable: True
|
2019-06-23 14:55:08 +02:00
|
|
|
{%- if name in prometheus.config %}
|
2019-04-24 18:18:44 +02:00
|
|
|
- watch:
|
2019-06-20 02:36:58 +02:00
|
|
|
- file: prometheus-config-file-{{ name }}-file-managed
|
2019-06-23 14:55:08 +02:00
|
|
|
{%- endif %}
|
2019-10-04 01:10:32 +02:00
|
|
|
{%- if 'prometheus' in prometheus.wanted %}
|
2019-04-24 18:18:44 +02:00
|
|
|
- require:
|
2019-06-22 19:24:19 +02:00
|
|
|
- file: prometheus-config-file-var-file-directory
|
2019-10-04 01:10:32 +02:00
|
|
|
{%- endif %}
|
2019-06-20 02:36:58 +02:00
|
|
|
{%- if grains.kernel|lower == 'linux' %}
|
2019-06-23 15:04:48 +02:00
|
|
|
- service: prometheus-service-running-{{ name }}-service-unmasked
|
2019-10-04 12:13:24 +02:00
|
|
|
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
|
2019-06-20 02:36:58 +02:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
|