fix(example): fix pillar.example formatting

This commit is contained in:
N 2019-06-22 22:34:37 +01:00
parent eda47f71e8
commit a13dd03af1
No known key found for this signature in database
GPG Key ID: 55A292EAB4E54067
9 changed files with 75 additions and 64 deletions

View File

@ -9,20 +9,21 @@ prometheus:
# no memcached_exporter in upstream repo - only archive # no memcached_exporter in upstream repo - only archive
# memcached_exporter # memcached_exporter
use_upstream_repo: False
use_upstream_archive: True use_upstream_archive: True
{%- if grains.os_family in ('CentOS',) %}
use_upstream_repo: False
{%- endif %}
pkg: pkg:
prometheus: prometheus:
archive_version: 2.10.0 archive_version: '2.10.0'
archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7 archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
repo: {}
alertmanager: alertmanager:
archive_version: '0.17.0' archive_version: '0.17.0'
archive_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569 archive_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
service: service:
prometheus prometheus:
args: args:
web.listen-address: 0.0.0.0:9090 web.listen-address: 0.0.0.0:9090
pushgateway: pushgateway:
@ -122,33 +123,33 @@ prometheus:
slack_api_url: "http://mysecret.example.com/" slack_api_url: "http://mysecret.example.com/"
http_config: http_config:
proxy_url: 'http://127.0.0.1:1025' proxy_url: 'http://127.0.0.1:1025'
route: route:
group_by: ['alertname', 'cluster', 'service'] group_by: ['alertname', 'cluster', 'service']
group_wait: 30s group_wait: 30s
group_interval: 5m group_interval: 5m
repeat_interval: 3h repeat_interval: 3h
receiver: team-X-mails receiver: team-X-mails
routes: routes:
- match_re: - match_re:
service: ^(foo1|foo2|baz)$ service: ^(foo1|foo2|baz)$
receiver: team-X-mails receiver: team-X-mails
routes: routes:
- match: - match:
severity: critical severity: critical
receiver: team-X-mails receiver: team-X-mails
receivers: receivers:
- name: 'team-X-mails' - name: 'team-X-mails'
email_configs: email_configs:
- to: 'team-X+alerts@example.org' - to: 'team-X+alerts@example.org'
inhibit_rules: inhibit_rules:
- name: opsGenie-receiver - name: opsGenie-receiver
opsgenie_configs: opsgenie_configs:
- api_key: mysecret - api_key: mysecret
- name: slack-receiver - name: slack-receiver
slack_configs: slack_configs:
- channel: '#my-channel' - channel: '#my-channel'
image_url: 'http://some.img.com/img.png' image_url: 'http://some.img.com/img.png'
linux: linux:
#'Alternatives system' priority: zero disables (default) #'Alternatives system' priority: zero disables (default)

View File

@ -17,8 +17,6 @@ prometheus-archive-clean-{{ name }}-file-absent:
file.absent: file.absent:
- names: - names:
- {{ p.dir.basedir }}/{{ name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) }} - {{ p.dir.basedir }}/{{ name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) }}
- require:
- sls: {{ sls_alternatives_clean }}
prometheus-archive-clean-{{ name }}-user-absent: prometheus-archive-clean-{{ name }}-user-absent:
user.absent: user.absent:
@ -27,13 +25,10 @@ prometheus-archive-clean-{{ name }}-user-absent:
- name: {{ name }} - name: {{ name }}
- require: - require:
- user: prometheus-archive-clean-{{ name }}-user-absent - user: prometheus-archive-clean-{{ name }}-user-absent
- sls: {{ sls_alternatives_clean }}
{%- endfor %} {%- endfor %}
prometheus-archive-clean-basedir-file-directory: prometheus-archive-clean-basedir-file-directory:
file.absent: file.absent:
- name: {{ p.dir.basedir }} - name: {{ p.dir.basedir }}
- require:
- sls: {{ sls_alternatives_clean }}

View File

