prometheus-formula/prometheus/service/running.sls

55 lines
1.6 KiB
Plaintext
Raw Normal View History

# -*- 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
2019-06-20 02:36:58 +02:00
{%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
prometheus-service-running-{{ name }}-service-unmasked:
service.unmasked:
2019-06-20 02:36:58 +02:00
- name: {{ name }}
- require:
- file: prometheus-config-file-var-file-directory
2019-06-20 02:36:58 +02:00
{%- if grains.kernel|lower == 'linux' %}
- onlyif:
- systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
{%- endif %}
2019-06-20 02:36:58 +02:00
prometheus-service-running-{{ name }}-service-running:
service.running:
2019-06-20 02:36:58 +02:00
- name: {{ name }}
- enable: True
2019-06-20 02:36:58 +02:00
{%- if name in prometheus.config %}
- watch:
2019-06-20 02:36:58 +02:00
- file: prometheus-config-file-{{ name }}-file-managed
{%- endif %}
- require:
2019-06-20 02:36:58 +02:00
- service: prometheus-service-running-{{ name }}-service-unmasked
- file: prometheus-config-file-var-file-directory
2019-06-20 02:36:58 +02:00
{%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
{%- endif %}
{%- endif %}
{%- endfor %}