2019-06-08 19:39:21 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
|
|
|
|
|
|
|
{#- Get the `tplroot` from `tpldir` #}
|
|
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
2019-06-17 23:02:51 +02:00
|
|
|
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
|
2019-06-08 19:39:21 +02:00
|
|
|
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
|
2019-06-19 01:23:45 +02:00
|
|
|
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
|
2019-06-22 19:24:19 +02:00
|
|
|
{%- set sls_users_install = tplroot ~ '.config.users' %}
|
2019-06-08 19:39:21 +02:00
|
|
|
|
2019-06-22 19:24:19 +02:00
|
|
|
include:
|
|
|
|
- {{ sls_users_install }}
|
|
|
|
|
|
|
|
prometheus-config-file-basedir-file-directory:
|
2019-06-20 02:36:58 +02:00
|
|
|
file.directory:
|
2019-06-22 19:24:19 +02:00
|
|
|
- name: {{ p.dir.basedir }}
|
2019-06-20 02:36:58 +02:00
|
|
|
- user: prometheus
|
|
|
|
- group: prometheus
|
|
|
|
- mode: 755
|
|
|
|
- makedirs: True
|
2019-06-22 23:34:37 +02:00
|
|
|
- require:
|
|
|
|
- sls: '{{ sls_users_install }}.*'
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
{%- for name in p.wanted %}
|
2019-06-22 23:34:37 +02:00
|
|
|
{%- if name in p.pkg %}
|
|
|
|
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
|
2019-06-17 23:02:51 +02:00
|
|
|
|
2019-06-20 02:36:58 +02:00
|
|
|
prometheus-archive-install-{{ name }}-archive-extracted:
|
2019-06-08 19:39:21 +02:00
|
|
|
archive.extracted:
|
2019-06-20 02:36:58 +02:00
|
|
|
- name: {{ p.dir.basedir }}
|
|
|
|
- source: {{ p.archive.uri }}/{{ name }}/releases/download/v{{ p.pkg[name]['archive_version']
|
|
|
|
+ '/' + bundle + '.' + p.archive.suffix }}
|
|
|
|
- source_hash: {{ p.pkg[name]['archive_hash'] }}
|
|
|
|
- user: {{ name }}
|
|
|
|
- group: {{ name }}
|
2019-06-17 23:02:51 +02:00
|
|
|
{{- format_kwargs(p.archive.kwargs) }}
|
2019-06-16 02:22:14 +02:00
|
|
|
- recurse:
|
|
|
|
- user
|
|
|
|
- group
|
2019-06-22 19:24:19 +02:00
|
|
|
- require:
|
|
|
|
- file: prometheus-config-file-basedir-file-directory
|
2019-06-19 01:23:45 +02:00
|
|
|
|
2019-06-22 23:34:37 +02:00
|
|
|
{%- if name in p.service %}
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
prometheus-archive-install-{{ name }}-file-directory:
|
|
|
|
file.directory:
|
|
|
|
- name: {{ p.dir.var }}/{{ name }}
|
|
|
|
- user: {{ name }}
|
|
|
|
- group: {{ name }}
|
|
|
|
- mode: 755
|
|
|
|
- makedirs: True
|
|
|
|
- require:
|
|
|
|
- archive: prometheus-archive-install-{{ name }}-archive-extracted
|
2019-06-22 19:24:19 +02:00
|
|
|
- file: prometheus-config-file-basedir-file-directory
|
2019-06-20 02:36:58 +02:00
|
|
|
|
|
|
|
prometheus-archive-install-{{ name }}-managed-service:
|
2019-06-19 01:23:45 +02:00
|
|
|
file.managed:
|
2019-06-20 02:36:58 +02:00
|
|
|
- name: {{ p.dir.service }}/{{ name }}.service
|
2019-06-19 01:23:45 +02:00
|
|
|
- source: {{ files_switch(['systemd.ini.jinja'],
|
2019-06-20 02:36:58 +02:00
|
|
|
lookup='prometheus-archive-install-{{ name }}-managed-service'
|
2019-06-19 01:23:45 +02:00
|
|
|
)
|
|
|
|
}}
|
|
|
|
- mode: 644
|
|
|
|
- user: root
|
|
|
|
- group: {{ p.rootgroup }}
|
|
|
|
- makedirs: True
|
|
|
|
- template: jinja
|
|
|
|
- context:
|
2019-06-20 02:36:58 +02:00
|
|
|
desc: prometheus - {{ name }} service
|
|
|
|
name: {{ name }}
|
|
|
|
user: {{ name }}
|
|
|
|
group: {{ name }}
|
|
|
|
workdir: {{ p.dir.var }}/{{ name }}
|
|
|
|
start: {{ p.dir.basedir }}/{{ bundle }}/{{ name }} --config.file {{ p.dir.etc }}/{{ name }}.yml
|
|
|
|
stop: '' #not needed
|
|
|
|
- require:
|
|
|
|
- file: prometheus-archive-install-{{ name }}-file-directory
|
2019-06-22 19:24:19 +02:00
|
|
|
- file: prometheus-config-file-basedir-file-directory
|
2019-06-23 14:55:08 +02:00
|
|
|
cmd.run:
|
|
|
|
- name: systemctl daemon-reload
|
|
|
|
- require:
|
|
|
|
- file: prometheus-archive-install-{{ name }}-managed-service
|
2019-06-19 01:23:45 +02:00
|
|
|
|
2019-06-22 23:34:37 +02:00
|
|
|
{%- endif %}
|
2019-06-20 02:36:58 +02:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|