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 %}
|
|
|
|
|
|
|
|
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
|
|
|
|
{%- set sls_package_install = tplroot ~ '.package.install' %}
|
|
|
|
{%- set sls_config_users = tplroot ~ '.config.users' %}
|
|
|
|
|
|
|
|
include:
|
|
|
|
- {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
|
|
|
|
- {{ sls_config_users }}
|
|
|
|
|
|
|
|
prometheus-config-file-etc-file-directory:
|
|
|
|
file.directory:
|
|
|
|
- name: {{ p.dir.etc }}
|
2020-10-19 14:57:29 +02:00
|
|
|
- makedirs: True
|
|
|
|
{%- if grains.os != 'Windows' %}
|
|
|
|
- mode: '0755'
|
2020-05-14 01:27:23 +02:00
|
|
|
- user: {{ p.identity.rootuser }}
|
|
|
|
- group: {{ p.identity.rootgroup }}
|
2020-10-19 14:57:29 +02:00
|
|
|
{%- endif %}
|
2020-05-14 01:27:23 +02:00
|
|
|
- require:
|
|
|
|
- sls: {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
|
|
|
|
|
2021-05-28 01:16:17 +02:00
|
|
|
# This loop manages the main config file for each component
|
2020-05-14 01:27:23 +02:00
|
|
|
{%- for name in p.wanted.component %}
|
|
|
|
{%- if 'config' in p.pkg.component[name] and p.pkg.component[name]['config'] %}
|
|
|
|
|
|
|
|
prometheus-config-file-{{ name }}-file-managed:
|
|
|
|
file.managed:
|
2020-10-19 14:57:29 +02:00
|
|
|
- name: {{ p.dir.etc }}{{ p.div }}{{ name }}.yml
|
2020-05-14 01:27:23 +02:00
|
|
|
- source: {{ files_switch(['config.yml.jinja'],
|
|
|
|
lookup='prometheus-config-file-' ~ name ~ '-file-managed'
|
|
|
|
)
|
|
|
|
}}
|
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: 644
|
|
|
|
- user: {{ name }}
|
|
|
|
- group: {{ name }}
|
2020-10-19 14:57:29 +02:00
|
|
|
{%- endif %}
|
2020-05-14 01:27:23 +02:00
|
|
|
- context:
|
|
|
|
config: {{ p.pkg.component[name]['config']|json }}
|
|
|
|
- require:
|
|
|
|
- file: prometheus-config-file-etc-file-directory
|
2020-11-03 10:34:46 +01:00
|
|
|
- user: prometheus-config-users-install-{{ name }}-user-present
|
|
|
|
- group: prometheus-config-users-install-{{ name }}-group-present
|
2020-05-14 01:27:23 +02:00
|
|
|
- watch_in:
|
|
|
|
- service: prometheus-service-running-{{ name }}
|
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
2021-05-28 01:16:17 +02:00
|
|
|
|
|
|
|
# This loop manages other config files, like `rules_files`
|
|
|
|
{%- for ef in p.extra_files %}
|
|
|
|
{%- set name = p.extra_files[ef]['file'] | default(ef) %}
|
|
|
|
{%- set component = p.extra_files[ef]['component'] | default('prometheus') %}
|
|
|
|
|
|
|
|
prometheus-config-file-{{ ef }}-file-managed:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ p.dir.etc }}{{ p.div }}{{ name }}.yml
|
|
|
|
- source: {{ files_switch(['config.yml.jinja'],
|
|
|
|
lookup='prometheus-config-file-' ~ ef ~ '-file-managed'
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
- makedirs: True
|
|
|
|
- template: jinja
|
|
|
|
{%- if grains.os != 'Windows' %}
|
|
|
|
- mode: 644
|
|
|
|
- user: {{ component }}
|
|
|
|
- group: {{ component }}
|
|
|
|
{%- endif %}
|
|
|
|
- context:
|
|
|
|
config: {{ p.extra_files[ef]['config'] }}
|
|
|
|
- require:
|
|
|
|
- file: prometheus-config-file-etc-file-directory
|
|
|
|
- user: prometheus-config-users-install-{{ component }}-user-present
|
|
|
|
- group: prometheus-config-users-install-{{ component }}-group-present
|
|
|
|
- watch_in:
|
|
|
|
- service: prometheus-service-running-{{ component }}
|
|
|
|
|
|
|
|
{%- endfor %}
|