Merge pull request 'Provision mail and publish DNS on separate servers' (#53) from feature/remote-mail-dns-nodes into main
Reviewed-on: #53
This commit was merged in pull request #53.
This commit is contained in:
commit
9a09314758
13 files changed
+239
-7
No files matched your search
@@ -0,0 +1,20 @@
|
|||||||
|
Match User coulobre-dns-request,coulobre-mail-request
|
||||||
|
AuthenticationMethods publickey
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
PasswordAuthentication no
|
||||||
|
KbdInteractiveAuthentication no
|
||||||
|
AuthorizedKeysFile /etc/ssh/coulobre-node-keys/%u
|
||||||
|
AuthorizedKeysCommand none
|
||||||
|
TrustedUserCAKeys none
|
||||||
|
DisableForwarding yes
|
||||||
|
PermitTunnel no
|
||||||
|
PermitTTY no
|
||||||
|
PermitUserRC no
|
||||||
|
|
||||||
|
Match User coulobre-dns-request
|
||||||
|
ForceCommand /usr/bin/socat -t 185 STDIO UNIX-CONNECT:/run/coulobre-dns-apply.sock
|
||||||
|
|
||||||
|
Match User coulobre-mail-request
|
||||||
|
ForceCommand /usr/bin/socat -t 185 STDIO UNIX-CONNECT:/run/coulobre-mail-apply.sock
|
||||||
|
|
||||||
|
Match all
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
Host coulobre-dns-node
|
||||||
|
HostName dns.example.org
|
||||||
|
Port 22
|
||||||
|
User coulobre-dns-request
|
||||||
|
IdentityFile /etc/coulobre-remote/dns/id_ed25519
|
||||||
|
IdentityAgent none
|
||||||
|
IdentitiesOnly yes
|
||||||
|
PreferredAuthentications publickey
|
||||||
|
UserKnownHostsFile /etc/coulobre-remote/dns/known_hosts
|
||||||
|
GlobalKnownHostsFile none
|
||||||
|
StrictHostKeyChecking yes
|
||||||
|
BatchMode yes
|
||||||
|
ConnectTimeout 5
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
Host coulobre-mail-node
|
||||||
|
HostName mail.example.org
|
||||||
|
Port 22
|
||||||
|
User coulobre-mail-request
|
||||||
|
IdentityFile /etc/coulobre-remote/mail/id_ed25519
|
||||||
|
IdentityAgent none
|
||||||
|
IdentitiesOnly yes
|
||||||
|
PreferredAuthentications publickey
|
||||||
|
UserKnownHostsFile /etc/coulobre-remote/mail/known_hosts
|
||||||
|
GlobalKnownHostsFile none
|
||||||
|
StrictHostKeyChecking yes
|
||||||
|
BatchMode yes
|
||||||
|
ConnectTimeout 5
|
||||||
@@ -12,6 +12,7 @@ COULOBRE_BROKER_URL=amqp://coulobre:@127.0.0.1:5672/coulobre
|
|||||||
# COULOBRE_LOCAL_WEB_HTTPS=1
|
# COULOBRE_LOCAL_WEB_HTTPS=1
|
||||||
# COULOBRE_LOCAL_WEB_SFTP=1
|
# COULOBRE_LOCAL_WEB_SFTP=1
|
||||||
# COULOBRE_LOCAL_DATABASE_PROVISIONING=1
|
# COULOBRE_LOCAL_DATABASE_PROVISIONING=1
|
||||||
|
# These two switches also enable provisioners using the SSH service drop-ins.
|
||||||
# COULOBRE_LOCAL_DNS_PUBLISHING=1
|
# COULOBRE_LOCAL_DNS_PUBLISHING=1
|
||||||
# COULOBRE_LOCAL_MAILBOX_PROVISIONING=1
|
# COULOBRE_LOCAL_MAILBOX_PROVISIONING=1
|
||||||
# COULOBRE_LOCAL_DATABASE_CREDENTIALS=1
|
# COULOBRE_LOCAL_DATABASE_CREDENTIALS=1
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Coulobre remote BIND9 publishing request
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=coulobre-dns-publisher
|
||||||
|
Group=coulobre-dns-publisher
|
||||||
|
UMask=0077
|
||||||
|
ReadWritePaths=
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=/usr/bin/ssh -T -F /etc/coulobre-remote/dns/ssh_config coulobre-dns-node
|
||||||
|
RuntimeMaxSec=190s
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Coulobre Panel local BIND9 publishing worker
|
Description=Coulobre Panel BIND9 publishing worker
|
||||||
Requires=coulobre-dns-apply.socket
|
Requires=coulobre-dns-apply.socket
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
After=network-online.target coulobre-dns-apply.socket mariadb.service rabbitmq-server.service
|
After=network-online.target coulobre-dns-apply.socket mariadb.service rabbitmq-server.service
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Coulobre remote mailbox provisioning request
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=coulobre-mail-provisioner
|
||||||
|
Group=coulobre-mail-provisioner
|
||||||
|
UMask=0077
|
||||||
|
StateDirectory=
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=/usr/bin/ssh -T -F /etc/coulobre-remote/mail/ssh_config coulobre-mail-node
|
||||||
|
RuntimeMaxSec=190s
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Coulobre Panel local mailbox provisioning worker
|
Description=Coulobre Panel mailbox provisioning worker
|
||||||
Requires=coulobre-mail-apply.socket
|
Requires=coulobre-mail-apply.socket
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
After=network-online.target coulobre-mail-apply.socket mariadb.service rabbitmq-server.service
|
After=network-online.target coulobre-mail-apply.socket mariadb.service rabbitmq-server.service
|
||||||
|
|||||||
@@ -760,6 +760,9 @@ database. Sign out of phpMyAdmin to end its session.
|
|||||||
|
|
||||||
## Publish local DNS zones from the panel
|
## Publish local DNS zones from the panel
|
||||||
|
|
||||||
|
To publish to BIND9 on another host, use the
|
||||||
|
[separate-node setup](#provision-mail-and-dns-on-separate-servers).
|
||||||
|
|
||||||
Enable the [DNS publishing socket](development.md#enable-local-dns-publishing)
|
Enable the [DNS publishing socket](development.md#enable-local-dns-publishing)
|
||||||
on the panel host. Install the BIND9 publishing worker under a dedicated
|
on the panel host. Install the BIND9 publishing worker under a dedicated
|
||||||
identity with access to that socket.
|
identity with access to that socket.
|
||||||
@@ -791,6 +794,9 @@ finishes. Use **Retry publishing** if the current revision failed.
|
|||||||
|
|
||||||
## Provision local mailboxes from the panel
|
## Provision local mailboxes from the panel
|
||||||
|
|
||||||
|
To provision Postfix and Dovecot on another host, use the
|
||||||
|
[separate-node setup](#provision-mail-and-dns-on-separate-servers).
|
||||||
|
|
||||||
Set up [Postfix and Dovecot](development.md#apply-a-mailbox-manifest) on the
|
Set up [Postfix and Dovecot](development.md#apply-a-mailbox-manifest) on the
|
||||||
Ubuntu 24.04 or 26.04 panel host and enable the
|
Ubuntu 24.04 or 26.04 panel host and enable the
|
||||||
[mailbox provisioning socket](development.md#enable-local-mailbox-provisioning).
|
[mailbox provisioning socket](development.md#enable-local-mailbox-provisioning).
|
||||||
@@ -834,3 +840,140 @@ the node command for manually provisioned mailboxes.
|
|||||||
Back up mail on the node that hosts the mailbox. The archive can be used to
|
Back up mail on the node that hosts the mailbox. The archive can be used to
|
||||||
recover messages and folders into a newly provisioned mailbox with the same
|
recover messages and folders into a newly provisioned mailbox with the same
|
||||||
address. [Mailbox backup and restore](development.md#back-up-and-restore-a-mailbox)
|
address. [Mailbox backup and restore](development.md#back-up-and-restore-a-mailbox)
|
||||||
|
|
||||||
|
## Provision mail and DNS on separate servers
|
||||||
|
|
||||||
|
Choose one destination per service. For example, run mail locally and publish
|
||||||
|
DNS to a separate authoritative server. The panel uses the same worker and
|
||||||
|
job history for each deployment. On the panel server, install the SSH
|
||||||
|
drop-in only for a service that uses another host.
|
||||||
|
|
||||||
|
Several Coulobre installations under the same administration can share a
|
||||||
|
destination. Generate a separate key per sending installation and service.
|
||||||
|
The receiver accepts each key separately, and removing its line revokes that
|
||||||
|
installation's access. Each receiver can manage any Coulobre resource on its
|
||||||
|
service. Assign each domain to one installation for changes to its zones and
|
||||||
|
mailboxes.
|
||||||
|
|
||||||
|
Use the values for each service below when following the commands.
|
||||||
|
|
||||||
|
| Value | DNS | Mail |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `node` | `dns` | `mail` |
|
||||||
|
| `request_group` | `coulobre-dns-provisioning` | `coulobre-mail-provisioning` |
|
||||||
|
| `receiver` | `coulobre-dns-request` | `coulobre-mail-request` |
|
||||||
|
| `worker` | `coulobre-dns-publisher` | `coulobre-mail-provisioner` |
|
||||||
|
| Worker unit | `coulobre-dns-publisher.service` | `coulobre-mailbox-provisioner.service` |
|
||||||
|
| Panel flag | `COULOBRE_LOCAL_DNS_PUBLISHING=1` | `COULOBRE_LOCAL_MAILBOX_PROVISIONING=1` |
|
||||||
|
|
||||||
|
### Prepare the panel's SSH identity
|
||||||
|
|
||||||
|
Start from the same Coulobre source release on both hosts. For DNS, set these
|
||||||
|
variables on the panel host. For mail, substitute the values in the table.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
node=dns
|
||||||
|
request_group=coulobre-dns-provisioning
|
||||||
|
worker=coulobre-dns-publisher
|
||||||
|
|
||||||
|
sudo apt install openssh-client
|
||||||
|
getent group "$request_group" >/dev/null || sudo groupadd --system "$request_group"
|
||||||
|
id "$worker" >/dev/null 2>&1 || sudo useradd --system --user-group \
|
||||||
|
--no-create-home --home-dir /nonexistent --shell /usr/sbin/nologin "$worker"
|
||||||
|
sudo install -d -o root -g root -m 0755 /etc/coulobre-remote
|
||||||
|
sudo install -d -o root -g "$worker" -m 0750 "/etc/coulobre-remote/$node"
|
||||||
|
sudo install -o root -g "$worker" -m 0640 \
|
||||||
|
"deploy/openssh/$node-node-client.conf.example" "/etc/coulobre-remote/$node/ssh_config"
|
||||||
|
sudo sh -c 'umask 077; ssh-keygen -t ed25519 -N "" -f "$1/id_ed25519"' \
|
||||||
|
sh "/etc/coulobre-remote/$node"
|
||||||
|
sudo chown "$worker:$worker" "/etc/coulobre-remote/$node/id_ed25519"
|
||||||
|
sudo cat "/etc/coulobre-remote/$node/id_ed25519.pub"
|
||||||
|
```
|
||||||
|
|
||||||
|
Set `HostName` and `Port` in the SSH client configuration. Obtain the
|
||||||
|
destination's SSH host public key through your existing administrative
|
||||||
|
connection. Put the hostname or IP address, key type, and public key on one
|
||||||
|
line in `/etc/coulobre-remote/` under the service's `known_hosts` file. For a
|
||||||
|
port other than 22, use `[hostname]:port` in that line. Make the file owned
|
||||||
|
by root and readable by the worker group. The worker checks this pinned host
|
||||||
|
key before sending a request. [OpenSSH client configuration](https://man.openbsd.org/ssh_config)
|
||||||
|
|
||||||
|
### Install the node on the destination
|
||||||
|
|
||||||
|
On the destination, unpack the source release and install the Coulobre node
|
||||||
|
commands in `/opt/coulobre`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt install python3-venv openssh-server socat
|
||||||
|
sudo python3 -m venv /opt/coulobre
|
||||||
|
sudo /opt/coulobre/bin/pip install .
|
||||||
|
```
|
||||||
|
|
||||||
|
Set up [BIND9](development.md#apply-a-zone-manifest) or
|
||||||
|
[Postfix and Dovecot](development.md#apply-a-mailbox-manifest), then enable
|
||||||
|
the corresponding [DNS socket](development.md#enable-local-dns-publishing) or
|
||||||
|
[mailbox socket](development.md#enable-local-mailbox-provisioning). The
|
||||||
|
destination runs the local socket service shipped with Coulobre.
|
||||||
|
|
||||||
|
Save the panel's public key from the previous step as `panel-node.pub` on
|
||||||
|
the destination. Create a receiver with only the socket group for that
|
||||||
|
service. This example uses DNS. Substitute the values for a mail node.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
request_group=coulobre-dns-provisioning
|
||||||
|
receiver=coulobre-dns-request
|
||||||
|
|
||||||
|
id "$receiver" >/dev/null 2>&1 || sudo useradd --system --user-group --groups "$request_group" \
|
||||||
|
--no-create-home --home-dir / --shell /bin/sh "$receiver"
|
||||||
|
sudo install -d -o root -g root -m 0755 /etc/ssh/coulobre-node-keys
|
||||||
|
authorized_keys="/etc/ssh/coulobre-node-keys/$receiver"
|
||||||
|
sudo touch "$authorized_keys"
|
||||||
|
sudo chown root:root "$authorized_keys"
|
||||||
|
sudo chmod 0644 "$authorized_keys"
|
||||||
|
sudo tee -a "$authorized_keys" < panel-node.pub >/dev/null
|
||||||
|
sudo install -m 0644 deploy/openssh/coulobre-node-requests.conf.example \
|
||||||
|
/etc/ssh/sshd_config.d/00-coulobre-node-requests.conf
|
||||||
|
sudo sshd -t
|
||||||
|
sudo systemctl reload-or-restart ssh.service
|
||||||
|
```
|
||||||
|
|
||||||
|
The receiver authenticates with the panel's key and runs a fixed relay to
|
||||||
|
the service socket. The socket's systemd service validates and applies the
|
||||||
|
request. [OpenSSH server configuration](https://man.openbsd.org/sshd_config)
|
||||||
|
|
||||||
|
### Enable the remote destination on the panel
|
||||||
|
|
||||||
|
Use the matching worker from the table. The commands below use DNS.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
node=dns
|
||||||
|
worker_unit=coulobre-dns-publisher.service
|
||||||
|
unit="coulobre-$node-apply"
|
||||||
|
|
||||||
|
sudo install -m 0644 "deploy/systemd/$unit.socket" \
|
||||||
|
"deploy/systemd/$unit@.service" "deploy/systemd/$worker_unit" /etc/systemd/system/
|
||||||
|
sudo install -D -m 0644 "deploy/systemd/$unit@.service.d/remote.conf" \
|
||||||
|
"/etc/systemd/system/$unit@.service.d/remote.conf"
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
```
|
||||||
|
|
||||||
|
Set the corresponding flag from the table in `/etc/coulobre/panel.env`. The
|
||||||
|
flag enables the existing panel actions and queue for that service. Restart
|
||||||
|
the panel and its general worker so they pick up the setting, then enable
|
||||||
|
the dedicated worker.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl restart coulobre-panel coulobre-worker coulobre-beat
|
||||||
|
sudo systemctl enable --now "$worker_unit"
|
||||||
|
```
|
||||||
|
|
||||||
|
Use **Publish zone** or **Provision mailbox** and check the status on the
|
||||||
|
account page. After correcting a connection or host key problem, use the
|
||||||
|
corresponding retry action. Check the panel-side relay log with
|
||||||
|
`sudo journalctl -u 'coulobre-dns-apply@*.service'` for DNS or
|
||||||
|
`sudo journalctl -u 'coulobre-mail-apply@*.service'` for mail.
|
||||||
|
|
||||||
|
When moving an existing service, migrate its data and provisioning state and
|
||||||
|
let outstanding jobs finish before switching destinations.
|
||||||
|
For mail on a separate server, retrieve logins on the mail node, and use the
|
||||||
|
[separate-node backup workflow](development.md#bundle-backups-from-separate-nodes).
|
||||||
@@ -212,6 +212,10 @@ def apply_on_local_node(
|
|||||||
|
|
||||||
if len(body) > RESPONSE_LIMIT:
|
if len(body) > RESPONSE_LIMIT:
|
||||||
raise ValueError(f"The {node} returned an oversized response.")
|
raise ValueError(f"The {node} returned an oversized response.")
|
||||||
|
if not body:
|
||||||
|
raise ValueError(
|
||||||
|
f"The {node} closed the connection without a response."
|
||||||
|
)
|
||||||
invalid_response = (
|
invalid_response = (
|
||||||
f"The {node} returned an invalid response for this {resource}."
|
f"The {node} returned an invalid response for this {resource}."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -498,8 +498,8 @@ def publish_dns_zone(publication_id):
|
|||||||
DnsPublication.objects.all(),
|
DnsPublication.objects.all(),
|
||||||
publication_id,
|
publication_id,
|
||||||
apply_dns_publication,
|
apply_dns_publication,
|
||||||
"Could not complete the request to the local BIND9 node. "
|
"Could not complete the request to the BIND9 node. "
|
||||||
"Check its socket and try again.",
|
"Check the node connection and try again.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -516,8 +516,8 @@ def provision_mailbox(provisioning_id):
|
|||||||
MailboxProvisioning.objects.select_related("mailbox__mail_domain"),
|
MailboxProvisioning.objects.select_related("mailbox__mail_domain"),
|
||||||
provisioning_id,
|
provisioning_id,
|
||||||
apply_mailbox_provisioning,
|
apply_mailbox_provisioning,
|
||||||
"Could not complete the request to the local mail node. "
|
"Could not complete the request to the mail node. "
|
||||||
"Check its socket and try again.",
|
"Check the node connection and try again.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,22 @@ class DnsPublicationTests(TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class DnsPublicationSocketTests(SimpleTestCase):
|
class DnsPublicationSocketTests(SimpleTestCase):
|
||||||
|
def test_closed_connection_reports_a_missing_reply(self):
|
||||||
|
zone = DnsZone(
|
||||||
|
"site.example",
|
||||||
|
1,
|
||||||
|
("ns.provider.example",),
|
||||||
|
"hostmaster.site.example",
|
||||||
|
)
|
||||||
|
with patch("coulobre.hosting.node_client.socket.socket") as socket:
|
||||||
|
connection = socket.return_value.__enter__.return_value
|
||||||
|
connection.makefile.return_value.__enter__.return_value = BytesIO()
|
||||||
|
with self.assertRaisesMessage(
|
||||||
|
ValueError,
|
||||||
|
"The BIND9 node closed the connection without a response.",
|
||||||
|
):
|
||||||
|
publish_local_zone(zone)
|
||||||
|
|
||||||
def test_receipt_must_identify_the_exact_soa_serial(self):
|
def test_receipt_must_identify_the_exact_soa_serial(self):
|
||||||
zone = DnsZone(
|
zone = DnsZone(
|
||||||
"site.example",
|
"site.example",
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class MailboxProvisioningTests(TestCase):
|
|||||||
detail = self.client.get(self.detail)
|
detail = self.client.get(self.detail)
|
||||||
self.assertContains(detail, "Retry provisioning")
|
self.assertContains(detail, "Retry provisioning")
|
||||||
self.assertContains(
|
self.assertContains(
|
||||||
detail, "Could not complete the request to the local mail node"
|
detail, "Could not complete the request to the mail node"
|
||||||
)
|
)
|
||||||
self.assertRedirects(self.client.post(self.url), self.detail)
|
self.assertRedirects(self.client.post(self.url), self.detail)
|
||||||
job.refresh_from_db()
|
job.refresh_from_db()
|
||||||
|
|||||||
Reference in new issue
Block a user