Add prometheus user and group variable. General clean up

This commit is contained in:
Ricardo Hernandez 2017-01-17 15:09:06 +00:00
parent ba6876042d
commit ad89540879
8 changed files with 48 additions and 31 deletions

View file

@ -1,5 +1,4 @@
{% from "prometheus/map.jinja" import prometheus with context %}
{%- set version_path = prometheus.alertmanager.install_dir ~ "/alertmanager-" ~ prometheus.alertmanager.version %}
include:
- prometheus.user
@ -10,20 +9,20 @@ alertmanager_tarball:
- source: {{ prometheus.alertmanager.source }}
- source_hash: {{ prometheus.alertmanager.source_hash }}
- archive_format: tar
- if_missing: {{ version_path }}
- if_missing: {{ prometheus.alertmanager.version_path }}
alertmanager_bin_link:
file.symlink:
- name: /usr/bin/alertmanager
- target: {{ version_path }}/alertmanager
- target: {{ prometheus.alertmanager.version_path }}/alertmanager
- require:
- archive: alertmanager_tarball
alertmanager_config:
file.serialize:
- name: {{ prometheus.alertmanager.args.config_file }}
- user: prometheus
- group: prometheus
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- dataset_pillar: prometheus:alertmanager:config
alertmanager_config:
@ -31,8 +30,8 @@ alertmanager_config:
- name: {{ prometheus.alertmanager.args.config_file }}
- source: salt://prometheus/files/config.jinja
- template: jinja
- user: prometheus
- group: prometheus
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- makedirs: True
- defaults:
data: {{ prometheus.alertmanager.config }}
@ -49,8 +48,8 @@ alertmanager_defaults:
alertmanager_storage_path:
file.directory:
- name: {{ prometheus.alertmanager.args.storage.path }}
- user: prometheus
- group: prometheus
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- makedirs: True
- watch:
- file: alertmanager_defaults
@ -75,5 +74,6 @@ alertmanager_service:
- enable: True
- reload: True
- watch:
- file: alertmanager_service_unit
- file: alertmanager_config
- file: alertmanager_bin_link

View file

@ -1,4 +1,6 @@
prometheus:
user: prometheus
group: prometheus
server:
version: 1.4.1.linux-amd64
install_dir: /opt
@ -17,7 +19,7 @@ prometheus:
config_file: /etc/alertmanager/alertmanager.yml
storage:
path: /var/lib/alertmanager
exporters:
exporter:
node:
version: 0.13.0.linux-amd64
install_dir: /opt

View file

@ -1,5 +1,4 @@
{% from "prometheus/map.jinja" import prometheus with context %}
{%- set version_path = prometheus.exporters.blackbox.install_dir ~ "/blackbox_exporter-" ~ prometheus.exporters.blackbox.version %}
include:
- prometheus.user
@ -9,13 +8,15 @@ blackbox_exporter_tarball:
- name: {{ prometheus.exporters.blackbox.install_dir }}
- source: {{ prometheus.exporters.blackbox.source }}
- source_hash: {{ prometheus.exporters.blackbox.source_hash }}
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- archive_format: tar
- if_missing: {{ version_path }}
- if_missing: {{ prometheus.exporter.blackbox.version_path }}
blackbox_exporter_bin_link:
file.symlink:
- name: /usr/bin/blackbox_exporter
- target: {{ version_path }}/blackbox_exporter
- target: {{ prometheus.exporter.blackbox.version_path }}/blackbox_exporter
- require:
- archive: blackbox_exporter_tarball
@ -45,5 +46,6 @@ blackbox_exporter_service:
- enable: True
- reload: True
- watch:
- file: blackbox_exporter_service_unit
- file: blackbox_exporter_defaults
- file: blackbox_exporter_bin_link

View file

@ -1,5 +1,4 @@
{% from "prometheus/map.jinja" import prometheus with context %}
{%- set version_path = prometheus.exporters.haproxy.install_dir ~ "/haproxy_exporter-" ~ prometheus.exporters.haproxy.version %}
include:
- prometheus.user
@ -9,13 +8,15 @@ haproxy_exporter_tarball:
- name: {{ prometheus.exporters.haproxy.install_dir }}
- source: {{ prometheus.exporters.haproxy.source }}
- source_hash: {{ prometheus.exporters.haproxy.source_hash }}
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- archive_format: tar
- if_missing: {{ version_path }}
- if_missing: {{ prometheus.exporter.haproxy.version_path }}
haproxy_exporter_bin_link:
file.symlink:
- name: /usr/bin/haproxy_exporter
- target: {{ version_path }}/haproxy_exporter
- target: {{ prometheus.exporter.haproxy.version_path }}/haproxy_exporter
- require:
- archive: haproxy_exporter_tarball
@ -45,5 +46,6 @@ haproxy_exporter_service:
- enable: True
- reload: True
- watch:
- file: haproxy_exporter_service_unit
- file: haproxy_exporter_defaults
- file: haproxy_exporter_bin_link

