Add prometheus role

Configured to include job definitions from /etc/prometheus/conf.d/*.yml.
This commit is contained in:
Timotej Lazar 2025-10-17 21:18:45 +02:00
parent f33a0b8a21
commit d347fd7215
4 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,3 @@
Install and configure prometheus.
Job definitions should be placed in /etc/prometheus/conf.d by roles using this one.

View file

@ -0,0 +1,2 @@
scrape_config_files:
- "conf.d/*.yml"

View file

@ -0,0 +1,5 @@
- name: reload prometheus
service:
name: prometheus
state: reloaded
when: "'handler' not in ansible_skip_tags"

View file

@ -0,0 +1,21 @@
- name: Install packages
package:
name:
- prometheus
- name: Create directory for prometheus configs
file:
path: /etc/prometheus/conf.d
state: directory
- name: Configure prometheus
copy:
dest: /etc/prometheus/
src: prometheus.yml
notify: reload prometheus
- name: Enable prometheus service
service:
name: prometheus
enabled: true
state: started