infra-iac/install-metrics.yml

41 lines
1.1 KiB
YAML
Raw Normal View History

2024-12-10 19:22:04 +01:00
---
- 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