Migrate Grafana to postgres

This commit is contained in:
Salt 2020-09-22 16:37:58 -05:00
parent cccae82c04
commit ab3db510ab
4 changed files with 27 additions and 24 deletions

View File

@ -84,13 +84,15 @@ gitea:
62303264653836656162366362316461656363353539343632616462626231643632
# Grafana
grafana:
mysql_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
65376335363732633132326630323161393861323833323631613630343262383137656138356262
3730386139393739373738626535376636666135646463350a623331333032346434343465666234
38393539623437376133363063633238383031326431653737346564323837343265653431633962
6665346237666165330a643635653863356633623535383063366632336437313730626233346664
33303465616532313339393634386166363162393661393037323835323035386663
db:
hostname: 172.31.47.215
pass: !vault |
$ANSIBLE_VAULT;1.1;AES256
65376335363732633132326630323161393861323833323631613630343262383137656138356262
3730386139393739373738626535376636666135646463350a623331333032346434343465666234
38393539623437376133363063633238383031326431653737346564323837343265653431633962
6665346237666165330a643635653863356633623535383063366632336437313730626233346664
33303465616532313339393634386166363162393661393037323835323035386663
url: "monitor.9iron.club"
webroot: "/var/www/grafana"
config_repo: "https://git.9iron.club/salt/grafana"

View File

@ -2,4 +2,3 @@
allow_duplicates: no
dependencies:
- role: apache-php
- role: mysql

View File

@ -3,22 +3,24 @@
---
- name: Install, configure, and start Grafana
block:
- name: Create and configure DB
- name: Set up PostgreSQL
block:
- name: Create DB user
postgresql_user:
name: grafana
password: "{{ grafana.db.pass }}"
login_host: "{{ grafana.db.hostname }}"
login_user: "{{ psql.ansible.user }}"
login_password: "{{ psql.ansible.pass }}"
- name: Create DB
mysql_db:
postgresql_db:
name: grafana
login_user: root
login_password: "{{ mysql.root_password }}"
state: present
- name: Create user
mysql_user:
name: grafana
host: localhost
password: "{{ grafana.mysql_password }}"
priv: "grafana.*:ALL,GRANT"
login_user: root
login_password: "{{ mysql.root_password }}"
owner: grafana
encoding: UNICODE
login_host: "{{ grafana.db.hostname }}"
login_user: "{{ psql.ansible.user }}"
login_password: "{{ psql.ansible.pass }}"
tags: [ postgresql ]
- name: Configure Grafana
block:
- name: Create configuration directories

View File

@ -73,12 +73,12 @@ http_port = 3001
# as separate properties or as on string using the url properties.
# Either "mysql", "postgres" or "sqlite3", it's your choice
type = mysql
host = 127.0.0.1:3306
type = postgres
host = {{ grafana.db.hostname }}:5432
name = grafana
user = grafana
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = {{ grafana.mysql_password }}
password = {{ grafana.db.pass }}
# Use either URL or the previous fields to configure the database
# Example: mysql://user:secret@host:port/database