Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Commit b8ccdae

Browse files
authored
remove prometheus 1.8 support (#113)
[major]
1 parent 0dec19c commit b8ccdae

File tree

8 files changed

+13
-84
lines changed

8 files changed

+13
-84
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ cache: pip
55
services:
66
- docker
77
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'
1410
- ANSIBLE='ansible>=2.5.0,<2.6.0'
1511
matrix:
1612
fast_finish: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
2424

2525
| Name | Default Value | Description |
2626
| -------------- | ------------- | -----------------------------------|
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 |
2828
| `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration |
2929
| `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database |
3030
| `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening |

molecule/alternative/playbook.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,10 @@
22
- name: Run role
33
hosts: all
44
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
165
roles:
176
- ansible-prometheus
187
vars:
8+
prometheus_version: latest
199
prometheus_config_dir: /opt/prom/etc
2010
prometheus_db_dir: /opt/prom/lib
2111
prometheus_web_listen_address: "127.0.0.1:9090"

molecule/default/playbook.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,5 @@
22
- name: Run role
33
hosts: all
44
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
165
roles:
176
- ansible-prometheus

tasks/configure.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
owner: root
77
group: prometheus
88
mode: 0640
9-
validate: "{{ prometheus_rules_validator }}"
9+
validate: "/usr/local/bin/promtool check rules %s"
1010
when:
1111
- prometheus_alertmanager_config != []
1212
- prometheus_alert_rules != []
@@ -20,7 +20,7 @@
2020
owner: root
2121
group: prometheus
2222
mode: 0640
23-
validate: "{{ prometheus_rules_validator }}"
23+
validate: "/usr/local/bin/promtool check rules %s"
2424
with_fileglob:
2525
- prometheus/rules/*
2626
notify:
@@ -34,7 +34,7 @@
3434
owner: root
3535
group: prometheus
3636
mode: 0640
37-
validate: "{{ prometheus_config_validator }}"
37+
validate: "/usr/local/bin/promtool check config %s"
3838
notify:
3939
- reload prometheus
4040

tasks/preflight.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
---
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-
142
- name: Check if extra config flags are duplicating ansible variables
153
fail:
164
msg: "Detected duplicate configuration entry. Please check your ansible variables and role README.md."
@@ -30,11 +18,6 @@
3018
set_fact:
3119
prometheus_metrics_path: "/{{ ( prometheus_web_external_url + '/metrics' ) | regex_replace('^(.*://)?(.*?)/') }}"
3220

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-
3821
- name: Fail when prometheus_config_flags_extra duplicates parameters set by other variables
3922
fail:
4023
msg: "Whooops. You are duplicating configuration. Please look at your prometheus_config_flags_extra and check against other variables in defaults/main.yml"

templates/alert.rules.j2

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
# {{ ansible_managed }}
2-
{% if prometheus_version is version_compare('2.0.0', '>=') %}
32
groups:
43
- name: ansible managed alert rules
54
rules:
65
{{ 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 %}

templates/prometheus.service.j2

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
{%- if prometheus_version is version_compare('2.0.0', '>=') %}
2-
{%- set pre = '-' %}
3-
{%- else %}
4-
{%- set pre = '' %}
5-
{%- endif %}
61
# {{ ansible_managed }}
72
[Unit]
83
Description=Prometheus
@@ -15,12 +10,12 @@ User=prometheus
1510
Group=prometheus
1611
ExecReload=/bin/kill -HUP $MAINPID
1712
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 %}
2419

2520
PrivateTmp=true
2621
PrivateDevices=true

0 commit comments

Comments
 (0)