my-homelab-configs/bootstrap/email/README.md

48 lines
2.2 KiB
Markdown

# OCI email learning VM
This is an independent, opt-in OpenTofu stack. It creates one OCI compute VM
inside an existing compartment and subnet. The separate `email-vm setup`
command installs an idempotent Postfix + Dovecot baseline over SSH; it does
not change DNS or open mail ingress unless explicitly enabled. Keep
`enabled=false` until the OCI image, network, and SSH inputs are known.
The default `VM.Standard.E2.1.Micro` shape and Canonical Ubuntu 24.04 Minimal
image are intended for OCI Always Free capacity in `us-ashburn-1`.
Example on the Debian pipeline host:
```sh
export LAB_EMAIL_VM_ENABLED=true
export LAB_EMAIL_OCI_REGION=us-phoenix-1
export LAB_EMAIL_COMPARTMENT_ID=ocid1.compartment...
export LAB_EMAIL_AVAILABILITY_DOMAIN='...'
export LAB_EMAIL_SUBNET_ID=ocid1.subnet...
export LAB_EMAIL_IMAGE_ID=ocid1.image...
export LAB_EMAIL_SSH_PUBLIC_KEY="$(cat ~/.ssh/id_ed25519.pub)"
export LAB_EMAIL_DOMAIN=example.org
# Optional existing NSGs, as a JSON list. Do not open mail ingress yet.
export LAB_EMAIL_NSG_IDS='["ocid1.networksecuritygroup..."]'
./jeannie email-vm plan
./jeannie email-vm apply
./jeannie email-vm setup [--domain example.org]
```
`email-vm setup` defaults to the Ubuntu `ubuntu` account and the local
`~/.ssh/id_ed25519` key. Set `LAB_EMAIL_SSH_USER` or
`LAB_EMAIL_SSH_PRIVATE_KEY` when the image uses different SSH credentials.
Without a domain it uses a temporary self-signed certificate and keeps ports
25, 465, 587, and 993 closed. After choosing the domain, rerun setup with
`LAB_EMAIL_DOMAIN=mail.example.org`; then add DNS A/MX, SPF, DKIM, DMARC, and
PTR records and request OCI SMTP port 25 access before opening mail ingress.
The setup also installs `prometheus-node-exporter`. OCI foundation apply
persists the discovered VM addresses and opens TCP 9100 only to the configured
monitoring CIDR. The platform monitoring stack adds the email target
automatically; the adopted edge VM is scraped when its restricted 9100 target
is reachable.
The provider reads OCI credentials from the normal OCI CLI configuration
(`~/.oci/config`) and never stores private keys in this repository. `destroy`
requires `--yes`. The stack is intentionally separate from `platform`, `apps`,
and `up`, so mail experiments cannot modify the Kubernetes cluster.