Added metric collection to server

This commit is contained in:
Manuel Forcén Muñoz 2024-12-10 19:22:04 +01:00
parent d7c3b9cdaa
commit a7bbea491c
4 changed files with 1746 additions and 0 deletions

40
install-metrics.yml Normal file
View file

@ -0,0 +1,40 @@
---
- name: installing metrics storage
hosts: server
gather_facts: false
tasks:
- name: Create prometheus directory if it does not exist
ansible.builtin.file:
path: /opt/infra/prometheus
state: directory
mode: '0755'
- name: Create prometheus config file
ansible.builtin.copy:
src: prometheus/prometheus.yml
dest: /opt/infra/prometheus/prometheus.yml
- name: Install collectd
ansible.builtin.apt:
name: collectd
state: present
update_cache: yes
become: true
- name: Install collectd config file
ansible.builtin.copy:
src: collectd/collectd.conf
dest: /etc/collectd/collectd.conf
become: true
- name: Restart collectd service
ansible.builtin.systemd_service:
name: collectd.service
state: restarted
become: true
- name: Create prometheus compose file
ansible.builtin.copy:
src: prometheus/compose.yml
dest: /opt/infra/prometheus/compose.yml
- name: Deploy prometheus compose file
community.docker.docker_compose_v2:
project_src: /opt/infra/prometheus
files:
- compose.yml