2017-03-09 06:12:27 -05:00
|
|
|
{% from "prometheus/map.jinja" import server with context %}
|
|
|
|
{%- if server.enabled %}
|
|
|
|
|
2018-01-26 07:35:38 -05:00
|
|
|
prometheus_server_config_dir:
|
2017-05-17 10:00:52 -04:00
|
|
|
file.directory:
|
2018-01-26 07:35:38 -05:00
|
|
|
- name: {{ server.dir.config }}
|
2017-05-17 10:00:52 -04:00
|
|
|
- makedirs: True
|
|
|
|
|
2018-01-26 07:35:38 -05:00
|
|
|
prometheus_server_data_dir:
|
2017-05-17 10:00:52 -04:00
|
|
|
file.directory:
|
2018-01-26 07:35:38 -05:00
|
|
|
- name: {{ server.dir.data }}
|
2017-05-17 10:00:52 -04:00
|
|
|
- makedirs: True
|
|
|
|
- mode: 755
|
|
|
|
|
2018-01-26 07:35:38 -05:00
|
|
|
prometheus_server_config_file:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ server.dir.config }}/prometheus.yml
|
|
|
|
- source: salt://prometheus/files/server/prometheus.yml
|
|
|
|
- template: jinja
|
|
|
|
- defaults:
|
|
|
|
server: {{ server }}
|
|
|
|
- require:
|
|
|
|
- file: prometheus_server_config_dir
|
|
|
|
|
|
|
|
prometheus_server_alerts_file:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ server.dir.config }}/alerts.yml
|
|
|
|
- source: salt://prometheus/files/server/{{server.version}}/alerts.yml
|
|
|
|
- template: jinja
|
|
|
|
- defaults:
|
|
|
|
server: {{ server }}
|
|
|
|
- require:
|
|
|
|
- file: prometheus_server_config_dir
|
|
|
|
|
|
|
|
{%- if not server.get('is_container', True) %}
|
|
|
|
|
|
|
|
prometheus_server_packages:
|
|
|
|
pkg.installed:
|
|
|
|
- names: {{ server.pkgs }}
|
|
|
|
|
|
|
|
prometheus_server_default_file:
|
2017-03-09 06:12:27 -05:00
|
|
|
file.managed:
|
2018-01-26 07:35:38 -05:00
|
|
|
- name: /etc/default/prometheus
|
|
|
|
- source: salt://prometheus/files/server/default
|
|
|
|
- template: jinja
|
|
|
|
- defaults:
|
|
|
|
server: {{ server }}
|
2017-03-09 06:12:27 -05:00
|
|
|
|
2018-01-26 07:35:38 -05:00
|
|
|
{%- if grains.get('init') == 'systemd' %}
|
|
|
|
|
|
|
|
prometheus_server_systemd_config:
|
2017-03-09 06:12:27 -05:00
|
|
|
file.managed:
|
2018-01-26 07:35:38 -05:00
|
|
|
- name: /etc/systemd/system/prometheus.service
|
|
|
|
- source: salt://prometheus/files/server/service
|
|
|
|
- makedirs: true
|
|
|
|
- user: root
|
|
|
|
- group: root
|
|
|
|
- mode: 644
|
|
|
|
- template: jinja
|
|
|
|
- require:
|
|
|
|
- file: prometheus_server_default_file
|
|
|
|
|
|
|
|
prometheus_server_restart_systemd:
|
|
|
|
module.wait:
|
|
|
|
- name: service.systemctl_reload
|
|
|
|
- watch:
|
|
|
|
- file: prometheus_server_systemd_config
|
|
|
|
- watch_in:
|
|
|
|
- service: prometheus_server_service
|
|
|
|
|
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
|
2018-01-26 07:35:38 -05:00
|
|
|
prometheus_server_service:
|
|
|
|
service.running:
|
|
|
|
- name: prometheus
|
|
|
|
- enable: True
|
|
|
|
{%- if grains.get('noservices') %}
|
|
|
|
- onlyif: /bin/false
|
|
|
|
{%- endif %}
|
|
|
|
- watch:
|
|
|
|
{%- if grains.get('init') == 'systemd' %}
|
|
|
|
- file: prometheus_server_systemd_config
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
2018-01-26 07:35:38 -05:00
|
|
|
- file: prometheus_server_config_file
|
|
|
|
- file: prometheus_server_alerts_file
|
|
|
|
- require:
|
|
|
|
- file: prometheus_server_data_dir
|
|
|
|
- pkg: prometheus_server_packages
|
|
|
|
|
|
|
|
{%- endif %}
|
|
|
|
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|