View file

@ -1,5 +1,4 @@
{% from "prometheus/map.jinja" import prometheus with context %}
{%- set version_path = prometheus.exporters.node.install_dir ~ "/node_exporter-" ~ prometheus.exporters.node.version %}
include:
- prometheus.user
@ -9,13 +8,15 @@ node_exporter_tarball:
- name: {{ prometheus.exporters.node.install_dir }}
- source: {{ prometheus.exporters.node.source }}
- source_hash: {{ prometheus.exporters.node.source_hash }}
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- archive_format: tar
- if_missing: {{ version_path }}
- if_missing: {{ prometheus.exporter.node.version_path }}
node_exporter_bin_link:
file.symlink:
- name: /usr/bin/node_exporter
- target: {{ version_path }}/node_exporter
- target: {{ prometheus.exporter.node.version_path }}/node_exporter
- require:
- archive: node_exporter_tarball
@ -43,5 +44,6 @@ node_exporter_service:
- enable: True
- reload: True
- watch:
- file: node_exporter_service_unit
- file: node_exporter_defaults
- file: node_exporter_bin_link

View file

@ -1,3 +1,10 @@
{% import_yaml 'prometheus/defaults.yaml' as defaults %}
{% do defaults.prometheus.alertmanager.update('version_path': defaults.prometheus.alertmanager.install_dir ~ "/alertmanager-" ~ defaults.prometheus.alertmanager.version) %}
{% do defaults.prometheus.server.update('version_path': defaults.prometheus.server.install_dir ~ "/prometheus-" ~ defaults.prometheus.server.version) %}
{% do defaults.prometheus.exporter.node.update('version_path': defaults.prometheus.exporter.node.install_dir ~ "/node_exporter-" ~ defaults.prometheus.exporter.node.version) %}
{% do defaults.prometheus.exporter.blackbox.update('version_path': defaults.prometheus.exporter.blackbox.install_dir ~ "/blackbox_exporter-" ~ defaults.prometheus.exporter.blackbox.version) %}
{% do defaults.prometheus.exporter.haproxy.update('version_path': defaults.prometheus.exporter.haproxy.install_dir ~ "/haproxy_exporter-" ~ defaults.prometheus.exporter.haproxy.version) %}
{% set prometheus = salt['pillar.get']('prometheus', default=defaults.prometheus, merge=True) %}

View file

@ -1,5 +1,4 @@
{% from "prometheus/map.jinja" import prometheus with context %}
{%- set version_path = prometheus.server.install_dir ~ "/prometheus-" ~ prometheus.server.version %}
include:
- prometheus.user
@ -10,20 +9,20 @@ prometheus_server_tarball:
- source: {{ prometheus.server.source }}
- source_hash: {{ prometheus.server.source_hash }}
- archive_format: tar
- if_missing: {{ version_path }}
- if_missing: {{ prometheus.server.version_path }}
prometheus_bin_link:
file.symlink:
- name: /usr/bin/prometheus
- target: {{ version_path }}/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
- group: prometheus
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- dataset_pillar: prometheus:server:config
prometheus_defaults:
@ -34,15 +33,15 @@ prometheus_defaults:
- defaults:
config_file: {{ prometheus.server.args.config_file }}
storage_local_path: {{ prometheus.server.args.storage.local_path }}
web_console_libraries: {{ version_path }}/console_libraries
web_console_templates: {{ version_path }}/consoles
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
- group: prometheus
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- makedirs: True
- watch:
- file: prometheus_defaults
@ -68,5 +67,6 @@ prometheus_service:
- enable: True
- reload: True
- watch:
- file: prometheus_service_unit
- file: prometheus_server_config
- file: prometheus_bin_link

View file

@ -1,9 +1,11 @@
prometheus_group:
group.present:
- name: prometheus
- name: {{ prometheus.group }}
- system: True
prometheus_user:
user.present:
- name: prometheus
- name: {{ prometheus.user }}
- home: /var/lib/prometheus
- gid_from_name: True
- gid: {{ prometheus.group }}
- system: True