summaryrefslogtreecommitdiff
path: root/roles/monitoring/prometheus/exporter/node/tasks/main.yml
blob: 2811c7594a8a71279f913c0bce596443769a9d52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
  ## TODO: pin version
- name: install apt packages
  apt:
    name:
    - prom-exporter-node
    - moreutils
    state: present

- name: create directory for textfile collector
  file:
    path: /var/lib/prometheus-node-exporter/textfile-collector
    state: directory

- name: generate systemd service unit
  template:
    src: service.j2
    dest: /etc/systemd/system/prometheus-node-exporter.service
  notify: restart prometheus-node-exporter

- name: make sure prometheus-node-exporter is enabled and started
  systemd:
    name: prometheus-node-exporter.service
    daemon_reload: yes
    state: started
    enabled: yes

- name: register exporter
  copy:
    content: |
      location = /node {
          proxy_pass http://127.0.0.1:9100/metrics;
      }
    dest: /etc/prometheus/exporter/node.locations
  notify: reload nginx

- name: create directory for textfile collector scripts
  file:
    path: /usr/local/share/prometheus-node-exporter
    state: directory

- name: install the apt textfile collector script
  when: ansible_pkg_mgr == "apt"
  vars:
    textfile_collector_name: "apt"
  include_tasks: textfile_collector_script.yml

- name: install all other textfile collector scripts
  loop: "{{ prometheus_exporter_node_textfile_collector_scripts }}"
  loop_control:
    loop_var: textfile_collector_name
  include_tasks: textfile_collector_script.yml