forked from Fediversity/Fediversity
106 lines
2.2 KiB
HCL
106 lines
2.2 KiB
HCL
variable "terraform-nixos" {
|
|
type = string
|
|
}
|
|
|
|
variable "domain" {
|
|
type = string
|
|
default = "fediversity.net"
|
|
}
|
|
|
|
variable "mastodon" {
|
|
type = object({
|
|
enable = bool
|
|
})
|
|
default = {
|
|
enable = false
|
|
}
|
|
}
|
|
|
|
variable "pixelfed" {
|
|
type = object({
|
|
enable = bool
|
|
})
|
|
default = {
|
|
enable = false
|
|
}
|
|
}
|
|
|
|
variable "peertube" {
|
|
type = object({
|
|
enable = bool
|
|
})
|
|
default = {
|
|
enable = false
|
|
}
|
|
}
|
|
|
|
variable "initialUser" {
|
|
type = object({
|
|
displayName = string
|
|
username = string
|
|
email = string
|
|
# TODO: mark (nested) credentials as sensitive
|
|
# https://discuss.hashicorp.com/t/is-it-possible-to-mark-an-attribute-of-an-object-as-sensitive/24649/2
|
|
password = string
|
|
})
|
|
default = {
|
|
displayName = "Testy McTestface"
|
|
username = "test"
|
|
email = "test@test.com"
|
|
password = "testtest"
|
|
}
|
|
}
|
|
|
|
# TODO: could this straight-up be added in the child module instead?
|
|
variable "ssh_private_key_file" {
|
|
type = string
|
|
description = "Path to private key used to connect to the target_host"
|
|
default = ""
|
|
}
|
|
|
|
variable "deploy_environment" {
|
|
type = map(string)
|
|
description = "Extra environment variables to be set during deployment."
|
|
default = {}
|
|
}
|
|
|
|
locals {
|
|
applications = {
|
|
mastodon = {
|
|
cfg = var.mastodon
|
|
hostname = "test06"
|
|
}
|
|
pixelfed = {
|
|
cfg = var.pixelfed
|
|
hostname = "test04"
|
|
}
|
|
peertube = {
|
|
cfg = var.peertube
|
|
hostname = "test03"
|
|
}
|
|
}
|
|
}
|
|
|
|
# module "garage" {
|
|
# source = "./vm"
|
|
# count = var.mastodon.enable || var.pixelfed.enable || var.peertube.enable ? 1 : 0
|
|
# domain = var.domain
|
|
# hostname = "test01"
|
|
# config = "garage"
|
|
# initialUser = var.initialUser
|
|
# terraform-nixos = var.terraform-nixos
|
|
# ssh_private_key_file = var.ssh_private_key_file
|
|
# deploy_environment = var.deploy_environment
|
|
# }
|
|
|
|
module "nixos" {
|
|
source = "./vm"
|
|
domain = var.domain
|
|
initialUser = var.initialUser
|
|
terraform-nixos = var.terraform-nixos
|
|
ssh_private_key_file = var.ssh_private_key_file
|
|
deploy_environment = var.deploy_environment
|
|
for_each = { for name, inst in local.applications : name => inst if inst.cfg.enable }
|
|
config = each.key
|
|
hostname = each.value.hostname
|
|
}
|