ansible playbooks for retailor.io infrastructure

This commit is contained in:
2025-03-03 19:33:36 +01:00
committed by KevinMidboe
commit 92cb10ba27
139 changed files with 33603 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
---
- name: Create a Docker network for Grafana
docker_network:
name: monitoring_network
state: present
- name: Create grafana datasources directory on host
file:
path: /etc/grafana/datasources
state: directory
mode: "0755"
- name: Create grafana dashboards directory on host
file:
path: /etc/grafana/dashboards
state: directory
mode: "0755"
- name: Copy prometheus datasource config
template:
src: grafana-datasources.yml.j2
dest: /etc/grafana/datasources/prometheus.yml
- name: Copy grafana default dashboards config
template:
src: grafana-dashboards.yml.j2
dest: /etc/grafana/dashboards/grafana-dashboards.yml
- name: Copy grafana dashboards
copy:
src: "{{ item }}"
dest: /etc/grafana/dashboards/{{ item | basename | regex_replace('\.j2$', '') }}
loop: "{{ query('fileglob', 'templates/grafana-dashboards/*.json') }}"
- name: Pull Grafana Docker image
docker_image:
name: grafana/grafana-oss:latest
source: pull
- name: Start Grafana container
docker_container:
name: grafana
image: grafana/grafana-oss:latest
state: started
restart: yes
restart_policy: unless-stopped
published_ports:
- "3000:3000"
volumes:
- /etc/grafana/datasources:/etc/grafana/provisioning/datasources
- /etc/grafana/dashboards:/etc/grafana/provisioning/dashboards
networks:
- name: monitoring_network
env:
GF_SECURITY_ADMIN_PASSWORD: "{{ env_vars.GRAFANA_PASSWORD }}" # Customize the password

View File

@@ -0,0 +1,36 @@
---
- name: Create a Docker network for loki
docker_network:
name: monitoring_network
state: present
- name: Pull loki Docker image
docker_image:
name: grafana/loki:latest
source: pull
- name: Create loki configuration file directory on host
file:
path: /etc/loki
state: directory
mode: '0755'
- name: Create loki configuration file
template:
src: loki.yml.j2
dest: /etc/loki/config.yml
- name: Start loki container
docker_container:
name: loki
image: grafana/loki
state: started
restart: yes
command: -config.file=/etc/loki/config.yml
restart_policy: unless-stopped
published_ports:
- "3100:3100"
volumes:
- /etc/loki/config.yml:/etc/loki/config.yml
networks:
- name: monitoring_network

View File

@@ -0,0 +1,11 @@
---
# ensure we have variables from .env files
- include_tasks: ../roles/env/tasks/main.yml
- include_tasks: prometheus.yml
- include_tasks: grafana.yml
# disables loki and promtail
# - include_tasks: loki.yml
# - include_tasks: promtail.yml

View File

@@ -0,0 +1,36 @@
---
- name: Create a Docker network for Prometheus
docker_network:
name: monitoring_network
state: present
- name: Pull Prometheus Docker image
docker_image:
name: prom/prometheus
source: pull
- name: Create Prometheus configuration file directory on host
file:
path: /etc/prometheus
state: directory
mode: '0755'
- name: Create Prometheus configuration file
template:
src: prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
- name: Start Prometheus container
docker_container:
name: prometheus
image: prom/prometheus:{{ prometheus_version }}
state: started
restart: yes
restart_policy: unless-stopped
published_ports:
- "9090:9090"
volumes:
- /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
networks:
- name: monitoring_network