prometheus-formula/prometheus/service/running.sls
2019-10-04 22:56:17 +02:00

61 lines
1.8 KiB
Plaintext

# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_args = tplroot ~ '.config.args' %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
include:
- {{ sls_config_args }}
- {{ sls_config_file }}
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
{%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
{%- set service_name = prometheus.service.get(name, {}).get('name', False) %}
{%- if not service_name %}
{%- set service_name = name %}
{%- endif %}
{%- if grains.kernel|lower == 'linux' %}
prometheus-service-running-{{ name }}-service-unmasked:
service.unmasked:
- name: {{ service_name }}
- require:
- file: prometheus-config-file-var-file-directory
- onlyif:
- systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %}
prometheus-service-running-{{ name }}-service-running:
service.running:
- name: {{ service_name }}
- enable: True
{%- if name in prometheus.config %}
- watch:
- file: prometheus-config-file-{{ name }}-file-managed
{%- endif %}
- require:
- file: prometheus-config-file-var-file-directory
{%- if grains.kernel|lower == 'linux' %}
- service: prometheus-service-running-{{ name }}-service-unmasked
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %}
{%- endif %}
{%- endfor %}