cluster/nomad/regions/homelab-1/email.tf

80 lines
1.7 KiB
Terraform
Raw Normal View History

resource "vault_policy" "dovecot-policy" {
name = "dovecot-policy"
policy = <<EOF
path "kv/data/cluster/dovecot" {
capabilities = ["read"]
}
EOF
}
resource "vault_policy" "getmail-policy" {
name = "getmail-policy"
policy = <<EOF
path "kv/data/cluster/getmail" {
capabilities = ["read"]
}
EOF
}
resource "nomad_volume" "dovecot_maildir" {
type = "csi"
plugin_id = "org.democratic-csi.nfs"
volume_id = "dovecot_maildir"
name = "dovecot_maildir"
external_id = "dovecot_maildir"
capability {
access_mode = "multi-node-multi-writer"
attachment_mode = "file-system"
}
context = {
server = "blowhole.hosts.in.redalder.org"
share = "/var/nfs/dovecot/maildir"
node_attach_driver = "nfs"
provisioner_driver = "node-manual"
}
mount_options {
fs_type = "nfs"
mount_flags = [ "nfsvers=3", "hard", "async" ]
}
}
resource "nomad_volume" "mail-configuration" {
type = "csi"
plugin_id = "org.democratic-csi.nfs"
volume_id = "mail-configuration"
name = "mail-configuration"
external_id = "mail-configuration"
capability {
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
context = {
server = "blowhole.hosts.in.redalder.org"
share = "/var/nfs/mail-configuration"
node_attach_driver = "nfs"
provisioner_driver = "node-manual"
}
mount_options {
fs_type = "nfs"
mount_flags = [ "nfsvers=3", "hard", "async" ]
}
}
resource "nomad_job" "email" {
jobspec = file("${path.module}/job/email.hcl")
hcl2 {
enabled = true
vars = {
flake_ref = "${var.flake_host}?rev=${var.flake_rev}&ref=${var.flake_ref}"
flake_sha = var.flake_sha
}
}
}