Explain setup choices and database service failures
Coulobre Panel CI / Checks (Python 3.12) (pull_request) Canceled after 0s
Coulobre Panel CI / Checks (Python 3.14) (pull_request) Canceled after 0s

This commit is contained in:
parkel committed 2026-11-24 12:15:16 +01:00
1 parent 3812e37d5b
commit e658bf5b30
6 files changed
+245 -35

No files matched your search

+8
View File
@@ -31,3 +31,11 @@ mode = "off"
# ssh_identity. ssh_identity is a root-owned 0600 file on the panel host. # ssh_identity. ssh_identity is a root-owned 0600 file on the panel host.
# For remote mail installation, set mail_hostname to the public service # For remote mail installation, set mail_hostname to the public service
# hostname. Provide tls = "acme" or certificate and key paths on that host. # hostname. Provide tls = "acme" or certificate and key paths on that host.
[hosting]
# Addresses clients use for hosted websites. Used in default A and AAAA records.
# public_addresses = ["192.0.2.21", "2001:db8::21"]
# Authoritative nameservers for new NS records. Set delegation at the registrar.
# nameservers = ["ns1.example.net", "ns2.example.net"]
# Public outbound SMTP addresses, including the NAT address if used. Used for SPF.
# mail_sending_addresses = ["192.0.2.25"]
+46 -15
View File
@@ -6,6 +6,7 @@ from getpass import getpass
from pathlib import Path from pathlib import Path
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from . import guidance
from .config import ( from .config import (
REMOTE_MODES, REMOTE_MODES,
InstallError, InstallError,
@@ -18,7 +19,9 @@ from .config import (
from .engine import Installer from .engine import Installer
def prompt(label, default=""): def prompt(label, default="", *, hint=""):
if hint:
print(f" {hint}", flush=True)
value = input(f"{label}{f' [{default}]' if default else ''}: ").strip() value = input(f"{label}{f' [{default}]' if default else ''}: ").strip()
return value or default return value or default
@@ -37,7 +40,9 @@ def comma_separated(values):
def interactive_plan(previous=None): def interactive_plan(previous=None):
if previous is None: if previous is None:
preset = prompt( preset = prompt(
"Installation profile (full-service or custom)", "full-service" "Installation profile (full-service or custom)",
"full-service",
hint=guidance.PROFILE,
) )
if preset not in {"full-service", "custom"}: if preset not in {"full-service", "custom"}:
raise InstallError("Choose full-service or custom.") raise InstallError("Choose full-service or custom.")
@@ -46,18 +51,25 @@ def interactive_plan(previous=None):
preset = "custom" preset = "custom"
defaults = export_parameters(previous, None) defaults = export_parameters(previous, None)
def ask(label, section, name, fallback=""): def ask(label, section, name, fallback="", *, hint=""):
return prompt( return prompt(
label, str(defaults.get(section, {}).get(name, fallback)) label,
str(defaults.get(section, {}).get(name, fallback)),
hint=hint,
) )
full_service = preset == "full-service" full_service = preset == "full-service"
panel = {"hostname": ask("Panel hostname", "panel", "hostname")} panel = {
"hostname": ask(
"Panel hostname", "panel", "hostname", hint=guidance.PANEL_HOSTNAME
)
}
access = panel["access"] = ask( access = panel["access"] = ask(
"Panel access (tls, acme, or proxy)", "Panel access (tls, acme, or proxy)",
"panel", "panel",
"access", "access",
"acme" if full_service else "tls", "acme" if full_service else "tls",
hint=guidance.PANEL_ACCESS,
) )
if access == "tls": if access == "tls":
panel["certificate"] = ask( panel["certificate"] = ask(
@@ -66,9 +78,17 @@ def interactive_plan(previous=None):
panel["key"] = ask("Panel private key path", "panel", "key") panel["key"] = ask("Panel private key path", "panel", "key")
elif access == "proxy": elif access == "proxy":
panel["origin_ip"] = ask( panel["origin_ip"] = ask(
"Private origin address", "panel", "origin_ip" "Private origin address",
"panel",
"origin_ip",
hint=guidance.ORIGIN_ADDRESS,
)
panel["proxy_ip"] = ask(
"Trusted proxy address",
"panel",
"proxy_ip",
hint=guidance.PROXY_ADDRESS,
) )
panel["proxy_ip"] = ask("Trusted proxy address", "panel", "proxy_ip")
panel["origin_port"] = number( panel["origin_port"] = number(
ask("Origin port", "panel", "origin_port", "8080"), "the origin" ask("Origin port", "panel", "origin_port", "8080"), "the origin"
) )
@@ -78,7 +98,12 @@ def interactive_plan(previous=None):
"username": ask( "username": ask(
"Administrator username", "admin", "username", "operator" "Administrator username", "admin", "username", "operator"
), ),
"email": ask("Administrator email", "admin", "email"), "email": ask(
"Administrator email",
"admin",
"email",
hint=guidance.ADMIN_EMAIL,
),
}, },
} }
for name in ("dns", "mail"): for name in ("dns", "mail"):
@@ -87,6 +112,7 @@ def interactive_plan(previous=None):
name, name,
"mode", "mode",
"local" if full_service else "off", "local" if full_service else "off",
hint=guidance.DNS_ROLE if name == "dns" else guidance.MAIL_ROLE,
) )
target = data[name] = {"mode": mode} target = data[name] = {"mode": mode}
if mode in REMOTE_MODES: if mode in REMOTE_MODES:
@@ -97,14 +123,20 @@ def interactive_plan(previous=None):
ask("SSH port", name, "port", "22"), f"the {name} node" ask("SSH port", name, "port", "22"), f"the {name} node"
) )
target["host_key"] = ask( target["host_key"] = ask(
"Verified SSH host public key file", name, "host_key" "Verified SSH host public key file",
name,
"host_key",
hint=guidance.SSH_HOST_KEY,
) )
if mode == "remote-install": if mode == "remote-install":
target["ssh_user"] = ask( target["ssh_user"] = ask(
"SSH administrator username", name, "ssh_user" "SSH administrator username", name, "ssh_user"
) )
target["ssh_identity"] = ask( target["ssh_identity"] = ask(
"SSH administrator private key file", name, "ssh_identity" "SSH administrator private key file",
name,
"ssh_identity",
hint=guidance.SSH_IDENTITY,
) )
if name == "mail" and mode in {"local", "remote-install"}: if name == "mail" and mode in {"local", "remote-install"}:
field = "host" if mode == "local" else "mail_hostname" field = "host" if mode == "local" else "mail_hostname"
@@ -113,12 +145,14 @@ def interactive_plan(previous=None):
name, name,
field, field,
panel["hostname"] if mode == "local" else "", panel["hostname"] if mode == "local" else "",
hint=guidance.MAIL_HOSTNAME,
) )
target["tls"] = ask( target["tls"] = ask(
"Mail TLS (provided or acme)", "Mail TLS (provided or acme)",
name, name,
"tls", "tls",
"acme" if access == "acme" and mode == "local" else "provided", "acme" if access == "acme" and mode == "local" else "provided",
hint=guidance.MAIL_TLS,
) )
if target["tls"] == "provided": if target["tls"] == "provided":
target["certificate"] = ask( target["certificate"] = ask(
@@ -128,11 +162,7 @@ def interactive_plan(previous=None):
"Private key path on the mail host", name, "key" "Private key path on the mail host", name, "key"
) )
hosting = data["hosting"] = {} hosting = data["hosting"] = {}
for name, label in ( for name, label, hint in guidance.HOSTING_FIELDS:
("public_addresses", "IP addresses for hosted websites"),
("nameservers", "Nameservers for new DNS zones"),
("mail_sending_addresses", "Public sending IPs for hosted email"),
):
if name == "nameservers" and data["dns"]["mode"] == "off": if name == "nameservers" and data["dns"]["mode"] == "off":
continue continue
if name == "mail_sending_addresses" and data["mail"]["mode"] not in { if name == "mail_sending_addresses" and data["mail"]["mode"] not in {
@@ -144,6 +174,7 @@ def interactive_plan(previous=None):
value = prompt( value = prompt(
f"{label} (comma-separated, or none)", f"{label} (comma-separated, or none)",
", ".join(previous_values) or "none", ", ".join(previous_values) or "none",
hint=hint,
) )
hosting[name] = [] if value == "none" else comma_separated(value) hosting[name] = [] if value == "none" else comma_separated(value)
return parse_plan(data) return parse_plan(data)
+7
View File
@@ -485,8 +485,15 @@ class Installer:
("RabbitMQ", "rabbitmq-server.service"), ("RabbitMQ", "rabbitmq-server.service"),
): ):
with self.step(f"Starting {name} on loopback"): with self.step(f"Starting {name} on loopback"):
try:
systemctl("enable", "--now", unit) systemctl("enable", "--now", unit)
systemctl("restart", unit) systemctl("restart", unit)
except InstallError:
self.progress(
f"Read the {name} service log with "
f"sudo journalctl -b -u {unit} -n 60 --no-pager"
)
raise
def mariadb(sql): def mariadb(sql):
return run( return run(
+68
View File
@@ -0,0 +1,68 @@
"""Help text shared by the interactive installer and browser wizard."""
PROFILE = (
"Full-service preselects local DNS and mail with Let's Encrypt. "
"Custom starts with DNS and mail off."
)
PANEL_HOSTNAME = (
"The full DNS name administrators and customers use to sign in."
)
PANEL_ACCESS = (
"Use acme for Let's Encrypt, tls for an existing certificate on this "
"server, or proxy when a trusted reverse proxy handles HTTPS."
)
ORIGIN_ADDRESS = (
"The private address on this server that the proxy connects to."
)
PROXY_ADDRESS = "The source IP of the trusted proxy as seen by this server."
ADMIN_EMAIL = (
"Use an inbox you can open now. Coulobre uses this address for notices "
"and Let's Encrypt registration when enabled."
)
DNS_ROLE = (
"Use local to serve zones here, or off to manage DNS elsewhere. "
"Use remote for an existing Coulobre DNS node or remote-install to "
"set one up over SSH."
)
MAIL_ROLE = (
"Use local to host mail here, or off to use a separate mail provider. "
"Use remote for an existing Coulobre mail node or remote-install to "
"set one up over SSH."
)
MAIL_HOSTNAME = (
"The public name mail clients and other mail servers use to reach "
"this mail service."
)
MAIL_TLS = (
"Use acme for Let's Encrypt or provided for certificate and key files "
"already available on the mail server."
)
SSH_HOST_KEY = "A file with the verified public host key of the remote server."
SSH_IDENTITY = (
"The private key file on this panel server used to sign in as the "
"SSH administrator."
)
HOSTING_FIELDS = (
(
"public_addresses",
"IP addresses for hosted websites",
"Public IPv4 or IPv6 addresses used in default A and AAAA records. "
"Use the addresses visitors connect to, or leave unset to add them "
"later.",
),
(
"nameservers",
"Nameservers for new DNS zones",
"Authoritative nameserver hostnames, such as ns1.example.net. "
"Coulobre uses them in new NS records. Set public delegation "
"separately at the registrar, or leave unset to configure later.",
),
(
"mail_sending_addresses",
"Public sending IPs for hosted email",
"The public outbound SMTP addresses, including the NAT address "
"if used. Coulobre uses them to prepare SPF and managed mail DNS. "
"Leave unset to configure those records separately.",
),
)
+58 -18
View File
@@ -9,6 +9,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
from threading import Thread from threading import Thread
from urllib.parse import parse_qs from urllib.parse import parse_qs
from . import guidance
from .cli import comma_separated, number from .cli import comma_separated, number
from .config import REMOTE_MODES, InstallError, parse_plan, port from .config import REMOTE_MODES, InstallError, parse_plan, port
from .engine import SOURCE, Installer from .engine import SOURCE, Installer
@@ -21,28 +22,34 @@ FORM = """<form method="post" action="/review">
websites, databases, DNS and mail run locally. Adjust the settings below websites, databases, DNS and mail run locally. Adjust the settings below
for a different deployment.</p> for a different deployment.</p>
<fieldset><legend>Panel</legend> <fieldset><legend>Panel</legend>
<label>Hostname<input name="hostname" autocomplete="off" required></label> <label>Hostname<input name="hostname" aria-describedby="hostname-hint"
<label>Access<select name="access"> autocomplete="off" required></label>
{hostname_hint}
<label>Access<select name="access" aria-describedby="access-hint">
<option value="acme">HTTPS with Let's Encrypt</option> <option value="acme">HTTPS with Let's Encrypt</option>
<option value="tls">HTTPS on this server</option> <option value="tls">HTTPS with an existing certificate</option>
<option value="proxy">Trusted external HTTPS proxy</option></select></label> <option value="proxy">Trusted external HTTPS proxy</option></select></label>
{access_hint}
<label>Panel certificate path<input name="certificate"></label> <label>Panel certificate path<input name="certificate"></label>
<label>Panel private key path<input name="key"></label> <label>Panel private key path<input name="key"></label>
<label>Private origin address<input name="origin_ip"></label> <label>Private origin address
<label>Trusted proxy address<input name="proxy_ip"></label> <input name="origin_ip" aria-describedby="origin_ip-hint"></label>
{origin_hint}
<label>Trusted proxy address
<input name="proxy_ip" aria-describedby="proxy_ip-hint"></label>
{proxy_hint}
<label>Origin port<input name="origin_port" type="number" value="8080"></label> <label>Origin port<input name="origin_port" type="number" value="8080"></label>
</fieldset> </fieldset>
<fieldset><legend>Administrator</legend> <fieldset><legend>Administrator</legend>
<label>Username<input name="username" value="operator" required></label> <label>Username<input name="username" value="operator" required></label>
<label>Email<input name="email" type="email" required></label> <label>Email<input name="email" type="email" aria-describedby="email-hint"
required></label>
{email_hint}
</fieldset> </fieldset>
{dns}{mail} {dns}{mail}
<fieldset><legend>New hosting accounts</legend> <fieldset><legend>New hosting accounts</legend>
<p>Separate multiple values with commas. You can also set these later.</p> <p>Separate multiple values with commas.</p>
<label>IP addresses for hosted websites<input name="public_addresses"></label> {hosting}
<label>Nameservers for new DNS zones<input name="nameservers"></label>
<label>Public sending IPs for hosted email
<input name="mail_sending_addresses"></label>
</fieldset> </fieldset>
<button type="submit">Review installation</button></form>""" <button type="submit">Review installation</button></form>"""
STYLE = """:root{color-scheme:light} STYLE = """:root{color-scheme:light}
@@ -51,6 +58,8 @@ h1 img{width:1.9rem;height:1.9rem;flex:none}
body{font:1rem system-ui,sans-serif;max-width:46rem;margin:auto; body{font:1rem system-ui,sans-serif;max-width:46rem;margin:auto;
padding:1rem;color:#14372e} fieldset{margin:1rem 0;border:1px solid #a9beb2; padding:1rem;color:#14372e} fieldset{margin:1rem 0;border:1px solid #a9beb2;
border-radius:.4rem;padding:1rem} label{display:block;margin-bottom:.75rem} border-radius:.4rem;padding:1rem} label{display:block;margin-bottom:.75rem}
label:has(+.field-hint){margin-bottom:.25rem}
.field-hint{display:block;margin-bottom:.75rem;color:#3f5c52}
input,select{display:block;box-sizing:border-box;width:100%;padding:.45rem; input,select{display:block;box-sizing:border-box;width:100%;padding:.45rem;
margin-top:.25rem} button{background:#195a46;color:white;border:0; margin-top:.25rem} button{background:#195a46;color:white;border:0;
border-radius:.3rem;padding:.75rem 1.1rem;font:inherit} summary{cursor:pointer} border-radius:.3rem;padding:.75rem 1.1rem;font:inherit} summary{cursor:pointer}
@@ -58,15 +67,26 @@ border-radius:.3rem;padding:.75rem 1.1rem;font:inherit} summary{cursor:pointer}
[role=alert]{color:#8c2828}""" [role=alert]{color:#8c2828}"""
def field_hint(name, message):
return (
f'<small class="field-hint" id="{name}-hint">{escape(message)}</small>'
)
def role_form(name): def role_form(name):
title = name.upper() if name == "dns" else "Mail" title = name.upper() if name == "dns" else "Mail"
local = ( local = (
"<label>Public mail hostname" "<label>Public mail hostname"
'<input name="mail_local_host"></label>' '<input name="mail_local_host" '
'<label>Mail TLS<select name="mail_tls">' 'aria-describedby="mail_local_host-hint">'
"</label>"
f"{field_hint('mail_local_host', guidance.MAIL_HOSTNAME)}"
'<label>Mail TLS<select name="mail_tls" '
'aria-describedby="mail_tls-hint">'
'<option value="acme">Let&#39;s Encrypt</option>' '<option value="acme">Let&#39;s Encrypt</option>'
'<option value="provided">Existing certificate</option>' '<option value="provided">Existing certificate</option>'
"</select></label>" "</select></label>"
f"{field_hint('mail_tls', guidance.MAIL_TLS)}"
"<label>Certificate path on the mail host" "<label>Certificate path on the mail host"
'<input name="mail_certificate"></label>' '<input name="mail_certificate"></label>'
"<label>Private key path on the mail host" "<label>Private key path on the mail host"
@@ -74,22 +94,28 @@ def role_form(name):
if name == "mail" if name == "mail"
else "" else ""
) )
role_hint = guidance.DNS_ROLE if name == "dns" else guidance.MAIL_ROLE
return f"""<fieldset><legend>{title}</legend> return f"""<fieldset><legend>{title}</legend>
<label>Role<select name="{name}_mode"> <label>Role<select name="{name}_mode" aria-describedby="{name}_mode-hint">
<option value="local">Local service</option> <option value="local">Local service</option>
<option value="off">Disabled</option> <option value="off">Disabled</option>
<option value="remote">Connect an existing Coulobre node</option> <option value="remote">Connect an existing Coulobre node</option>
<option value="remote-install">Install and connect a Coulobre node</option> <option value="remote-install">Install and connect a Coulobre node</option>
</select></label> </select></label>
{field_hint(f"{name}_mode", role_hint)}
{local} {local}
<details><summary>Separate node settings</summary> <details><summary>Separate node settings</summary>
<label>SSH hostname or address<input name="{name}_host"></label> <label>SSH hostname or address<input name="{name}_host"></label>
<label>SSH port<input name="{name}_port" type="number" value="22"></label> <label>SSH port<input name="{name}_port" type="number" value="22"></label>
<label>Verified SSH host public key file<input name="{name}_host_key"></label> <label>Verified SSH host public key file
<input name="{name}_host_key" aria-describedby="{name}_host_key-hint"></label>
{field_hint(f"{name}_host_key", guidance.SSH_HOST_KEY)}
<label>SSH administrator username for installation <label>SSH administrator username for installation
<input name="{name}_ssh_user"></label> <input name="{name}_ssh_user"></label>
<label>SSH administrator key file for installation <label>SSH administrator key file for installation
<input name="{name}_ssh_identity"></label> <input name="{name}_ssh_identity" aria-describedby="{name}_ssh_identity-hint">
</label>
{field_hint(f"{name}_ssh_identity", guidance.SSH_IDENTITY)}
</details></fieldset>""" </details></fieldset>"""
@@ -155,7 +181,21 @@ def form_plan(fields):
def installation_form(values): def installation_form(values):
html = FORM.format(dns=role_form("dns"), mail=role_form("mail")) hosting = "".join(
f'<label>{label}<input name="{name}" aria-describedby="{name}-hint">'
f"</label>{field_hint(name, hint)}"
for name, label, hint in guidance.HOSTING_FIELDS
)
html = FORM.format(
dns=role_form("dns"),
mail=role_form("mail"),
hosting=hosting,
hostname_hint=field_hint("hostname", guidance.PANEL_HOSTNAME),
access_hint=field_hint("access", guidance.PANEL_ACCESS),
origin_hint=field_hint("origin_ip", guidance.ORIGIN_ADDRESS),
proxy_hint=field_hint("proxy_ip", guidance.PROXY_ADDRESS),
email_hint=field_hint("email", guidance.ADMIN_EMAIL),
)
def restore_field(match): def restore_field(match):
tag = match[0] tag = match[0]
@@ -171,7 +211,7 @@ def installation_form(values):
return re.sub( return re.sub(
r'<input name="(?P<input>[a-z_]+)"[^>]*>|' r'<input name="(?P<input>[a-z_]+)"[^>]*>|'
r'<select name="(?P<select>[a-z_]+)">.*?</select>', r'<select name="(?P<select>[a-z_]+)"[^>]*>.*?</select>',
restore_field, restore_field,
html, html,
flags=re.DOTALL, flags=re.DOTALL,
+58 -2
View File
@@ -3,11 +3,13 @@ import shlex
import stat import stat
import tempfile import tempfile
import unittest import unittest
from contextlib import redirect_stdout
from io import StringIO
from pathlib import Path from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from deploy.panel_installer.cli import save_interactive_plan from deploy.panel_installer.cli import interactive_plan, save_interactive_plan
from deploy.panel_installer.config import ( from deploy.panel_installer.config import (
InstallError, InstallError,
parse_plan, parse_plan,
@@ -15,7 +17,12 @@ from deploy.panel_installer.config import (
read_plan, read_plan,
) )
from deploy.panel_installer.engine import Installer, install_worker from deploy.panel_installer.engine import Installer, install_worker
from deploy.panel_installer.web import Wizard, WizardHandler, form_plan from deploy.panel_installer.web import (
Wizard,
WizardHandler,
form_plan,
installation_form,
)
PROXY = { PROXY = {
"hostname": "Panel.Example.NET", "hostname": "Panel.Example.NET",
@@ -139,6 +146,39 @@ class InstallerParametersTests(unittest.TestCase):
self.assertEqual(stat.S_IMODE(path.stat().st_mode), 0o600) self.assertEqual(stat.S_IMODE(path.stat().st_mode), 0o600)
self.assertEqual(parse_plan(read_plan(path)), plan) self.assertEqual(parse_plan(read_plan(path)), plan)
def test_interactive_hosting_hints_explain_dns_and_keep_defaults(self):
replies = [
"",
"panel.example.net",
"",
"",
"ops@example.net",
"",
"",
"",
"",
"192.0.2.21",
"ns1.example.net",
"",
]
output = StringIO()
with (
patch("builtins.input", side_effect=replies),
redirect_stdout(output),
):
plan = interactive_plan()
self.assertEqual(plan.dns.mode, "local")
self.assertEqual(plan.mail.mode, "local")
self.assertEqual(plan.hosting.public_addresses, ("192.0.2.21",))
self.assertEqual(plan.hosting.nameservers, ("ns1.example.net",))
self.assertEqual(plan.hosting.mail_sending_addresses, ())
self.assertIn("default A and AAAA records", output.getvalue())
self.assertIn(
"delegation separately at the registrar", output.getvalue()
)
self.assertIn("SPF and managed mail DNS", output.getvalue())
def test_browser_and_parameter_file_share_the_same_plan(self): def test_browser_and_parameter_file_share_the_same_plan(self):
with tempfile.TemporaryDirectory() as folder: with tempfile.TemporaryDirectory() as folder:
params = Path(folder) / "panel.toml" params = Path(folder) / "panel.toml"
@@ -260,6 +300,22 @@ class InstallerParametersTests(unittest.TestCase):
class SetupWizardTests(unittest.TestCase): class SetupWizardTests(unittest.TestCase):
def test_form_hints_are_linked_and_saved_choices_are_restored(self):
html = installation_form(
{
"access": "proxy",
"dns_mode": "off",
"mail_tls": "provided",
"public_addresses": "192.0.2.21",
}
)
for name in ("access", "dns_mode", "mail_tls", "public_addresses"):
self.assertIn(f'aria-describedby="{name}-hint"', html)
self.assertIn(f'id="{name}-hint"', html)
for value in ("proxy", "off", "provided"):
self.assertIn(f'<option value="{value}" selected>', html)
self.assertIn('value="192.0.2.21"', html)
def handler(self): def handler(self):
handler = WizardHandler.__new__(WizardHandler) handler = WizardHandler.__new__(WizardHandler)
handler.server = SimpleNamespace( handler.server = SimpleNamespace(