1
0
Fork 0
mirror of https://gitlab.com/s3lph/ansible-collection-prometheus synced 2024-11-22 17:51:01 +01:00
ansible-collection-prometheus/roles/prometheus_node/tasks/collectors.yml

43 lines
1.4 KiB
YAML
Raw Permalink Normal View History

2020-11-13 10:36:46 +01:00
---
- name: install collector script
template:
src: "{{ basename }}.j2"
dest: "/usr/local/bin/{{ basename }}"
mode: 0750
vars:
basename: "{{ item.value.template_base_name | default('prometheus-node-exporter-' + item.key + '.sh') }}"
loop: "{{ prometheus_textfile_collectors | dict2items }}"
- name: install collector config
copy:
content: "{{ item.value.config.content }}"
dest: "{{ item.value.config.filename }}"
when: "'config' in item.value"
loop: "{{ prometheus_textfile_collectors | dict2items }}"
- name: install collector service
template:
src: "prometheus-collector.service.j2"
dest: "/etc/systemd/system/prometheus-node-exporter-{{ item.key }}.service"
vars:
basename: "{{ item.value.template_base_name | default('prometheus-node-exporter-' + item.key + '.sh') }}"
loop: "{{ prometheus_textfile_collectors | dict2items }}"
notify:
- systemctl daemon-reload
- name: install collector timer
template:
src: "prometheus-collector.timer.j2"
dest: "/etc/systemd/system/prometheus-node-exporter-{{ item.key }}.timer"
loop: "{{ prometheus_textfile_collectors | dict2items }}"
notify:
- systemctl daemon-reload
- name: start and enable collector timer
systemd:
name: "prometheus-node-exporter-{{ item.key }}.timer"
state: started
enabled: yes
loop: "{{ prometheus_textfile_collectors | dict2items }}"