prometheus-formula/prometheus/archive/install.sls
N eda47f71e8
fix(repo): use_upstream_repo corrections; separate users state
BREAKING CHANGE:

The formula has been refactored to accomodate multiple packages,
archives, users, and repos. Update your pillars and top states
2019-06-22 21:46:24 +01:00

81 lines
2.6 KiB
Plaintext

# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_users_install = tplroot ~ '.config.users' %}
include:
- {{ sls_users_install }}
prometheus-config-file-basedir-file-directory:
file.directory:
- name: {{ p.dir.basedir }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
# require:
# sls: {{ sls_users_install }}
{%- for name in p.wanted %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
prometheus-archive-install-{{ name }}-archive-extracted:
archive.extracted:
- 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 }}
{{- format_kwargs(p.archive.kwargs) }}
- recurse:
- user
- group
- require:
- file: prometheus-config-file-basedir-file-directory
{%- if name in p.service %}
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
- file: prometheus-config-file-basedir-file-directory
prometheus-archive-install-{{ name }}-managed-service:
file.managed:
- name: {{ p.dir.service }}/{{ name }}.service
- source: {{ files_switch(['systemd.ini.jinja'],
lookup='prometheus-archive-install-{{ name }}-managed-service'
)
}}
- mode: 644
- user: root
- group: {{ p.rootgroup }}
- makedirs: True
- template: jinja
- context:
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
- file: prometheus-config-file-basedir-file-directory
{%- endif %}
{%- endfor %}