@ -18,11 +18,12 @@ prometheus-config-file-basedir-file-directory:
- group: prometheus - group: prometheus
- mode: 755 - mode: 755
- makedirs: True - makedirs: True
# require: - require:
# sls: {{ sls_users_install }} - sls: '{{ sls_users_install }}.*'
{%- for name in p.wanted %} {%- for name in p.wanted %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %} {%- if name in p.pkg %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
prometheus-archive-install-{{ name }}-archive-extracted: prometheus-archive-install-{{ name }}-archive-extracted:
archive.extracted: archive.extracted:
@ -39,7 +40,7 @@ prometheus-archive-install-{{ name }}-archive-extracted:
- require: - require:
- file: prometheus-config-file-basedir-file-directory - file: prometheus-config-file-basedir-file-directory
{%- if name in p.service %} {%- if name in p.service %}
prometheus-archive-install-{{ name }}-file-directory: prometheus-archive-install-{{ name }}-file-directory:
file.directory: file.directory:
@ -76,5 +77,6 @@ prometheus-archive-install-{{ name }}-managed-service:
- file: prometheus-archive-install-{{ name }}-file-directory - file: prometheus-archive-install-{{ name }}-file-directory
- file: prometheus-config-file-basedir-file-directory - file: prometheus-config-file-basedir-file-directory
{%- endif %}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -21,7 +21,7 @@ prometheus-config-args-{{ name }}-data-dir:
file.absent: file.absent:
- name: {{ args['storage.tsdb.path'] }} - name: {{ args['storage.tsdb.path'] }}
- require: - require:
- sls: {{ sls_service_clean }} - sls: '{{ sls_service_clean }}.*'
{%- if grains.os_family == 'FreeBSD' %} {%- if grains.os_family == 'FreeBSD' %}
@ -51,6 +51,8 @@ prometheus-config-args-{{ name }}-file-absent:
- name: {{ prometheus.dir.args }}/{{ name }}.sh - name: {{ prometheus.dir.args }}/{{ name }}.sh
- require: - require:
- service: prometheus-service-clean-{{ name }}-service-dead - service: prometheus-service-clean-{{ name }}-service-dead
- require_in:
- file: prometheus-config-file-args-file-absent
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}

View File

@ -5,12 +5,13 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import concat_args %} {%- from tplroot ~ "/map.jinja" import concat_args %}
{%- set sls_config_install = tplroot ~ '.config' %} {%- set sls_config_users = tplroot ~ '.config.users' %}
{%- set sls_service_install = tplroot ~ '.service' %} {%- set sls_archive_install = tplroot ~ '.archive' %}
{%- set sls_package_install = tplroot ~ '.package' %}
include: include:
- {{ sls_service_install }} - {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
- {{ sls_config_install }} - {{ sls_config_users }}
prometheus-config-file-args-file-directory: prometheus-config-file-args-file-directory:
file.directory: file.directory:
@ -19,8 +20,8 @@ prometheus-config-file-args-file-directory:
- group: prometheus - group: prometheus
- mode: 755 - mode: 755
- makedirs: True - makedirs: True
# require: - require:
# sls: {{ sls_config_install }}.users - sls: '{{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}.*'
{%- for name in prometheus.wanted %} {%- for name in prometheus.wanted %}
{%- if name in prometheus.config or name in prometheus.service %} {%- if name in prometheus.config or name in prometheus.service %}
@ -51,6 +52,8 @@ prometheus-config-args-args-web-listen-address:
- value: {{ args.pop('web.listen-address') }} - value: {{ args.pop('web.listen-address') }}
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }}-service-running - service: prometheus-service-running-{{ name }}-service-running
- require:
- file: prometheus-config-file-args-file-directory
{%- endif %} {%- endif %}
{%- if 'collector.textfile.directory' in args.keys() %} {%- if 'collector.textfile.directory' in args.keys() %}
@ -61,6 +64,8 @@ prometheus-config-args-{{ name }}-collector-textfile-directory:
- value: {{ args.pop('collector.textfile.directory') }} - value: {{ args.pop('collector.textfile.directory') }}
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }}-service-running - service: prometheus-service-running-{{ name }}-service-running
- require:
- file: prometheus-config-file-args-file-directory
{%- endif %} {%- endif %}
{%- if 'storage.tsdb.path' in args.keys() %} {%- if 'storage.tsdb.path' in args.keys() %}
@ -71,6 +76,8 @@ prometheus-config-args-{{ name }}-{{ key }}:
- value: {{ args.pop('storage.tsdb.path') }} - value: {{ args.pop('storage.tsdb.path') }}
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }}-service-running - service: prometheus-service-running-{{ name }}-service-running
- require:
- file: prometheus-config-file-args-file-directory
{%- endif %} {%- endif %}
@ -82,6 +89,8 @@ prometheus-config-args-{{ name }}-all:
- value: "{{ concat_args(args) }} >/dev/null 2>&1" - value: "{{ concat_args(args) }} >/dev/null 2>&1"
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }}-service-running - service: prometheus-service-running-{{ name }}-service-running
- require:
- file: prometheus-config-file-args-file-directory
{%- elif grains.os_family != 'FreeBSD' %} {%- elif grains.os_family != 'FreeBSD' %}
@ -92,6 +101,8 @@ prometheus-config-args-{{ name }}-file-managed:
ARGS="{{ concat_args(args) }}" ARGS="{{ concat_args(args) }}"
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }}-service-running - service: prometheus-service-running-{{ name }}-service-running
- require:
- file: prometheus-config-file-args-file-directory
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}

