mirror of
https://github.com/davestephens/ansible-nas
synced 2025-01-13 03:58:47 +00:00
69 lines
2.9 KiB
YAML
69 lines
2.9 KiB
YAML
---
|
|
- name: Start Grafana
|
|
block:
|
|
- name: Create Grafana Directories
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "472"
|
|
recurse: yes
|
|
changed_when: false
|
|
with_items:
|
|
- "{{ stats_grafana_data_directory }}"
|
|
- "{{ stats_grafana_config_directory }}"
|
|
- "{{ stats_grafana_config_directory }}/dashboards"
|
|
- "{{ stats_grafana_config_directory }}/provisioning/datasources"
|
|
- "{{ stats_grafana_config_directory }}/provisioning/dashboards"
|
|
|
|
- name: Template Grafana data source
|
|
ansible.builtin.template:
|
|
src: datasources/ansible-nas.yml
|
|
dest: "{{ stats_grafana_config_directory }}/provisioning/datasources/ansible-nas.yml"
|
|
|
|
- name: Copy Grafana dashboards configuration
|
|
ansible.builtin.copy:
|
|
src: dashboards/ansible-nas.yml
|
|
dest: "{{ stats_grafana_config_directory }}/provisioning/dashboards/ansible-nas.yml"
|
|
|
|
- name: Copy Grafana Ansible-NAS dashboard
|
|
ansible.builtin.copy:
|
|
src: dashboards/ansible-nas-overview.json
|
|
dest: "{{ stats_grafana_config_directory }}/dashboards/ansible-nas-overview.json"
|
|
|
|
- name: Grafana Docker Container
|
|
community.docker.docker_container:
|
|
name: "{{ stats_grafana_container_name }}"
|
|
image: "{{ stats_grafana_image_name }}:{{ stats_grafana_image_version }}"
|
|
pull: true
|
|
volumes:
|
|
- "{{ stats_grafana_data_directory }}:/var/lib/grafana:rw"
|
|
- "{{ stats_grafana_config_directory }}/provisioning:/etc/grafana/provisioning:ro"
|
|
- "{{ stats_grafana_config_directory }}/dashboards:/etc/dashboards:ro"
|
|
ports:
|
|
- "{{ stats_grafana_port }}:3000"
|
|
env:
|
|
GF_PLUGINS_ENABLE_ALPHA: "true"
|
|
GF_UNIFIED_ALERTING_ENABLED: "true"
|
|
restart_policy: unless-stopped
|
|
memory: 1g
|
|
labels:
|
|
traefik.enable: "{{ stats_grafana_available_externally | string }}"
|
|
traefik.http.routers.grafana.rule: "Host(`grafana.{{ ansible_nas_domain }}`) "
|
|
traefik.http.routers.grafana.tls.certresolver: "letsencrypt"
|
|
traefik.http.routers.grafana.tls.domains[0].main: "{{ ansible_nas_domain }}"
|
|
traefik.http.routers.grafana.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
|
|
traefik.http.services.grafana.loadbalancer.server.port: "3000"
|
|
homepage.group: Monitoring
|
|
homepage.name: Grafana
|
|
homepage.icon: grafana
|
|
homepage.href: "http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ stats_grafana_port }}"
|
|
homepage.description: Dashboards and centralized observability.
|
|
when: stats_enabled is true
|
|
|
|
- name: Stop Grafana
|
|
block:
|
|
- name: Stop Grafana
|
|
community.docker.docker_container:
|
|
name: "{{ stats_grafana_container_name }}"
|
|
state: absent
|
|
when: stats_enabled is false
|