orchestration-tests/nomad/traefik/traefik.tf

59 lines
1.2 KiB
Terraform
Raw Normal View History

2022-02-28 20:07:25 +00:00
variable "base_hostname" {
2022-04-13 21:01:14 +00:00
type = string
2022-02-28 20:07:25 +00:00
description = "Base hostname to serve content from"
2022-04-13 21:01:14 +00:00
default = "dev.homelab"
2022-02-28 20:07:25 +00:00
}
2022-02-27 23:22:09 +00:00
variable "consul_address" {
2022-04-13 21:01:14 +00:00
type = string
description = "address of consul server for dynamic routes"
2022-02-27 23:22:09 +00:00
}
2022-03-13 17:13:19 +00:00
data "consul_nodes" "all-nodes" {
query_options {
datacenter = "dc1"
}
}
2022-06-23 16:53:26 +00:00
# Get hostname from Consul
data "consul_keys" "base_hostname" {
key {
name = "base_hostname"
path = "global/base_hostname"
# Default to hostname provided as input variable for bootstrapping
default = var.base_hostname
}
}
2022-02-27 23:22:09 +00:00
resource "nomad_job" "traefik" {
hcl2 {
enabled = true
vars = {
2022-03-13 17:13:19 +00:00
# "consul_address" = "${var.consul_address}",
"consul_address" = "http://${data.consul_nodes.all-nodes.nodes[0].address}:8500",
2022-06-23 16:53:26 +00:00
"base_hostname" = "${data.consul_keys.base_hostname.var.base_hostname}",
2022-02-27 23:22:09 +00:00
}
}
jobspec = file("${path.module}/traefik.nomad")
}
2022-06-23 16:53:26 +00:00
# locals {
# authelia_config = templatefile(
# "${path.module}/authelia.yml",
# {
# }
# )
# }
#
# resource "nomad_job" "authelia" {
# hcl2 {
# enabled = true
# vars = {
# config_data = "${local.authelia_config}",
# }
# }
#
# jobspec = file("${path.module}/authelia.nomad")
# }