View File

@ -15,11 +15,13 @@ include:
prometheus-config-file-{{ name }}-file-absent: prometheus-config-file-{{ name }}-file-absent:
file.absent: file.absent:
- name: {{ prometheus.dir.etc }}/{{ name }}.yml - name: {{ prometheus.dir.etc }}/{{ name }}.yml
- require: - require_in:
- sls: {{ sls_service_clean }} - file: prometheus-config-file-etc-file-absent
{%- endfor %} {%- endfor %}
prometheus-config-file-etc-file-absent: prometheus-config-file-etc-file-absent:
file.absent: file.absent:
- name: {{ prometheus.dir.etc }} - name: {{ prometheus.dir.etc }}
- require:
- sls: {{ sls_service_clean }}

View File

@ -5,13 +5,13 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_users_install = tplroot ~ '.config.users' %} {%- set sls_config_users = tplroot ~ '.config.users' %}
{%- set sls_archive_install = tplroot ~ '.archive' %} {%- set sls_archive_install = tplroot ~ '.archive' %}
{%- set sls_package_install = tplroot ~ '.package' %} {%- set sls_package_install = tplroot ~ '.package' %}
include: include:
- {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }} - {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
- {{ sls_users_install }} - {{ sls_config_users }}
prometheus-config-file-etc-file-directory: prometheus-config-file-etc-file-directory:
file.directory: file.directory:
@ -20,8 +20,8 @@ prometheus-config-file-etc-file-directory:
- group: prometheus - group: prometheus
- mode: 755 - mode: 755
- makedirs: True - makedirs: True
# require: - require:
# sls: {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }} - sls: '{{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}.*'
{%- for name in prometheus.wanted %} {%- for name in prometheus.wanted %}
{%- if name in prometheus.config or name in prometheus.service %} {%- if name in prometheus.config or name in prometheus.service %}
@ -41,8 +41,8 @@ prometheus-config-file-{{ name }}-file-managed:
- context: - context:
config: {{ '' if name not in prometheus.config else prometheus.config[name]|json }} config: {{ '' if name not in prometheus.config else prometheus.config[name]|json }}
- require: - require:
- user: prometheus-config-user-install-{{ name }}-user-present
- file: prometheus-config-file-etc-file-directory - file: prometheus-config-file-etc-file-directory
# user: prometheus-config-user-install-{{ name }}-user-present
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -18,7 +18,6 @@ prometheus:
etc: /etc/prometheus etc: /etc/prometheus
var: /var/lib/prometheus var: /var/lib/prometheus
args: /etc/default args: /etc/default
default: /etc/default
service: /usr/lib/systemd/system service: /usr/lib/systemd/system
service: service:
@ -29,6 +28,7 @@ prometheus:
config: config:
prometheus: {} prometheus: {}
alertmanager: {}
pkg: pkg:
prometheus: prometheus:

View File

@ -7,18 +7,16 @@
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %} {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/archive/defaults.yaml" as archive_defaults %}
{%- set defaults = salt['grains.filter_by'](default_settings, {%- set defaults = salt['grains.filter_by'](default_settings,
merge=salt['grains.filter_by'](archive_defaults, default='prometheus',
merge=salt['grains.filter_by'](osarchmap, grain='osarch', merge=salt['grains.filter_by'](osarchmap, grain='osarch',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family', merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['pillar.get']('prometheus:lookup', default={}), merge=salt['pillar.get']('prometheus:lookup', default={})
base='prometheus'), )
base='prometheus'), )
base='prometheus'), ) %}
base='prometheus')
%}
{#- Merge the prometheus pillar #} {#- Merge the prometheus pillar #}
{%- set prometheus = salt['pillar.get']('prometheus', default=defaults, merge=True) %} {%- set prometheus = salt['pillar.get']('prometheus', default=defaults, merge=True) %}