ansible-collection-prometheus/roles/prometheus/tasks/configure.yml
Stan Rudenko f637d5f7c9
removing prometheus_rules_enable, minor fixes
Signed-off-by: Stan Rudenko <stan@truera.com>
2023-08-24 10:24:56 -07:00

72 lines
2.1 KiB
YAML

---
- name: Alerting rules file
ansible.builtin.template:
src: "alert.rules.j2"
dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules"
owner: root
group: prometheus
mode: 0640
validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s"
when:
- prometheus_alert_rules != []
- not prometheus_agent_mode
notify:
- reload prometheus
- name: Copy custom alerting rule files
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ prometheus_config_dir }}/rules/"
owner: root
group: prometheus
mode: 0640
validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s"
with_fileglob: "{{ prometheus_alert_rules_files }}"
when:
- not prometheus_agent_mode
notify:
- reload prometheus
- name: Configure prometheus
ansible.builtin.template:
src: "{{ prometheus_config_file }}"
dest: "{{ prometheus_config_dir }}/prometheus.yml"
force: true
owner: root
group: prometheus
mode: 0640
validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s"
no_log: "{{ false if (lookup('env', 'CI')) or (lookup('env', 'MOLECULE_PROVISIONER_NAME')) else true }}"
notify:
- reload prometheus
- name: Configure Prometheus web
ansible.builtin.copy:
content: "{{ prometheus_web_config | to_nice_yaml(indent=2, sort_keys=False) }}"
dest: "{{ prometheus_config_dir }}/web.yml"
force: true
owner: root
group: prometheus
mode: 0640
- name: Configure prometheus static targets
ansible.builtin.copy:
content: |
{{ item.value | to_nice_yaml(indent=2, sort_keys=False) }}
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
group: prometheus
mode: 0640
with_fileglob: "{{ prometheus_static_targets_files }}"