prometheus-formula/prometheus/service/running.sls

54 lines
1.8 KiB
Plaintext
Raw Normal View History

# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- set sls_config_environ = tplroot ~ '.config.environ' %}
include:
- {{ sls_config_file }}
- {{ sls_config_environ }}
{%- for name in p.wanted.component %}
{%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
{%- set service_name = p.pkg.component[name]['service'].get('name', name) %}
{%- if grains.kernel|lower == 'linux' %}
prometheus-service-running-{{ name }}-unmasked:
service.unmasked:
- name: {{ service_name }}
- onlyif: systemctl list-unit-files | grep {{ service_name }} >/dev/null 2>&1
- require_in:
- service: prometheus-service-running-{{ name }}
- require:
- sls: {{ sls_config_file }}
- file: prometheus-config-file-etc-file-directory
{%- endif %}
prometheus-service-running-{{ name }}:
{%- if grains.kernel|lower == 'linux' and p.wanted.firewall %}
pkg.installed:
- name: firewalld
- reload_modules: true
2020-08-17 16:55:39 +02:00
{%- endif %}
service.running:
- names:
- {{ service_name }}
- enable: True
- require:
- sls: {{ sls_config_file }}
{%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-unit-files | grep {{ service_name }} >/dev/null 2>&1
{%- if p.wanted.firewall %}
2020-08-17 16:55:39 +02:00
- firewalld
firewalld.present:
- name: public
- ports: {{ p.pkg.component[name]['firewall']['ports']|json }}
- require:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- endif %}
2019-06-20 02:36:58 +02:00
{%- endif %}
{%- endfor %}