Add node_explorer

This commit is contained in:
Przemek Grondek 2021-09-19 17:34:38 +02:00
parent b0074be80e
commit cdcd75e20d
7 changed files with 87 additions and 7 deletions

View File

@ -4,15 +4,16 @@
# - ssh # - ssh
# - ubuntu # - ubuntu
# #
- hosts: prusa #- hosts: prusa
roles:
- ssh
- octoprint
- ubuntu
#- hosts: docker_cluster
# roles: # roles:
# - ssh # - ssh
# - octoprint
# - ubuntu
- hosts: docker_cluster
roles:
- node_explorer
# - ssh
# - docker-cluster # - docker-cluster
# - ubuntu # - ubuntu
# #
@ -24,3 +25,6 @@
# roles: # roles:
# - router # - router
#- hosts: iron-man
# roles:
# - ssh

View File

@ -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

View 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

View 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'

View File

@ -0,0 +1,6 @@
---
- import_tasks: account.yml
- import_tasks: install.yml
- import_tasks: service.yml

View 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

View File

@ -0,0 +1,2 @@
---
version: 1.2.2