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'] %}
|
|
|
|
{%- set service_name = p.pkg.component[name]['service']['get'](name, {}).get('name', name) %}
|
2019-10-04 12:13:24 +02:00
|
|
|
|
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 }}
|
2019-06-20 02:36:58 +02:00
|
|
|
- onlyif:
|
2020-05-14 01:27:23 +02:00
|
|
|
- {{ grains.kernel|lower == 'linux' }}
|
|
|
|
- systemctl list-units | 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
|
2019-06-08 19:39:21 +02:00
|
|
|
|
2020-05-14 01:27:23 +02:00
|
|
|
prometheus-service-running-{{ name }}:
|
2020-08-17 16:55:39 +02:00
|
|
|
{%- if p.wanted.firewall and grains.kernel|lower == 'linux' %}
|
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:
|
2019-10-04 12:13:24 +02:00
|
|
|
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
|
2020-05-14 01:27:23 +02:00
|
|
|
- enable: True
|
|
|
|
- require:
|
|
|
|
- sls: {{ sls_config_file }}
|
2020-08-17 16:55:39 +02:00
|
|
|
- names:
|
|
|
|
- {{ service_name }}
|
|
|
|
{%- if p.wanted.firewall and grains.kernel|lower == 'linux' %}
|
|
|
|
- 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 }}
|
|
|
|
{%- endif %}
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|