first commit
This commit is contained in:
78
README.md
Normal file
78
README.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
Ansible-Role: Node exporter
|
||||||
|
=========
|
||||||
|
|
||||||
|
This role installs [node-exporter](https://github.com/prometheus/node_exporter) for the prometeus metrics server and configures the systemd service
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
|
1: go to the roles folder
|
||||||
|
2: cloning the repository git clone url node_exporter
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
N/A
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
---
|
||||||
|
#### General
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
NE_version: 'latest'
|
||||||
|
NE_arch: 'amd64'
|
||||||
|
NE_host: ''
|
||||||
|
NE_port: 9100
|
||||||
|
NE_options: ''
|
||||||
|
```
|
||||||
|
- NE_version: Node_exporter version
|
||||||
|
- NE_arch: System architecture
|
||||||
|
- NE_host: the IP address where node_exporter will listen
|
||||||
|
- NE_port: the port where node_exporter will listen (Don't forget to open it.)
|
||||||
|
- NE_optinos: Abstract attributes of node_exporter
|
||||||
|
#### Download
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
NE_download_url: https://github.com/prometheus/node_exporter/releases/download/v{{ NE_version }}/node_exporter-{{ NE_version }}.linux-{{ NE_arch }}.tar.gz
|
||||||
|
```
|
||||||
|
- NE_download_url generating the node_exporter download link
|
||||||
|
|
||||||
|
#### Setting systemd
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
NE_bin_path: /usr/local/bin/node_exporter
|
||||||
|
NE_state: started
|
||||||
|
NE_enabled: true
|
||||||
|
NE_restart: on-failure
|
||||||
|
```
|
||||||
|
- NE_bin_path The installation path of the binary file
|
||||||
|
- NE_state Start of the systemd service
|
||||||
|
- NE_enbaled Enabling systemd service startup
|
||||||
|
- NE_restart restarting node_exporter.service when it fails
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
no
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- role: node_exporter
|
||||||
|
```
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
1xtier
|
||||||
|
|
||||||
|
[github](https://github.com/1xtier)
|
||||||
|
|
||||||
|
[blog](https://1xtier.ru)
|
||||||
14
defaults/main.yml
Normal file
14
defaults/main.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
# General
|
||||||
|
NE_version: '1.10.2'
|
||||||
|
NE_arch: 'amd64'
|
||||||
|
NE_host: ''
|
||||||
|
NE_port: 9100
|
||||||
|
NE_options: ''
|
||||||
|
# Download
|
||||||
|
NE_download_url: https://github.com/prometheus/node_exporter/releases/download/v{{ NE_version }}/node_exporter-{{ NE_version }}.linux-{{ NE_arch }}.tar.gz
|
||||||
|
# Setting systemd
|
||||||
|
NE_bin_path: /usr/local/bin/node_exporter
|
||||||
|
NE_state: started
|
||||||
|
NE_enabled: true
|
||||||
|
NE_restart: on-failure
|
||||||
3
handlers/main.yml
Normal file
3
handlers/main.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# handlers file for node-exporter
|
||||||
30
meta/main.yml
Normal file
30
meta/main.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
dependencies: []
|
||||||
|
galaxy_info:
|
||||||
|
author: 1xtier
|
||||||
|
role_name: node_exporter
|
||||||
|
description: Installing node-exporter
|
||||||
|
company: RedFex
|
||||||
|
license: license (MIT)
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
platforms:
|
||||||
|
- name: GenericUNIX
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
- name: Fedora
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
galaxy_tags:
|
||||||
|
- system
|
||||||
|
- monitoring
|
||||||
|
- prometheus
|
||||||
|
- node
|
||||||
|
- exporter
|
||||||
|
- metrics
|
||||||
|
|
||||||
38
tasks/main.yml
Normal file
38
tasks/main.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
- name: Downloading node-exporter
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: "{{ NE_download_url }}"
|
||||||
|
dest: /tmp
|
||||||
|
mode: 0755
|
||||||
|
remote_src: yes
|
||||||
|
|
||||||
|
- name: Copying the node_exporter bin file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "/tmp/node_exporter-{{ NE_version }}.linux-{{NE_arch }}/node_exporter"
|
||||||
|
dest: "{{ NE_bin_path }}"
|
||||||
|
mode: 0755
|
||||||
|
remote_src: yes
|
||||||
|
|
||||||
|
- name: "Installing node-exporter"
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "nodeusr"
|
||||||
|
shell: "/bin/false"
|
||||||
|
create_home: false
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: I copy the node_exporter.service file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: node_exporter.service.j2
|
||||||
|
dest: /etc/systemd/system/node_exporter.service
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: re-reading the systemd configuration
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Starting node_exoporter.service
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: node_exporter.service
|
||||||
|
state: "{{ NE_state }}"
|
||||||
|
enabled: "{{ NE_enabled }}"
|
||||||
14
templates/node_exporter.service.j2
Normal file
14
templates/node_exporter.service.j2
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Node Exporter Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=nodeusr
|
||||||
|
Group=nodeusr
|
||||||
|
Type=simple
|
||||||
|
ExecStart={{ NE_bin_path }} --web.listen-address={{ NE_host }}:{{ NE_port }} {{ NE_options }}
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
Restart={{ NE_restart }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
3
tests/inventory
Normal file
3
tests/inventory
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
localhost
|
||||||
|
|
||||||
6
tests/test.yml
Normal file
6
tests/test.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- node-exporter
|
||||||
3
vars/main.yml
Normal file
3
vars/main.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# vars file for node-exporter
|
||||||
Reference in New Issue
Block a user