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

Commit 9398d4f

Browse files
authored
Merge pull request #94 from cloudalchemy/issue90
[minor] allow `latest` as prometheus_version
2 parents a5ff80e + fb8d551 commit 9398d4f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

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

2424
| Name | Default Value | Description |
2525
| -------------- | ------------- | -----------------------------------|
26-
| `prometheus_version` | 2.2.1 | Prometheus package version |
26+
| `prometheus_version` | 2.2.1 | Prometheus package version. Also accepts `latest` as parameter. |
2727
| `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration |
2828
| `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database |
2929
| `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening |

tasks/preflight.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,21 @@
5050
when: not prometheus_config_dir + "/file_sd/" + item.key + ".yml" in file_sd_files
5151
# when: not item | basename | splitext | difference(['.yml']) | join('') in prometheus_targets.keys()
5252
with_dict: "{{ prometheus_targets }}"
53+
54+
- block:
55+
- name: get latest release
56+
uri:
57+
url: "https://api.github.com/repos/prometheus/prometheus/releases/latest"
58+
method: GET
59+
return_content: yes
60+
status_code: 200
61+
body_format: json
62+
validate_certs: no
63+
register: _latest_release
64+
until: result.status == 200
65+
retries: 5
66+
67+
- name: "Set prometheus version to {{ _latest_release.json.tag_name[1:] }}"
68+
set_fact:
69+
prometheus_version: "{{ _latest_release.json.tag_name[1:] }}"
70+
when: prometheus_version == "latest"

0 commit comments

Comments
 (0)