2020-05-14 01:27:23 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
|
|
|
|
|
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
|
|
|
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
|
|
|
|
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
|
2021-06-24 15:55:09 +02:00
|
|
|
{%- from tplroot ~ "/files/macros.jinja" import concat_args %}
|
2020-05-14 01:27:23 +02:00
|
|
|
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
|
|
|
|
{%- set sls_package_install = tplroot ~ '.package.install' %}
|
2021-06-27 16:04:47 +02:00
|
|
|
{%- set sls_service_running = tplroot ~ '.service.running' %}
|
2020-05-14 01:27:23 +02:00
|
|
|
|
|
|
|
include:
|
|
|
|
- {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
|
2021-06-27 16:04:47 +02:00
|
|
|
- {{ sls_service_running }}
|
2020-05-14 01:27:23 +02:00
|
|
|
|
|
|
|
{%- for name in p.wanted.component %}
|
2021-06-24 15:55:09 +02:00
|
|
|
{%- if 'environ' in p.pkg.component[name] and 'args' in p.pkg.component[name]['environ'] %}
|
|
|
|
{%- set args = p.pkg.component[name]['environ']['args'] %}
|
2021-06-27 16:04:47 +02:00
|
|
|
{%- set arg_name = p.pkg.component[name]['environ']['environ_arg_name'] %}
|
2020-05-14 01:27:23 +02:00
|
|
|
{%- if 'environ_file' in p.pkg.component[name] and p.pkg.component[name]['environ_file'] %}
|
|
|
|
|
|
|
|
prometheus-config-install-{{ name }}-environ_file:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ p.pkg.component[name]['environ_file'] }}
|
|
|
|
- source: {{ files_switch(['environ.sh.jinja'],
|
|
|
|
lookup='prometheus-config-install-' ~ name ~ '-environ_file'
|
|
|
|
)
|
|
|
|
}}
|
2020-10-19 14:57:29 +02:00
|
|
|
- makedirs: True
|
|
|
|
- template: jinja
|
|
|
|
{%- if grains.os != 'Windows' %}
|
2020-05-14 01:27:23 +02:00
|
|
|
- mode: 640
|
|
|
|
- user: {{ p.identity.rootuser }}
|
|
|
|
- group: {{ p.identity.rootgroup }}
|
2020-10-19 14:57:29 +02:00
|
|
|
{%- endif %}
|
2021-06-24 15:55:09 +02:00
|
|
|
- context:
|
2021-06-24 18:25:35 +02:00
|
|
|
args: {{ concat_args(args) }}
|
2021-06-27 16:04:47 +02:00
|
|
|
arg_name: {{ arg_name }}
|
2020-05-14 01:27:23 +02:00
|
|
|
- watch_in:
|
|
|
|
- service: prometheus-service-running-{{ name }}
|
|
|
|
- require:
|
|
|
|
- sls: {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
|
|
|
|
|
|
|
|
{%- if grains.os_family == 'FreeBSD' %}
|
|
|
|
|
|
|
|
prometheus-config-environ-{{ name }}-all:
|
|
|
|
sysrc.managed:
|
|
|
|
- name: {{ name }}_environ
|
|
|
|
# service prometheus restart tends to hang on FreeBSD
|
|
|
|
# https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
|
2021-06-24 15:55:09 +02:00
|
|
|
- value: "{{ concat_args(p.pkg.component[name]['environ']) }} >/dev/null 2>&1"
|
2020-05-14 01:27:23 +02:00
|
|
|
- watch_in:
|
|
|
|
- service: prometheus-service-running-{{ name }}
|
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|