🏡 index : github.com/captn3m0/nebula.git

author Nemo <me@captnemo.in> 2017-12-28 22:12:21.0 +05:30:00
committer Nemo <me@captnemo.in> 2017-12-28 22:12:21.0 +05:30:00
commit
b745498004d0616a1e8930f4f9beb374e69dc0c1 [patch]
tree
9c239b5b2da164001e4e5f9e2ee2c884c1183b9b
parent
7adef5e80d2b28ec78f0d15e6a21844893354dd7
download
b745498004d0616a1e8930f4f9beb374e69dc0c1.tar.gz

Creates the mysql database cleanly



Diff

 main.tf            |  7 +++++--
 variables.tf       |  4 ++++
 docker/db.tf       |  1 -
 docker/outputs.tf  |  3 +++
 mysql/main.tf      | 30 +++++++++++++-----------------
 mysql/variables.tf | 10 ++++++++++
 6 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/main.tf b/main.tf
index 0d1d743..c40336a 100644
--- a/main.tf
+++ a/main.tf
@@ -5,8 +5,11 @@
}

module "mysql" {

  source              = "mysql"
  mysql_root_password = "${var.mysql_root_password}"
  source                = "mysql"
  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" {

diff --git a/variables.tf b/variables.tf
index 257c268..1028573 100644
--- a/variables.tf
+++ a/variables.tf
@@ -15,6 +15,10 @@
  type = "string"
}

variable "mysql_lychee_password" {}

variable "mysql_kodi_password" {}

variable "wiki_session_secret" {

  type = "string"
}
diff --git a/docker/db.tf b/docker/db.tf
index b3ce5d0..a630259 100644
--- a/docker/db.tf
+++ a/docker/db.tf
@@ -37,7 +37,6 @@
    ip       = "${var.ips["eth0"]}"
  }


  // This is a not-so-great idea
  // TODO: Figure out a better way to make terraform SSH and then connect to localhost
  ports {

diff --git a/docker/outputs.tf b/docker/outputs.tf
new file mode 100644
index 0000000..2cdad4b 100644
--- /dev/null
+++ a/docker/outputs.tf
@@ -1,0 +1,3 @@
output "lychee-ip" {

  value = "${docker_container.lychee.ip_address}"
}
diff --git a/mysql/main.tf b/mysql/main.tf
index 40393aa..47d3416 100644
--- a/mysql/main.tf
+++ a/mysql/main.tf
@@ -1,34 +1,22 @@
# # This is pending on https://github.com/hashicorp/go-version/pull/34

# Create a Database
resource "mysql_database" "kodi" {

  name = "kodi"
resource "mysql_database" "lychee" {

  name = "lychee"
  lifecycle {

    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" {

  user     = "lychee"
  plaintext_password = "testing"
    user = "lychee"
    host = "${var.lychee_ip}"
    plaintext_password = "${var.mysql_lychee_password}"
}

resource "mysql_grant" "lychee" {

  user       = "${mysql_user.lychee.user}"
  host       = "${mysql_user.lychee.host}"
  database   = "lychee"
  privileges = ["SUPER"]
    user = "${mysql_user.lychee.user}"
    host = "${mysql_user.lychee.host}"
    database = "${mysql_database.lychee.name}"
    privileges = ["ALL"]
}

diff --git a/mysql/variables.tf b/mysql/variables.tf
index 2c69125..2990d8d 100644
--- a/mysql/variables.tf
+++ a/mysql/variables.tf
@@ -1,3 +1,13 @@
variable "mysql_root_password" {

  type = "string"
}

variable "mysql_lychee_password" {

  type = "string"
}

variable "mysql_kodi_password" {

  type = "string"
}

variable "lychee_ip" {}