Add node_explorer
This commit is contained in:
parent
b0074be80e
commit
cdcd75e20d
18
main.yml
18
main.yml
@ -4,15 +4,16 @@
|
||||
# - ssh
|
||||
# - ubuntu
|
||||
#
|
||||
- hosts: prusa
|
||||
roles:
|
||||
- ssh
|
||||
- octoprint
|
||||
- ubuntu
|
||||
|
||||
#- hosts: docker_cluster
|
||||
#- hosts: prusa
|
||||
# roles:
|
||||
# - ssh
|
||||
# - octoprint
|
||||
# - ubuntu
|
||||
|
||||
- hosts: docker_cluster
|
||||
roles:
|
||||
- node_explorer
|
||||
# - ssh
|
||||
# - docker-cluster
|
||||
# - ubuntu
|
||||
#
|
||||
@ -24,3 +25,6 @@
|
||||
# roles:
|
||||
# - router
|
||||
|
||||
#- hosts: iron-man
|
||||
# roles:
|
||||
# - ssh
|
||||
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=node_exporter
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
User=prometheus
|
||||
Group=prometheus
|
||||
Type=simple
|
||||
ExecStart=/usr/local/sbin/node_exporter
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
10
roles/node_explorer/tasks/account.yml
Normal file
10
roles/node_explorer/tasks/account.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: create prometheus account
|
||||
become: yes
|
||||
user:
|
||||
name: prometheus
|
||||
comment: Octoprint account
|
||||
system: yes
|
||||
password_lock: yes
|
||||
home: /nonexistent
|
||||
create_home: no
|
32
roles/node_explorer/tasks/install.yml
Normal file
32
roles/node_explorer/tasks/install.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: Create temp dir
|
||||
file:
|
||||
path: /tmp/node_exporter
|
||||
state: directory
|
||||
|
||||
- name: Download node-explorer
|
||||
unarchive:
|
||||
src: https://github.com/prometheus/node_exporter/releases/download/v{{version}}/node_exporter-{{version}}.linux-arm64.tar.gz
|
||||
dest: /tmp/node_exporter
|
||||
remote_src: yes
|
||||
mode: 0755
|
||||
|
||||
- name: get folder name
|
||||
shell: ls /tmp/node_exporter
|
||||
register: dir_name
|
||||
|
||||
- name: Move to /usr/local/sbin
|
||||
become: yes
|
||||
command: cp -ra /tmp/node_exporter/{{ dir_name.stdout }}/node_exporter /usr/local/sbin/node_exporter
|
||||
|
||||
- name: Remove temp directory
|
||||
become: yes
|
||||
file:
|
||||
path: /tmp/node_exporter
|
||||
state: absent
|
||||
|
||||
- name: change chmod
|
||||
become: yes
|
||||
file:
|
||||
path: /usr/local/bin/node_exporter
|
||||
mode: '0755'
|
6
roles/node_explorer/tasks/main.yml
Normal file
6
roles/node_explorer/tasks/main.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- import_tasks: account.yml
|
||||
|
||||
- import_tasks: install.yml
|
||||
|
||||
- import_tasks: service.yml
|
13
roles/node_explorer/tasks/service.yml
Normal file
13
roles/node_explorer/tasks/service.yml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
- become: yes
|
||||
block:
|
||||
- name: copy systemd service config
|
||||
copy:
|
||||
src: lib/systemd/system/node_explorer.service
|
||||
dest: /lib/systemd/system/node_explorer.service
|
||||
|
||||
- name: enable systemd service
|
||||
systemd:
|
||||
name: node_explorer
|
||||
enabled: yes
|
||||
state: started
|
2
roles/node_explorer/vars/main.yml
Normal file
2
roles/node_explorer/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
version: 1.2.2
|
Loading…
Reference in New Issue
Block a user