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