Pass base hostname through modules

This commit is contained in:
IamTheFij 2022-02-28 12:07:25 -08:00
parent 4df773f5d7
commit 449a5061bc
4 changed files with 38 additions and 3 deletions

View File

@ -1,4 +1,9 @@
# Create mysql server
variable "base_hostname" {
type = string
description = "Base hostname to serve content from"
default = "dev.homelab"
}
resource "nomad_job" "mysql-server" {
hcl2 {
enabled = true
@ -10,6 +15,9 @@ resource "nomad_job" "mysql-server" {
resource "nomad_job" "adminer" {
hcl2 {
enabled = true
vars = {
"base_hostname" = "${var.base_hostname}",
}
}
jobspec = file("${path.module}/adminer.nomad")

View File

@ -1,3 +1,9 @@
variable "base_hostname" {
type = string
description = "Base hostname to serve content from"
default = "dev.homelab"
}
resource "nomad_job" "nextcloud-bootstrap" {
hcl2 {
enabled = true
@ -9,6 +15,9 @@ resource "nomad_job" "nextcloud-bootstrap" {
resource "nomad_job" "nextcloud" {
hcl2 {
enabled = true
vars = {
"base_hostname" = "${var.base_hostname}",
}
}
jobspec = file("${path.module}/nextcloud.nomad")

View File

@ -4,6 +4,12 @@ variable "consul_address" {
default = "http://192.168.2.41:8500"
}
variable "base_hostname" {
type = string
description = "Base hostname to serve content from"
default = "dev.homelab"
}
provider "consul" {
address = var.consul_address
}
@ -26,20 +32,24 @@ provider "nomad" {
# Define services as modules
# Create mysql server
module "mysql-server" {
source = "./mysql"
base_hostname = var.base_hostname
}
module "traefik" {
source = "./traefik"
consul_address = var.consul_address
base_hostname = var.base_hostname
}
module "nextcloud" {
source = "./nextcloud"
base_hostname = var.base_hostname
depends_on = [module.mysql-server]
}
@ -47,7 +57,8 @@ resource "nomad_job" "whoami" {
hcl2 {
enabled = true
vars = {
"count" = "${2 * length(data.consul_service.read-nomad-cluster.service)}"
"count" = "${2 * length(data.consul_service.read-nomad-cluster.service)}",
"base_hostname" = "${var.base_hostname}",
}
}

View File

@ -1,3 +1,9 @@
variable "base_hostname" {
type = string
description = "Base hostname to serve content from"
default = "dev.homelab"
}
variable "consul_address" {
type = string
}
@ -7,6 +13,7 @@ resource "nomad_job" "traefik" {
enabled = true
vars = {
"consul_address" = "${var.consul_address}",
"base_hostname" = "${var.base_hostname}",
}
}