prometheus-formula/prometheus/service/clean.sls

37 lines
1.2 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 %}
{%- 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-06-20 02:36:58 +02:00
prometheus-service-clean-{{ name }}:
service.dead:
- name: {{ service_name }}
- enable: False
{%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %}
file.absent:
- name: {{ p.dir.service }}{{ p.div }}{{ name }}.service
- require:
- service: prometheus-service-clean-{{ name }}
cmd.run:
- onlyif: {{ grains.kernel|lower == 'linux' }}
- name: systemctl daemon-reload
- require:
- file: prometheus-service-clean-{{ name }}
{%- if grains.os_family == 'FreeBSD' %}
sysrc.absent:
- name: {{ name }}_environ
- require:
- service: prometheus-service-clean-{{ name }}
2019-06-20 02:36:58 +02:00
{%- endif %}
2019-06-20 02:36:58 +02:00
{%- endif %}
{%- endfor %}