Restore dockerized grafana setup

It's stil on a separate machine, but in docker to allow more applications to be run easier and tied together.
This commit is contained in:
Jake Howard 2021-02-09 09:16:52 +00:00
parent b940d22373
commit 149d01165f
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 55 additions and 75 deletions

View file

@ -0,0 +1,33 @@
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
ports:
- 3000:3000
depends_on:
- db
- renderer
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

View file

@ -1,11 +1,4 @@
- name: restart grafana
service:
name: grafana-server
state: restarted
become: true
- name: restart influxdb
service:
name: influxdb
state: restarted
become: true
shell:
chdir: /opt/grafana
cmd: "{{ docker_update_command }}"

View file

@ -0,0 +1,17 @@
- name: Create install directory
file:
path: /opt/grafana
state: directory
owner: "{{ docker_user.name }}"
mode: "{{ docker_compose_directory_mask }}"
become: true
- 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: docker-compose -f %s config
notify: restart grafana
become: true

View file

@ -1,65 +1,2 @@
- 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-server
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: 0.0.0.0: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}
- name: Grafana
include: grafana.yml