prometheus_node: collect textfiles

This commit is contained in:
jeltz 2023-04-04 01:28:51 +02:00
parent 94953e1aa7
commit e160b98f0e
Signed by: jeltz
GPG key ID: 800882B66C0C3326
4 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,10 @@
---
- name: Run daemon-reload
systemd:
daemon_reload: true
- name: Restart prometheus-node-exporter
systemd:
name: prometheus-node-exporter.service
state: restarted
...

View file

@ -6,12 +6,41 @@
- prometheus-node-exporter-collectors
install_recommends: false # Do not install smartmontools
- name: Configure prometheus-node-exporter
template:
src: default.j2
dest: /etc/default/prometheus-node-exporter
owner: root
group: root
mode: u=rw,g=r,o=r
notify:
- Restart prometheus-node-exporter
- name: Install smartmontools
apt:
name: smartmontools
when:
- "ansible_virtualization_role == 'host'"
- name: Create override directory
file:
path: /etc/systemd/system/prometheus-node-exporter.service.d
state: directory
owner: root
group: root
mode: u=rwx,g=rw,o=rw
- name: Override prometheus-node-exporter.service
template:
src: override.conf.j2
dest: /etc/systemd/system/prometheus-node-exporter.service.d/override.conf
owner: root
group: root
mode: u=rw,g=r,o=r
notify:
- Run daemon-reload
- Restart prometheus-node-exporter
- name: Enable prometheus-node-exporter
systemd:
name: prometheus-node-exporter

View file

@ -0,0 +1,7 @@
{{ ansible_managed | comment }}
{% if prometheus_node__text_dir is defined %}
ARGS="--collector.textfile.directory={{ prometheus_node__text_dir | quote }}"
{% else %}
ARGS=""
{% endif %}

View file

@ -0,0 +1,4 @@
{{ ansible_managed | comment }}
[Service]
RuntimeDirectory=prometheus-node-exporter