first commit

This commit is contained in:
ace 2023-08-10 17:12:28 +03:00
commit c3c1c7de07
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
8 changed files with 83 additions and 0 deletions

0
README.md Normal file
View File

2
defaults/main.yaml Normal file
View File

@ -0,0 +1,2 @@
node_exporter_version: "1.5.0"
node_exporter_install_official_repo: true

8
meta/main.yaml Normal file
View File

@ -0,0 +1,8 @@
---
galaxy_info:
description: node_exporter
galaxy_tags:
- node_exporter
- exporter
dependencies: []

20
tasks/Debian.yaml Normal file
View File

@ -0,0 +1,20 @@
---
- name: Add the user 'prometheus' for node_exporter
ansible.builtin.user:
name: prometheus
shell: /usr/sbin/nologin
append: yes
home: /var/lib/prometheus
- name: Ensure {{ node_exporter_package }} installed
apt:
name: "{{ node_exporter_package }}"
state: present
- name: Enable and start node_exporter
systemd:
name: "{{ node_exporter_unit_name }}"
state: started
enabled: yes
masked: no
daemon_reload: yes

13
tasks/RedHat.yaml Normal file
View File

@ -0,0 +1,13 @@
---
- name: Ensure node_exporter version {{ node_exporter_version }} installed
dnf:
name: "node_exporter-{{ node_exporter_version }}"
state: present
- name: Enable and start node_exporter
systemd:
name: node_exporter
state: started
enabled: yes
masked: no
daemon_reload: yes

17
tasks/main.yaml Normal file
View File

@ -0,0 +1,17 @@
---
- name: Load a variable file based on the OS type
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
- "{{ ansible_facts['os_family'] }}.yaml"
paths:
- "vars"
tags: node_exporter_vars
- name: Include node_exporter install
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"

9
vars/Debian.yaml Normal file
View File

@ -0,0 +1,9 @@
node_exporter_apt_repository:
- repo: deb [trusted=yes] https://mirror.0xace.cc/debian/custom/ default all
filename: mirror.0xace.cc
node_exporter_package_name: "node-exporter"
node_exporter_package: "{{ node_exporter_package_name }}={{ node_exporter_version }}-{{ node_exporter_version_build }}"
node_exporter_version_build: "1"
node_exporter_unit_name: "node_exporter"

14
vars/RedHat.yaml Normal file
View File

@ -0,0 +1,14 @@
node_exporter_rpm_repository:
- name: "prometheus"
file: "prometheus"
description: "Prometheus repository"
baseurl: "https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch"
repo_gpgcheck: yes
gpgcheck: yes
gpgkey: >-
https://packagecloud.io/prometheus-rpm/release/gpgkey
https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
node_exporter_package_name: "node_exporter"
node_exporter_package: "{{ node_exporter_package_name }}-{{ node_exporter_version }}"
node_exporter_unit_name: "{{ node_exporter_package_name }}"