Skip to content

Commit

Permalink
use /etc/default/prometheus to configure args
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey4l committed Nov 23, 2018
1 parent c0f1a05 commit d1e3ceb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ prometheus_download_url: >-
# Valid options: [ remote, local ]
download_mode: remote

prometheus_args: >-
--config.file={{ prometheus_etc_path }}/prometheus.yml
--storage.tsdb.path={{ prometheus_data_path }}
--web.console.templates={{ prometheus_bin_path }}/consoles
--web.console.libraries={{ prometheus_bin_path }}/console_libraries
13 changes: 13 additions & 0 deletions molecule/lxc/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: check prometheus status
hosts: all
tasks:
- name: check the prometheus services
uri:
url: http://localhost:9090/api/v1/status/config
register: check_prometheus
retries: 3
delay: 3
until:
- check_prometheus.status == 200
- check_prometheus.json.status == 'success'
14 changes: 14 additions & 0 deletions tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
with_items:
- "{{ prometheus_etc_path }}"
- "{{ prometheus_etc_path }}/rules"
- /etc/default

- name: ensure data folder
file:
Expand All @@ -16,6 +17,19 @@
owner: "{{ prometheus_runas_user }}"
group: "{{ prometheus_runas_user }}"

- name: copy /etc/dfault/prometheus file
template:
src: "{{ item }}"
dest: /etc/default/prometheus
with_first_found:
- files:
- "default_prometheus.j2"
paths:
- "{{ playbook_dir }}/templates/{{ role_name }}"
- "{{ role_path }}/templates"
notify:
- restart prometheus service

- name: copy prometheus.yml file
vars:
filename: prometheus.yml
Expand Down
1 change: 0 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
name: prometheus
state: started
enabled: true
ignore_errors: true
# vim:ft=yaml
1 change: 1 addition & 0 deletions templates/default_prometheus.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ARGS="{{ prometheus_args }}"
16 changes: 8 additions & 8 deletions templates/prometheus.service.j2
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[Unit]
Description=prometheus service
Description=Monitoring system and time series database
Documentation=https://prometheus.io/docs/introduction/overview/

[Service]
Type=simple
Restart=always
EnvironmentFile=/etc/default/prometheus
ExecStart={{ prometheus_bin_path }}/prometheus $ARGS
ExecReload=/bin/kill -HUP $MAINPID
ExecStart={{ prometheus_bin_path }}/prometheus \
--config.file={{ prometheus_etc_path }}/prometheus.yml \
--storage.tsdb.path={{ prometheus_data_path }} \
--web.console.templates={{ prometheus_bin_path }}/consoles \
--web.console.libraries={{ prometheus_bin_path }}/console_libraries
User={{ prometheus_runas_user }}
TimeoutStopSec=20s
SendSIGKILL=no

[Install]
WantedBy=default.target
WantedBy=multi-user.target

0 comments on commit d1e3ceb

Please sign in to comment.