mirror of
https://github.com/KevinMidboe/playbooks-retailor.git
synced 2026-01-08 10:25:44 +00:00
94 lines
2.7 KiB
YAML
94 lines
2.7 KiB
YAML
---
|
|
- 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: Create grafana alerting directory on host
|
|
file:
|
|
path: /etc/grafana/alerting
|
|
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: Ensure remote dashboard folders exist
|
|
file:
|
|
path: "/etc/grafana/dashboards/{{ item }}"
|
|
state: directory
|
|
mode: "0755"
|
|
loop: "{{ dashboard_folders }}"
|
|
|
|
- name: Copy grafana dashboards - database
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: /etc/grafana/dashboards/database/{{ item | basename | regex_replace('\.j2$', '') }}
|
|
loop: "{{ query('fileglob', 'templates/grafana-dashboards/database/*.json') }}"
|
|
|
|
- name: Copy grafana dashboards - container
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: /etc/grafana/dashboards/container/{{ item | basename | regex_replace('\.j2$', '') }}
|
|
loop: "{{ query('fileglob', 'templates/grafana-dashboards/container/*.json') }}"
|
|
|
|
- name: Copy grafana dashboards - cache
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: /etc/grafana/dashboards/cache/{{ item | basename | regex_replace('\.j2$', '') }}
|
|
loop: "{{ query('fileglob', 'templates/grafana-dashboards/cache/*.json') }}"
|
|
|
|
- name: Copy grafana dashboards - server
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: /etc/grafana/dashboards/server/{{ item | basename | regex_replace('\.j2$', '') }}
|
|
loop: "{{ query('fileglob', 'templates/grafana-dashboards/server/*.json') }}"
|
|
|
|
- name: Copy grafana alerting config
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: /etc/grafana/alerting/{{ item | basename | regex_replace('\.j2$', '') }}
|
|
loop: "{{ query('fileglob', 'templates/grafana-alerting/*.j2') }}"
|
|
|
|
- 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
|
|
|