Skip to content

Commit

Permalink
Merge pull request #35 from rekup/fix/prom-rules
Browse files Browse the repository at this point in the history
fix: Copy prometheus rules from files instead of var
  • Loading branch information
janikvonrotz authored Jan 31, 2025
2 parents dd74171 + dccb5eb commit 062c39b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion roles/prometheus/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ prometheus_n8n_exporter_proxy_basic_auth_password: "'{{ vault_prometheus_n8n_exp
prometheus_meilisearch_exporter_api_key: "{{ vault_prometheus_meilisearch_exporter_api_key }}"
prometheus_uptime_kuma_exporter_basic_auth_password: "{{ vault_prometheus_uptime_kuma_exporter_basic_auth_password }}"
prometheus_alerting: {}
prometheus_rules: {}
prometheus_custom_scrapers: ""
# system.yml: |
# {% raw %}
Expand Down
22 changes: 16 additions & 6 deletions roles/prometheus/tasks/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@
ansible.builtin.debug:
msg: "{{ targets }}"

- name: Copy {{ role_name }} rules
ansible.builtin.copy:
dest: "{{ prometheus_data_dir }}/rules/{{ item }}"
content: "{{ lookup('ansible.builtin.template', 'rule.yml') }}"
loop: "{{ prometheus_rules.keys() }}"
notify: Reload {{ role_name }}
- name: Copy {{ role_name }} rules block
block:
- name: Copy {{ role_name }} rules
ansible.builtin.copy:
dest: "{{ prometheus_data_dir }}/rules/"
src: "{{ inventory_dir }}/prometheus_rules/{{ inventory_hostname }}/"
notify: Reload {{ role_name }}

rescue:
- name: Show warning
ansible.builtin.debug:
msg: |
Could not copy prometheus rules.
There is probably no rules directory on the ansible controll node.
If you would likt to copy rules, create them in the directory
{{ inventory_dir }}/prometheus_rules/{{ inventory_hostname }}/.
- name: Copy {{ role_name }} conf
ansible.builtin.template:
Expand Down
2 changes: 0 additions & 2 deletions roles/prometheus/templates/rule.yml

This file was deleted.

0 comments on commit 062c39b

Please sign in to comment.