From 311d6ce925f4ab5d2cdd116ff3e6f2ad0848019f Mon Sep 17 00:00:00 2001 From: Pijus Kamandulis Date: Thu, 30 May 2024 00:52:52 +0300 Subject: [PATCH] Configure prometheus node-exporter --- README.md | 3 +++ ansible/05-vpn.yml | 3 ++- ansible/06-prometheus-exporters.yml | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ansible/06-prometheus-exporters.yml diff --git a/README.md b/README.md index 10688e9..99541f5 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ mx1_fw: - name: wg0 allowed_tcp: - 22 # SSH + - 9100 # Prometheus node exporter mx2_fw: interfaces: - name: vio0 @@ -83,6 +84,7 @@ mx2_fw: - name: wg0 allowed_tcp: - 22 # SSH + - 9100 # Prometheus node exporter ``` The hosts are taken from the `inventory.yml` file: @@ -132,3 +134,4 @@ Current ansible playbooks: - 03-mail.yml - installs and configures dovecot and opensmtpd - 04-secondary-mail.yml - installs and configures opensmtpd as a backup mail receiver - 05-vpn.yml - configures wireguard vpn +- 06-prometheus-exporters.yml - installs prometheus exporters diff --git a/ansible/05-vpn.yml b/ansible/05-vpn.yml index 721d4af..82190e7 100644 --- a/ansible/05-vpn.yml +++ b/ansible/05-vpn.yml @@ -24,6 +24,7 @@ owner: root group: wheel mode: "0600" + register: wg_config - name: Create wireguard interface template: @@ -33,4 +34,4 @@ - name: Apply network configuration if changed shell: sh /etc/netstart {{ lookup('vars', inventory_hostname + '_wg').interface }} - when: iface_config.changed + when: wg_config.changed or iface_config.changed diff --git a/ansible/06-prometheus-exporters.yml b/ansible/06-prometheus-exporters.yml new file mode 100644 index 0000000..e2d7b9d --- /dev/null +++ b/ansible/06-prometheus-exporters.yml @@ -0,0 +1,19 @@ +- name: VPN Setup + hosts: + - mx1 + - mx2 + remote_user: root + vars_files: + - vars.yml + tasks: + - name: Install node-exporter + community.general.openbsd_pkg: + name: + - node_exporter + state: present + + - name: Enable and start node_exporter + service: + name: node_exporter + enabled: yes + state: started