This repository was archived by the owner on Mar 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +13
-84
lines changed Expand file tree Collapse file tree 8 files changed +13
-84
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,8 @@ cache: pip
5
5
services :
6
6
- docker
7
7
env :
8
- - ANSIBLE='ansible>=2.3.0,<2.4.0' PROMETHEUS=1.8.2
9
- - ANSIBLE='ansible>=2.3.0,<2.4.0' PROMETHEUS=2.2.1
10
- - ANSIBLE='ansible>=2.4.0,<2.5.0' PROMETHEUS=1.8.2
11
- - ANSIBLE='ansible>=2.4.0,<2.5.0' PROMETHEUS=2.2.1
12
- - ANSIBLE='ansible>=2.5.0,<2.6.0' PROMETHEUS=1.8.2
13
- - ANSIBLE='ansible>=2.5.0,<2.6.0' PROMETHEUS=2.2.1
8
+ - ANSIBLE='ansible>=2.3.0,<2.4.0'
9
+ - ANSIBLE='ansible>=2.4.0,<2.5.0'
14
10
- ANSIBLE='ansible>=2.5.0,<2.6.0'
15
11
matrix :
16
12
fast_finish : true
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
24
24
25
25
| Name | Default Value | Description |
26
26
| -------------- | ------------- | -----------------------------------|
27
- | ` prometheus_version ` | 2.2.1 | Prometheus package version. Also accepts ` latest ` as parameter. |
27
+ | ` prometheus_version ` | 2.2.1 | Prometheus package version. Also accepts ` latest ` as parameter. Only prometheus 2.x is supported |
28
28
| ` prometheus_config_dir ` | /etc/prometheus | Path to directory with prometheus configuration |
29
29
| ` prometheus_db_dir ` | /var/lib/prometheus | Path to directory with prometheus database |
30
30
| ` prometheus_web_listen_address ` | "0.0.0.0:9090" | Address on which prometheus will be listening |
Original file line number Diff line number Diff line change 2
2
- name : Run role
3
3
hosts : all
4
4
any_errors_fatal : true
5
- pre_tasks :
6
- - name : Set prometheus version from PROMETHEUS environment variable
7
- set_fact :
8
- prometheus_version : " {{ lookup('env', 'PROMETHEUS') | default('latest') }}"
9
- - name : Set prometheus version to latest when not set previously
10
- set_fact :
11
- prometheus_version : " latest"
12
- when : prometheus_version == ""
13
- - name : Show prometheus version used in tests
14
- debug :
15
- var : prometheus_version
16
5
roles :
17
6
- ansible-prometheus
18
7
vars :
8
+ prometheus_version : latest
19
9
prometheus_config_dir : /opt/prom/etc
20
10
prometheus_db_dir : /opt/prom/lib
21
11
prometheus_web_listen_address : " 127.0.0.1:9090"
Original file line number Diff line number Diff line change 2
2
- name : Run role
3
3
hosts : all
4
4
any_errors_fatal : true
5
- pre_tasks :
6
- - name : Set prometheus version from PROMETHEUS environment variable
7
- set_fact :
8
- prometheus_version : " {{ lookup('env', 'PROMETHEUS') | default('latest') }}"
9
- - name : Set prometheus version to latest when not set previously
10
- set_fact :
11
- prometheus_version : " latest"
12
- when : prometheus_version == ""
13
- - name : Show prometheus version used in tests
14
- debug :
15
- var : prometheus_version
16
5
roles :
17
6
- ansible-prometheus
Original file line number Diff line number Diff line change 6
6
owner : root
7
7
group : prometheus
8
8
mode : 0640
9
- validate : " {{ prometheus_rules_validator }} "
9
+ validate : " /usr/local/bin/promtool check rules %s "
10
10
when :
11
11
- prometheus_alertmanager_config != []
12
12
- prometheus_alert_rules != []
20
20
owner : root
21
21
group : prometheus
22
22
mode : 0640
23
- validate : " {{ prometheus_rules_validator }} "
23
+ validate : " /usr/local/bin/promtool check rules %s "
24
24
with_fileglob :
25
25
- prometheus/rules/*
26
26
notify :
34
34
owner : root
35
35
group : prometheus
36
36
mode : 0640
37
- validate : " {{ prometheus_config_validator }} "
37
+ validate : " /usr/local/bin/promtool check config %s "
38
38
notify :
39
39
- reload prometheus
40
40
Original file line number Diff line number Diff line change 1
1
---
2
- - name : Set validator commands for prometheus 2.x
3
- set_fact :
4
- prometheus_config_validator : " /usr/local/bin/promtool check config %s"
5
- prometheus_rules_validator : " /usr/local/bin/promtool check rules %s"
6
- when : prometheus_version is version_compare('2.0.0', '>=')
7
-
8
- - name : Set validator commands for prometheus 1.x
9
- set_fact :
10
- prometheus_config_validator : " /usr/local/bin/promtool check-config %s"
11
- prometheus_rules_validator : " /usr/local/bin/promtool check-rules %s"
12
- when : prometheus_version is version_compare('2.0.0', '<')
13
-
14
2
- name : Check if extra config flags are duplicating ansible variables
15
3
fail :
16
4
msg : " Detected duplicate configuration entry. Please check your ansible variables and role README.md."
30
18
set_fact :
31
19
prometheus_metrics_path : " /{{ ( prometheus_web_external_url + '/metrics' ) | regex_replace('^(.*://)?(.*?)/') }}"
32
20
33
- - name : Set storage retention setting
34
- set_fact :
35
- prometheus_storage_retention : " {{ (prometheus_storage_retention | regex_search('\\ d+') | int ) * 24 }}h0m0s"
36
- when : prometheus_version is version_compare('2.0.0', '<')
37
-
38
21
- name : Fail when prometheus_config_flags_extra duplicates parameters set by other variables
39
22
fail :
40
23
msg : " Whooops. You are duplicating configuration. Please look at your prometheus_config_flags_extra and check against other variables in defaults/main.yml"
Original file line number Diff line number Diff line change 1
1
# {{ ansible_managed }}
2
- {% if prometheus_version is version_compare ('2.0.0' , '>=' ) %}
3
2
groups:
4
3
- name: ansible managed alert rules
5
4
rules:
6
5
{{ prometheus_alert_rules | to_nice_yaml(indent=2) | indent(2,False) }}
7
- {% else %}
8
- {% for alert in prometheus_alert_rules %}
9
- ALERT {{ alert.alert }}
10
- IF {{ alert.expr }}
11
- {% if 'for' in alert %}
12
- FOR {{ alert.for }}
13
- {% endif %}
14
- {% if 'labels' in alert %}
15
- LABELS {
16
- {% for key , value in alert .labels .items () %}
17
- {{ key }} = "{{ value }}"{{ "," if not loop.last else '' }}
18
- {% endfor %}
19
- }
20
- {% endif %}
21
- {% if 'annotations' in alert %}
22
- ANNOTATIONS {
23
- {% for key , value in alert .annotations .items () %}
24
- {{ key }} = "{{ value }}"{{ "," if not loop.last else '' }}
25
- {% endfor %}
26
- }
27
- {% endif %}
28
- {% endfor %}
29
- {% endif %}
Original file line number Diff line number Diff line change 1
- {% - if prometheus_version is version_compare ('2.0.0' , '>=' ) %}
2
- {% - set pre = '-' %}
3
- {% - else %}
4
- {% - set pre = '' %}
5
- {% - endif %}
6
1
# {{ ansible_managed }}
7
2
[Unit]
8
3
Description=Prometheus
@@ -15,12 +10,12 @@ User=prometheus
15
10
Group=prometheus
16
11
ExecReload=/bin/kill -HUP $MAINPID
17
12
ExecStart=/usr/local/bin/prometheus \
18
- {{ pre }} -config.file={{ prometheus_config_dir }}/prometheus.yml \
19
- {{ pre }}- storage.{{ ' tsdb' if prometheus_version is version_compare('2.0.0', '>=') else 'local' }} .path={{ prometheus_db_dir }} \
20
- {{ pre }}- storage.{{ ' tsdb' if prometheus_version is version_compare('2.0.0', '>=') else 'local' }} .retention={{ prometheus_storage_retention }} \
21
- {{ pre }} -web.listen-address={{ prometheus_web_listen_address }} \
22
- {{ pre }} -web.external-url={{ prometheus_web_external_url }}{% for flag , flag_value in prometheus_config_flags_extra .items () %} \
23
- {{ pre }} -{{ flag }}={{ flag_value }} {% endfor %}
13
+ - -config.file={{ prometheus_config_dir }}/prometheus.yml \
14
+ -- storage.tsdb.path={{ prometheus_db_dir }} \
15
+ -- storage.tsdb.retention={{ prometheus_storage_retention }} \
16
+ - -web.listen-address={{ prometheus_web_listen_address }} \
17
+ - -web.external-url={{ prometheus_web_external_url }}{% for flag , flag_value in prometheus_config_flags_extra .items () %} \
18
+ - -{{ flag }}={{ flag_value }} {% endfor %}
24
19
25
20
PrivateTmp=true
26
21
PrivateDevices=true
You can’t perform that action at this time.
0 commit comments