2022-02-16 17:56:18 +00:00
|
|
|
# Configure Consul provider
|
|
|
|
variable "consul_address" {
|
2022-02-17 22:03:42 +00:00
|
|
|
type = string
|
2022-02-16 17:56:18 +00:00
|
|
|
default = "http://192.168.2.41:8500"
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "consul" {
|
2022-02-17 22:03:42 +00:00
|
|
|
address = var.consul_address
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get Nomad client from Consul
|
|
|
|
data "consul_service" "read-nomad-cluster" {
|
2022-02-17 22:03:42 +00:00
|
|
|
name = "nomad-client"
|
|
|
|
# name = "nomad-clients"
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
locals {
|
2022-02-17 22:03:42 +00:00
|
|
|
nomad_node = data.consul_service.read-nomad-cluster.service[0]
|
2022-02-16 17:56:18 +00:00
|
|
|
nomad_node_address = "http://${local.nomad_node.node_address}:${local.nomad_node.port}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Configure the Consul provider
|
|
|
|
provider "nomad" {
|
|
|
|
# address = "http://services.thefij:4646"
|
2022-02-17 22:03:42 +00:00
|
|
|
address = local.nomad_node_address
|
2022-02-16 17:56:18 +00:00
|
|
|
region = "global"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create mysql server
|
|
|
|
resource "nomad_job" "mysql-server" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/mysql.nomad")
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create mysql server
|
|
|
|
resource "nomad_job" "adminer" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/adminer.nomad")
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create Traefik
|
|
|
|
resource "nomad_job" "traefik" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
vars = {
|
|
|
|
"consul_address" = "${var.consul_address}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/traefik.nomad")
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a sample host
|
|
|
|
resource "nomad_job" "whoami" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/whoami.nomad")
|
|
|
|
}
|
2022-02-17 22:03:42 +00:00
|
|
|
|
|
|
|
# Create a sample host
|
|
|
|
resource "nomad_job" "nextcloud-bootstrap" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/nextcloud-bootstrap.nomad")
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a sample host
|
|
|
|
resource "nomad_job" "nextcloud" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/nextcloud.nomad")
|
|
|
|
}
|