2022-09-22 14:38:42 +00:00
|
|
|
---
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Alerting rules file
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.template:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "alert.rules.j2"
|
|
|
|
dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules"
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: prometheus
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0640
|
|
|
|
validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s"
|
|
|
|
when:
|
|
|
|
- prometheus_alert_rules != []
|
|
|
|
notify:
|
|
|
|
- reload prometheus
|
|
|
|
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Copy custom alerting rule files
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.copy:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ prometheus_config_dir }}/rules/"
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: prometheus
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0640
|
|
|
|
validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s"
|
|
|
|
with_fileglob: "{{ prometheus_alert_rules_files }}"
|
|
|
|
notify:
|
|
|
|
- reload prometheus
|
|
|
|
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Configure prometheus
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.template:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "{{ prometheus_config_file }}"
|
|
|
|
dest: "{{ prometheus_config_dir }}/prometheus.yml"
|
|
|
|
force: true
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: prometheus
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0640
|
|
|
|
validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s"
|
|
|
|
notify:
|
|
|
|
- reload prometheus
|
|
|
|
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Configure Prometheus web
|
2023-01-11 19:42:15 +00:00
|
|
|
ansible.builtin.copy:
|
2022-11-25 10:37:52 +00:00
|
|
|
content: "{{ prometheus_web_config | to_nice_yaml(indent=2, sort_keys=False) }}"
|
2022-09-22 14:38:42 +00:00
|
|
|
dest: "{{ prometheus_config_dir }}/web.yml"
|
|
|
|
force: true
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: prometheus
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0640
|
|
|
|
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Configure prometheus static targets
|
2023-01-11 19:42:15 +00:00
|
|
|
ansible.builtin.copy:
|
2022-09-22 14:38:42 +00:00
|
|
|
content: |
|
2022-11-25 10:37:52 +00:00
|
|
|
{{ item.value | to_nice_yaml(indent=2, sort_keys=False) }}
|
2022-09-22 14:38:42 +00:00
|
|
|
dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml"
|
|
|
|
force: true
|
|
|
|
owner: root
|
2022-11-25 10:37:52 +00:00
|
|
|
group: prometheus
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0640
|
|
|
|
with_dict: "{{ prometheus_targets }}"
|
|
|
|
when: prometheus_targets != {}
|
|
|
|
|
2022-11-25 10:37:52 +00:00
|
|
|
- name: Copy prometheus custom static targets
|
2022-09-23 12:07:54 +00:00
|
|
|
ansible.builtin.copy:
|
2022-09-22 14:38:42 +00:00
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ prometheus_config_dir }}/file_sd/"
|
|
|
|
force: true
|
|
|
|
owner: root
|
2022-12-08 17:45:42 +00:00
|
|
|
group: prometheus
|
2022-09-22 14:38:42 +00:00
|
|
|
mode: 0640
|
|
|
|
with_fileglob: "{{ prometheus_static_targets_files }}"
|