2019-06-20 02:36:58 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
|
|
|
|
|
|
|
{#- Get the `tplroot` from `tpldir` #}
|
|
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
|
|
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
|
|
|
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
|
2019-06-22 23:34:37 +02:00
|
|
|
{%- set sls_config_users = tplroot ~ '.config.users' %}
|
2019-06-22 19:24:19 +02:00
|
|
|
{%- set sls_archive_install = tplroot ~ '.archive' %}
|
|
|
|
{%- set sls_package_install = tplroot ~ '.package' %}
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
include:
|
|
|
|
- {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
|
2019-06-22 23:34:37 +02:00
|
|
|
- {{ sls_config_users }}
|
2019-06-22 19:24:19 +02:00
|
|
|
|
|
|
|
prometheus-config-file-etc-file-directory:
|
|
|
|
file.directory:
|
|
|
|
- name: {{ prometheus.dir.etc }}
|
2019-10-04 01:10:32 +02:00
|
|
|
- user: root
|
|
|
|
- group: {{ prometheus.rootgroup }}
|
2019-06-22 19:24:19 +02:00
|
|
|
- mode: 755
|
|
|
|
- makedirs: True
|
2019-06-22 23:34:37 +02:00
|
|
|
- require:
|
|
|
|
- sls: '{{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}.*'
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
{%- for name in prometheus.wanted %}
|
|
|
|
{%- if name in prometheus.config or name in prometheus.service %}
|
|
|
|
|
|
|
|
prometheus-config-file-{{ name }}-file-managed:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ prometheus.dir.etc }}/{{ name }}.yml
|
|
|
|
- source: {{ files_switch(['config.yml.jinja'],
|
2019-12-12 06:38:58 +01:00
|
|
|
lookup='prometheus-config-file-file-managed'
|
2019-06-20 02:36:58 +02:00
|
|
|
)
|
|
|
|
}}
|
|
|
|
- mode: 644
|
|
|
|
- user: {{ name }}
|
|
|
|
- group: {{ name }}
|
|
|
|
- makedirs: True
|
|
|
|
- template: jinja
|
|
|
|
- context:
|
|
|
|
config: {{ '' if name not in prometheus.config else prometheus.config[name]|json }}
|
|
|
|
- require:
|
2019-06-22 23:34:37 +02:00
|
|
|
- user: prometheus-config-user-install-{{ name }}-user-present
|
2019-06-22 19:24:19 +02:00
|
|
|
- file: prometheus-config-file-etc-file-directory
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|