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 62303264653836656162366362316461656363353539343632616462626231643632
# Grafana # Grafana
grafana: grafana:
mysql_password: !vault | db:
$ANSIBLE_VAULT;1.1;AES256 hostname: 172.31.47.215
65376335363732633132326630323161393861323833323631613630343262383137656138356262 pass: !vault |
3730386139393739373738626535376636666135646463350a623331333032346434343465666234 $ANSIBLE_VAULT;1.1;AES256
38393539623437376133363063633238383031326431653737346564323837343265653431633962 65376335363732633132326630323161393861323833323631613630343262383137656138356262
6665346237666165330a643635653863356633623535383063366632336437313730626233346664 3730386139393739373738626535376636666135646463350a623331333032346434343465666234
33303465616532313339393634386166363162393661393037323835323035386663 38393539623437376133363063633238383031326431653737346564323837343265653431633962
6665346237666165330a643635653863356633623535383063366632336437313730626233346664
33303465616532313339393634386166363162393661393037323835323035386663
url: "monitor.9iron.club" url: "monitor.9iron.club"
webroot: "/var/www/grafana" webroot: "/var/www/grafana"
config_repo: "https://git.9iron.club/salt/grafana" config_repo: "https://git.9iron.club/salt/grafana"

View File

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

View File

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

View File

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