Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Copy prometheus rules from files instead of var #35

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.