Creates the mysql database cleanly
This commit is contained in:
parent
7adef5e80d
commit
b745498004
|
@ -37,7 +37,6 @@ resource "docker_container" "mariadb" {
|
||||||
ip = "${var.ips["eth0"]}"
|
ip = "${var.ips["eth0"]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is a not-so-great idea
|
// This is a not-so-great idea
|
||||||
// TODO: Figure out a better way to make terraform SSH and then connect to localhost
|
// TODO: Figure out a better way to make terraform SSH and then connect to localhost
|
||||||
ports {
|
ports {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
output "lychee-ip" {
|
||||||
|
value = "${docker_container.lychee.ip_address}"
|
||||||
|
}
|
3
main.tf
3
main.tf
|
@ -7,6 +7,9 @@ module "cloudflare" {
|
||||||
module "mysql" {
|
module "mysql" {
|
||||||
source = "mysql"
|
source = "mysql"
|
||||||
mysql_root_password = "${var.mysql_root_password}"
|
mysql_root_password = "${var.mysql_root_password}"
|
||||||
|
mysql_lychee_password = "${var.mysql_lychee_password}"
|
||||||
|
mysql_kodi_password = "${var.mysql_kodi_password}"
|
||||||
|
lychee_ip = "${module.docker.lychee-ip}"
|
||||||
}
|
}
|
||||||
|
|
||||||
module "docker" {
|
module "docker" {
|
||||||
|
|
|
@ -1,34 +1,22 @@
|
||||||
# # This is pending on https://github.com/hashicorp/go-version/pull/34
|
# # This is pending on https://github.com/hashicorp/go-version/pull/34
|
||||||
|
|
||||||
# Create a Database
|
# Create a Database
|
||||||
resource "mysql_database" "kodi" {
|
resource "mysql_database" "lychee" {
|
||||||
name = "kodi"
|
name = "lychee"
|
||||||
lifecycle {
|
lifecycle {
|
||||||
prevent_destroy = true
|
prevent_destroy = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "mysql_user" "kodi" {
|
|
||||||
user = "kodi"
|
|
||||||
plaintext_password = "testing"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "mysql_grant" "kodi" {
|
|
||||||
user = "${mysql_user.kodi.user}"
|
|
||||||
host = "${mysql_user.kodi.host}"
|
|
||||||
database = "kodi"
|
|
||||||
privileges = ["SUPER"]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "mysql_user" "lychee" {
|
resource "mysql_user" "lychee" {
|
||||||
user = "lychee"
|
user = "lychee"
|
||||||
plaintext_password = "testing"
|
host = "${var.lychee_ip}"
|
||||||
|
plaintext_password = "${var.mysql_lychee_password}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "mysql_grant" "lychee" {
|
resource "mysql_grant" "lychee" {
|
||||||
user = "${mysql_user.lychee.user}"
|
user = "${mysql_user.lychee.user}"
|
||||||
host = "${mysql_user.lychee.host}"
|
host = "${mysql_user.lychee.host}"
|
||||||
database = "lychee"
|
database = "${mysql_database.lychee.name}"
|
||||||
privileges = ["SUPER"]
|
privileges = ["ALL"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
variable "mysql_root_password" {
|
variable "mysql_root_password" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "mysql_lychee_password" {
|
||||||
|
type = "string"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "mysql_kodi_password" {
|
||||||
|
type = "string"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "lychee_ip" {}
|
||||||
|
|
|
@ -15,6 +15,10 @@ variable "mysql_root_password" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "mysql_lychee_password" {}
|
||||||
|
|
||||||
|
variable "mysql_kodi_password" {}
|
||||||
|
|
||||||
variable "wiki_session_secret" {
|
variable "wiki_session_secret" {
|
||||||
type = "string"
|
type = "string"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue