formula-prometheus-ng/prometheus/server.sls
Eric Renfro ce7512d643
Multiple changes in preparation for the "ng" fork.
* Changed references to salt://prometheus-ng/...
* Added generic templates for exporters.
* Added variables passed on to templates.
2019-05-08 16:09:25 -04:00

77 lines
2.4 KiB
Text

{% from "prometheus/map.jinja" import prometheus with context %}
include:
- prometheus.user
prometheus_server_tarball:
archive.extracted:
- name: {{ prometheus.server.install_dir }}
- source: {{ prometheus.server.source }}
- source_hash: {{ prometheus.server.source_hash }}
- archive_format: tar
- if_missing: {{ prometheus.server.version_path }}
prometheus_bin_link:
file.symlink:
- name: /usr/bin/prometheus
- target: {{ prometheus.server.version_path }}/prometheus
- require:
- archive: prometheus_server_tarball
prometheus_server_config:
file.serialize:
- name: {{ prometheus.server.args.config_file }}
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- dataset_pillar: prometheus:server:config
prometheus_defaults:
file.managed:
- name: /etc/default/prometheus
- source: salt://prometheus-ng/files/default-prometheus.jinja
- template: jinja
- defaults:
config_file: {{ prometheus.server.args.config_file }}
storage_local_path: {{ prometheus.server.args.storage.local_path }}
web_console_libraries: {{ prometheus.server.version_path }}/console_libraries
web_console_templates: {{ prometheus.server.version_path }}/consoles
{%- if prometheus.server.args.storage.local_path is defined %}
prometheus_storage_local_path:
file.directory:
- name: {{ prometheus.server.args.storage.local_path }}
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- makedirs: True
- watch:
- file: prometheus_defaults
{%- endif %}
prometheus_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/prometheus.service
- source: salt://prometheus-ng/files/prometheus.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/prometheus.conf
- source: salt://prometheus-ng/files/prometheus.upstart.jinja
{%- endif %}
- context:
user: {{ prometheus.user }}
group: {{ prometheus.group }}
bin_path: {{ prometheus.exporter.node.version_path }}
args: {{ prometheus.exporter.get('args', []) }}
- watch:
- file: prometheus_defaults
- require_in:
- file: prometheus_service
prometheus_service:
service.running:
- name: prometheus
- enable: True
- reload: True
- watch:
- file: prometheus_service_unit
- file: prometheus_server_config
- file: prometheus_bin_link