Skip to content

Commit

Permalink
feat: Support Prometheus 3.0
Browse files Browse the repository at this point in the history
Update prometheus role for 3.0.0.
* Update argument_specs.yml to reflect support of 3.x.
* Skip console templates on 3.x.

Fixes: #460

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Nov 17, 2024
1 parent 1231802 commit 9b36187
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion roles/prometheus/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
prometheus_version: 2.54.1
prometheus_version: 3.0.0
prometheus_binary_url: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/\
prometheus-{{ prometheus_version }}.{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"
prometheus_checksums_url: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/sha256sums.txt"
Expand Down
4 changes: 2 additions & 2 deletions roles/prometheus/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ argument_specs:
prometheus_version:
description:
- "Prometheus package version. Also accepts C(latest) as parameter."
- "Only prometheus 2.x is supported"
default: "2.54.1"
- "Prometheus >= 2.x is supported"
default: "3.0.0"
prometheus_binary_url:
description: "URL of the prometheus binaries .tar.gz file"
default: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def AnsibleDefaults():
("/etc/systemd/system/prometheus.service",
"storage.agent.path=/var/lib/prometheus"),
("/etc/systemd/system/prometheus.service",
"enable-feature=agent"),
"agent"),
])
def test_file_contents(host, file, content):
f = host.file(file)
Expand Down
2 changes: 0 additions & 2 deletions roles/prometheus/molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def test_directories(host, dirs):
"files",
[
"/etc/prometheus/prometheus.yml",
"/etc/prometheus/console_libraries/prom.lib",
"/etc/prometheus/consoles/prometheus.html",
"/etc/prometheus/scrape_configs/empty_scrapes.yml",
"/etc/systemd/system/prometheus.service",
"/usr/local/bin/prometheus",
Expand Down
3 changes: 3 additions & 0 deletions roles/prometheus/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
group: "{{ prometheus_system_group }}"
mode: 0775
loop:
- "{{ prometheus_config_dir }}/consoles"
- "{{ prometheus_config_dir }}/console_libraries"
- "{{ prometheus_config_dir }}/rules"
- "{{ prometheus_config_dir }}/file_sd"
- "{{ prometheus_config_dir }}/scrape_configs"
Expand All @@ -58,6 +60,7 @@
notify:
- restart prometheus
become: true
when: prometheus_version is version('3.0.0', '<')
tags:
- prometheus
- configure
Expand Down
4 changes: 4 additions & 0 deletions roles/prometheus/templates/prometheus.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ ExecStart={{ prometheus_binary_install_dir }}/prometheus \
{% else %}
--storage.tsdb.retention={{ prometheus_storage_retention }} \
{% endif %}
{% else %}
{% if prometheus_version is version('3.0.0', '>=') %}
--agent \
{% else %}
--enable-feature=agent \
{% endif %}
--storage.agent.path={{ prometheus_db_dir }} \
{% endif %}
{% if (prometheus_version is version('2.24.0', '>=')) and (prometheus_web_config.values() | map('length') | select('gt', 0) | list is any) %}
Expand Down

0 comments on commit 9b36187

Please sign in to comment.