feat: Support Prometheus 3.0 (#462)

Update prometheus role for 3.0.0.
* Update argument_specs.yml to reflect support of 3.x.
* Skip console templates on 3.x.

Fixes: https://github.com/prometheus-community/ansible/issues/460

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie 2024-11-18 14:44:55 +01:00 committed by GitHub
parent ef4eb15644
commit 818d67cd2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 11 additions and 6 deletions

View file

@ -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"

View file

@ -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"

View file

@ -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)

View file

@ -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",

View file

@ -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"
@ -58,6 +60,7 @@
notify:
- restart prometheus
become: true
when: prometheus_version is version('3.0.0', '<')
tags:
- prometheus
- configure

View file

@ -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) %}