-
Notifications
You must be signed in to change notification settings - Fork 0
/
node-exporter.yaml
79 lines (68 loc) · 1.99 KB
/
node-exporter.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
- hosts: all
become: true
vars:
packages:
download_url: https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
package_name: node_exporter-1.6.1.linux-amd64.tar.gz
temp_dir: /tmp
tasks:
- name: Download Node Exporter
get_url:
url: "{{ packages.download_url }}"
dest: "{{ temp_dir }}"
- name: Extract Node Exporter
unarchive:
src: "{{ temp_dir }}/{{ packages.package_name }}"
dest: "{{ temp_dir }}"
remote_src: yes
- name: Create prometheus group
group:
name: prometheus
state: present
- name: Create prometheus user
user:
name: prometheus
group: prometheus
shell: /sbin/nologin
system: yes
createhome: no
- name: Copy Node Exporter Binary Files
copy:
src: "{{ temp_dir }}/node_exporter-1.6.1.linux-amd64/node_exporter"
dest: /usr/local/bin
owner: root
mode: "0755"
group: root
remote_src: yes
- name: Creating Node Exporter Service Daemon
copy:
dest: "/etc/systemd/system/node-exporter.service"
content: |
[Unit]
Description=Prometheus exporter for machine metrics
[Service]
Restart=always
User=prometheus
ExecStart=/usr/local/bin/node_exporter
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
- name: Daemon Reload
systemd:
name: node-exporter
state: reloaded
- name: Start Node Exporter Service
systemd:
name: node-exporter
state: started
enabled: yes
- name: Clean Temporary Directory
file:
path: "{{ item }}"
state: absent
force: yes
with_items:
- "{{ temp_dir }}/node_exporter-1.6.1.linux-amd64"
- "{{ temp_dir }}/{{ packages.package_name }}"