From 712b818344f8ebbca25defa82ca968d38db6813a Mon Sep 17 00:00:00 2001 From: Jeffrey Serio Date: Wed, 2 Apr 2025 05:18:11 -0500 Subject: [PATCH] Update inventory, prometheus-clients.yml --- inventory.yml | 23 ++++++++--------------- prometheus-clients.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/inventory.yml b/inventory.yml index fe9ec28..f28914e 100644 --- a/inventory.yml +++ b/inventory.yml @@ -4,20 +4,9 @@ debianservers: ansible_user: jas ansible_host: hyperreal.headscale.moonshadow.dev ansible_python_interpreter: /usr/bin/python3 - auxnc-8g: - ansible_user: jas - ansible_host: auxnc-8g - ansible_python_interpreter: /usr/bin/python3 - headscale: - ansible_user: jas - ansible_host: headscale.headscale.moonshadow.dev - ansible_python_interpreter: /usr/bin/python3 - -almaservers: - hosts: - archive-warror: - ansible_user: jas - ansible_host: archive-warrior.headscale.moonshadow.dev + rpi400: + ansible_user: root + ansible_host: rpi400.headscale.moonshadow.dev ansible_python_interpreter: /usr/bin/python3 freebsdservers: @@ -26,6 +15,10 @@ freebsdservers: ansible_user: jas ansible_host: nas.headscale.moonshadow.dev ansible_python_interpreter: /usr/local/bin/python3 + moonshadow: + ansible_user: jas + ansible_host: moonshadow.headscale.moonshadow.dev + ansible_python_interpreter: /usr/local/bin/python3 promservers: hosts: @@ -37,4 +30,4 @@ promservers: promclients: children: debianservers: - almaservers: + freebsdservers: diff --git a/prometheus-clients.yml b/prometheus-clients.yml index d2689de..db27d76 100644 --- a/prometheus-clients.yml +++ b/prometheus-clients.yml @@ -4,3 +4,32 @@ - name: Import Node Exporter role import_role: name: prometheus.prometheus.node_exporter + when: ansible_service_mgr == "systemd" + + - name: Install Node Exporter on FreeBSD + community.general.pkgng: + name: "node_exporter" + state: latest + when: ansible_service_mgr == "bsdinit" + become: true + + - name: Enable node_exporter service on FreeBSD + ansible.builtin.shell: sysrc node_exporter_enable="YES" + when: ansible_service_mgr == "bsdinit" + register: node_exporter_enable + become: true + changed_when: '"node_exporter_enable: -> YES" in node_exporter_enable.stdout' + + - name: Check if node_exporter service is running on FreeBSD + ansible.builtin.shell: service node_exporter status + when: ansible_service_mgr == "bsdinit" + register: node_exporter_running + failed_when: '"node_exporter does not exist" in node_exporter_running.stdout' + changed_when: false + + - name: Start node_exporter service on FreeBSD + ansible.builtin.shell: service node_exporter start + when: + - ansible_service_mgr == "bsdinit" + - '"node_exporter is not running" in node_exporter_running.stdout' + become: true