Skip to content

Commit

Permalink
Add prometheus node exporter to ubuntu hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Ward committed Apr 21, 2024
1 parent ee3cbb1 commit 01b5cad
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions roles/monitored/files/node_exporter_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
basic_auth_users:
prometheus: $2y$05$tarSVOn5jRue/nCuXooDNOaSwFWfG25DE.YuNwMZ.H4siiDEyEtEy
6 changes: 6 additions & 0 deletions roles/monitored/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
name: nagios-nrpe-server
state: reloaded
become: true

- name: Restart prometheus node exporter
service:
name: prometheus-node-exporter
state: restarted
become: true
4 changes: 4 additions & 0 deletions roles/monitored/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@
import_tasks: conntrackd.yml
tags: nrpe_conntrackd
when: "'device_roles_router' in group_names"
- name: Configure Prometheus node exporter
import_tasks: prometheus-node-exporter.yml
tags: prometheus_node_exporter
when: ansible_distribution_version is version('22.04', '>=') and ansible_distribution == 'Ubuntu'
39 changes: 39 additions & 0 deletions roles/monitored/tasks/prometheus-node-exporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: Install node exporter
ansible.builtin.apt:
name: prometheus-node-exporter
state: present
install_recommends: false

- name: Make node exporter config directory
file:
path: /etc/node_exporter
state: directory
owner: root
group: root
mode: 0755

- name: Deploy node exporter web config
ansible.builtin.copy:
src: node_exporter_config.yml
dest: /etc/node_exporter/config.yml
owner: root
group: root
mode: 0644
notify:
- Restart prometheus node exporter

- name: Modify node exporter defaults config
ansible.builtin.lineinfile:
path: /etc/default/prometheus-node-exporter
regexp: "^ARGS="
line: ARGS="--web.config='/etc/node_exporter/config.yml'"
state: present
notify:
- Restart prometheus node exporter

- name: Setup prometheus node exporter service
ansible.builtin.service:
name: prometheus-node-exporter
state: started
enabled: true

0 comments on commit 01b5cad

Please sign in to comment.