terraform-incus/config/root.hcl
Ben Vincent cb67816eee feat: initial commit
- have been working on this for some time now
2025-05-30 22:36:55 +10:00

63 lines
1.7 KiB
HCL

locals {
images = yamldecode(file("${get_repo_root()}/config/globals/images.yaml"))
networks = yamldecode(file("${get_repo_root()}/config/globals/networks.yaml"))
profiles = yamldecode(file("${get_repo_root()}/config/globals/profiles.yaml"))
storage_pools = yamldecode(file("${get_repo_root()}/config/globals/storage_pools.yaml"))
storage_volumes = yamldecode(file("${get_repo_root()}/config/globals/storage_volumes.yaml"))
consul_addr = "https://consul.service.consul"
relative_path_after_config = join(
"/",
slice(
split("/", get_path_from_repo_root()),
index(split("/", get_path_from_repo_root()), "config") + 1,
length(split("/", get_path_from_repo_root()))
)
)
}
inputs = {
profiles = local.profiles
images = local.images
networks = local.networks
storage_pools = local.storage_pools
storage_volumes = local.storage_volumes
}
generate "backend" {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
terraform {
required_providers {
vault = {
source = "hashicorp/vault"
version = "~> 4.5.0"
}
incus = {
source = "lxc/incus"
version = "0.3.1"
}
cobbler = {
source = "cobbler/cobbler"
version = "2.0.3"
}
puppetca = {
source = "camptocamp/puppetca"
version = "2.0.0"
}
puppetdb = {
source = "camptocamp/puppetdb"
version = "2.0.0"
}
}
backend "consul" {
address = "${local.consul_addr}"
path = "infra/terraform/incus/${replace(local.relative_path_after_config, "/", "_")}/state"
scheme = "https"
lock = true
ca_file = "/etc/pki/tls/certs/ca-bundle.crt"
}
}
EOF
}