Move grafana to forrest

This commit is contained in:
Jake Howard 2021-01-31 16:52:24 +00:00
parent a79e54d45a
commit c7fba8107a
Signed by: jake
GPG key ID: 57AFB45680EDD477
11 changed files with 105 additions and 69 deletions

View file

@ -0,0 +1 @@
expose_ssh: true

View file

@ -5,3 +5,4 @@ protected_ip: "{{ pve_hosts.pve_docker.internal_ip }}"
traefik_provider_jellyfin: true
traefik_provider_homeassistant: true
traefik_provider_grafana: true

View file

@ -40,7 +40,6 @@
- hosts: pve-docker
roles:
- pve_docker
- grafana
- gitea
- duplicati
- yourls
@ -60,3 +59,7 @@
- pve
- zfs
- pve_nebula_route
- hosts: forrest
roles:
- forrest

View file

@ -0,0 +1,11 @@
- name: restart grafana
service:
name: grafana-server
state: restarted
become: true
- name: restart influxdb
service:
name: influxdb
state: restarted
become: true

View file

@ -0,0 +1,65 @@
- name: Add grafana repository
apt_repository:
repo: deb https://packages.grafana.com/oss/deb stable main
state: present
filename: grafana
- name: Add influxdb repository
apt_repository:
repo: deb https://repos.influxdata.com/debian buster stable
state: present
filename: influxdb
- name: Install grafana
package:
name: grafana
become: true
- name: Install influxdb
package:
name: grafana
become: true
loop:
- influxdb
- chronograf
- name: Enable grafana
service:
name: grafana-service
enabled: true
become: true
- name: Enable influxdb
service:
name: influxdb
enabled: true
become: true
- name: Configure influxdb
ini_file:
path: /etc/influxdb/influxdb.conf
mode: "0644"
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
become: true
notify: restart influxdb
loop_control:
label: "{{ item.section }}.{{ item.option }}={{ item.value }}"
loop:
- {section: http, option: bind-address, value: ":8086"}
- {section: http, option: auth-enabled, value: "true"}
- name: Configure grafana
ini_file:
path: /etc/grafana/grafana.ini
mode: "0644"
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
become: true
notify: restart grafana
loop_control:
label: "{{ item.section }}.{{ item.option }}={{ item.value }}"
loop:
- {section: server, option: domain, value: grafana.jakehoward.tech}

View file

@ -1,43 +0,0 @@
version: "2.3"
services:
grafana:
image: grafana/grafana:latest
environment:
- TZ=Europe/London
- GF_DATABASE_URL=postgres://grafana:grafana@db/grafana
- GF_RENDERING_SERVER_URL=http://renderer:8081/render
- GF_RENDERING_CALLBACK_URL=http://grafana:3000/
volumes:
- ./grafana:/var/lib/grafana
restart: unless-stopped
depends_on:
- db
- renderer
networks:
- default
- grafana
labels:
- traefik.enable=true
- traefik.http.routers.grafana.rule=Host(`grafana.jakehoward.tech`)
- traefik.http.routers.grafana.tls.certresolver=le
- traefik.http.routers.grafana.middlewares=compress@file
db:
image: postgres:12-alpine
restart: unless-stopped
volumes:
- ./postgres:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=grafana
- POSTGRES_USER=grafana
renderer:
image: grafana/grafana-image-renderer:latest
restart: unless-stopped
environment:
- BROWSER_TZ=Europe/London
networks:
grafana:
external: true

View file

@ -1,4 +0,0 @@
- name: restart grafana
shell:
chdir: /opt/grafana
cmd: "{{ docker_update_command }}"

View file

@ -1,21 +0,0 @@
- name: Create install directory
file:
path: /opt/grafana
state: directory
owner: "{{ docker_user.name }}"
mode: "{{ docker_compose_directory_mask }}"
become: true
- name: Create grafana network
docker_network:
name: grafana
- name: Install compose file
template:
src: files/docker-compose.yml
dest: /opt/grafana/docker-compose.yml
mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config
notify: restart grafana
become: true

View file

@ -2,5 +2,6 @@ traefik_influx_db_dir: ./influxdb
traefik_provider_jellyfin: false
traefik_provider_homeassistant: false
traefik_provider_grafana: false
with_traefik_pages: false

View file

@ -0,0 +1,12 @@
http:
routers:
router-grafana:
rule: Host(`grafana.jakehoward.tech`)
service: service-grafana
tls:
certResolver: le
services:
service-grafana:
loadBalancer:
servers:
- url: http://{{ pve_hosts.forrest.internal_ip }}:3000

View file

@ -67,3 +67,13 @@
notify: restart traefik
when: traefik_provider_jellyfin
become: true
- name: Install grafana provider
template:
src: files/file-provider-grafana.yml
dest: /opt/traefik/traefik/conf/grafana.yml
mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}"
notify: restart traefik
when: traefik_provider_grafana
become: true