first commit

This commit is contained in:
ace
2023-08-10 17:12:28 +03:00
commit c3c1c7de07
8 changed files with 83 additions and 0 deletions

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"