From 41ee9e06189bfee6c8099a49c2e51825862c4feb Mon Sep 17 00:00:00 2001 From: Alexandre Pires Date: Thu, 24 Apr 2025 22:47:25 +0200 Subject: [PATCH] Refactor email configuration in Terraform files for improved clarity and consistency --- terraform/k8sapps/config.tf | 34 +++++++++++++++++++++++++++------- terraform/k8sapps/mail.tf | 34 +++++++--------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/terraform/k8sapps/config.tf b/terraform/k8sapps/config.tf index 033e738..302a089 100644 --- a/terraform/k8sapps/config.tf +++ b/terraform/k8sapps/config.tf @@ -1,7 +1,12 @@ locals { + # general domain_name = "alexpires.me" + # storage + persistent_folder = "/mnt/microk8s_persistent" + database_folder = "/var/lib" + # apps wordpress_version = "6.7.2" wordpress_fqdns = ["blog.${local.domain_name}", "www.${local.domain_name}", "${local.domain_name}"] @@ -48,18 +53,33 @@ locals { local_backup_retention_days = 2 cloud_backup_retention_days = 3 - # notification - scaleway_smtp_host = "smtp.tem.scw.cloud" - scaleway_smtp_port = 587 - # mail settings getmail_version = "v0.0.1-6.19.07" fetch_emails_schedule = "*/2 * * * *" mail_files_backup_cron_schedule = "0 3 * * *" - # storage - persistent_folder = "/mnt/microk8s_persistent" - database_folder = "/var/lib" + # email settings + scaleway_smtp_host = "smtp.tem.scw.cloud" + scaleway_smtp_port = 587 + email_accounts = [ + { + domain = "alexpires.me" + recipient = "c.alexandre.pires" + receive = { + type = "imap" + server = "mail-pt.securemail.pro" + port = 993 + } + send = { + server = "smtp-pt.securemail.pro" + port = 465 + } + username = var.alexpires_me_email_username + password = var.alexpires_me_email_password + mailboxes = ["INBOX", "Sent", "Drafts", "Trash", "Spam"] + } + ] + } data "scaleway_account_project" "default" { diff --git a/terraform/k8sapps/mail.tf b/terraform/k8sapps/mail.tf index 23d8697..dc8e7fe 100644 --- a/terraform/k8sapps/mail.tf +++ b/terraform/k8sapps/mail.tf @@ -1,29 +1,9 @@ locals { - mail_path = "${local.persistent_folder}/mail" - mailboxes_path = "${local.mail_path}/mailboxes" - getmail_path = "${local.mail_path}/getmail" - postfix_path = "${local.mail_path}/postfix" - mail_backup_path = "${local.persistent_folder}/backup.mail" - email_domain_name = "alexpires.me" - - email_accounts = [ - { - domain = "alexpires.me" - recipient = "c.alexandre.pires" - receive = { - type = "imap" - server = "mail-pt.securemail.pro" - port = 993 - } - send = { - server = "smtp-pt.securemail.pro" - port = 465 - } - username = var.alexpires_me_email_username - password = var.alexpires_me_email_password - mailboxes = ["INBOX", "Sent", "Drafts", "Trash", "Spam"] - } - ] + mail_path = "${local.persistent_folder}/mail" + mailboxes_path = "${local.mail_path}/mailboxes" + getmail_path = "${local.mail_path}/getmail" + postfix_path = "${local.mail_path}/postfix" + mail_backup_path = "${local.persistent_folder}/backup.mail" getmail_jobs = flatten([ for account in local.email_accounts : [ @@ -45,10 +25,10 @@ locals { # Email configuration SMTP_HOST = local.scaleway_smtp_host SMTP_PORT = 465 - MY_PRIMARY_DOMAIN = local.email_domain_name + MY_PRIMARY_DOMAIN = local.domain_name MY_DESTINATION = join(",", [for account in local.email_accounts : account.domain]) MY_NETWORKS = "127.0.0.0/8" - MAILNAME = "smtp.alexpires.me" + MAILNAME = "smtp.${local.domain_name}" DOVECOT_AUTH_ADDRESS = "dovecot-auth.mail.svc.cluster.local" DOVECOT_AUTH_PORT = 31000 DOVECOT_LMTP_ADDRESS = "dovecot-lmtp.mail.svc.cluster.local"