88 lines
1.6 KiB
HCL
88 lines
1.6 KiB
HCL
# Configure Consul provider
|
|
variable "consul_address" {
|
|
type = string
|
|
default = "http://192.168.2.41:8500"
|
|
}
|
|
|
|
provider "consul" {
|
|
address = var.consul_address
|
|
}
|
|
|
|
# Get Nomad client from Consul
|
|
data "consul_service" "read-nomad-cluster" {
|
|
name = "nomad-client"
|
|
# name = "nomad-clients"
|
|
}
|
|
|
|
locals {
|
|
nomad_node = data.consul_service.read-nomad-cluster.service[0]
|
|
nomad_node_address = "http://${local.nomad_node.node_address}:${local.nomad_node.port}"
|
|
}
|
|
|
|
# Configure the Consul provider
|
|
provider "nomad" {
|
|
# address = "http://services.thefij:4646"
|
|
address = local.nomad_node_address
|
|
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
|
|
vars = {
|
|
"count" = "${2 * length(data.consul_service.read-nomad-cluster.service)}"
|
|
}
|
|
}
|
|
|
|
jobspec = file("${path.module}/whoami.nomad")
|
|
}
|
|
|
|
# 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")
|
|
}
|