ansible-collection-prometheus/roles/prometheus/tasks/configure.yml
gardar 2c075e3b15
fix(lint): warning lint errors
Signed-off-by: gardar <gardar@users.noreply.github.com>
2022-11-25 15:39:18 +00:00

69 lines
2 KiB
YAML

---
- name: Alerting rules file
ansible.builtin.template:
src: "alert.rules.j2"
dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules"
owner: root
ansible.builtin.group: prometheus
mode: 0640
validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s"
when:
- prometheus_alert_rules != []
notify:
- reload prometheus
- name: Copy custom alerting rule files
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ prometheus_config_dir }}/rules/"
owner: root
ansible.builtin.group: prometheus
mode: 0640
validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s"
with_fileglob: "{{ prometheus_alert_rules_files }}"
notify:
- reload prometheus
- name: Configure prometheus
ansible.builtin.template:
src: "{{ prometheus_config_file }}"
dest: "{{ prometheus_config_dir }}/prometheus.yml"
force: true
owner: root
ansible.builtin.group: prometheus
mode: 0640
validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s"
notify:
- reload prometheus
- name: Configure Prometheus web
ansible.builtin.template:
content: "{{ prometheus_web_config | to_nice_yaml(indent=2, sort_keys=False) }}"
dest: "{{ prometheus_config_dir }}/web.yml"
force: true
owner: root
ansible.builtin.group: prometheus
mode: 0640
- name: Configure prometheus static targets
ansible.builtin.template:
content: |
{{ item.value | to_nice_yaml(indent=2, sort_keys=False) }}
lstrip_blocks: true
dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml"
force: true
owner: root
group: prometheus
mode: 0640
with_dict: "{{ prometheus_targets }}"
when: prometheus_targets != {}
- name: Copy prometheus custom static targets
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ prometheus_config_dir }}/file_sd/"
force: true
owner: root
ansible.builtin.group: prometheus
mode: 0640
with_fileglob: "{{ prometheus_static_targets_files }}"