Enable local service health checks during installation
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-22 22:27:08 +01:00
1 parent 7e51716122
commit 52b3e84413
5 files changed
+87 -5

No files matched your search

+25 -1
View File
@@ -34,6 +34,7 @@ PANEL_UNITS = (
"coulobre-worker.service",
"coulobre-beat.service",
)
HEALTH_TIMER = "coulobre-health.timer"
BASE_PACKAGES = (
"apache2",
"mariadb-server",
@@ -547,6 +548,20 @@ class Installer:
)
def environment(self):
services = [
"panel",
"worker",
"scheduler",
"apache",
"mariadb",
"rabbitmq",
]
if self.php:
services.append("php-fpm")
if self.plan.dns.mode == "local":
services.append("bind9")
if self.plan.mail.mode == "local":
services.extend(("postfix", "dovecot", "rspamd", "redis"))
options = {
"DJANGO_SETTINGS_MODULE": "coulobre.settings",
"COULOBRE_ALLOWED_HOSTS": self.plan.hostname,
@@ -564,6 +579,9 @@ class Installer:
f"amqp://coulobre:{self.state['broker_password']}@127.0.0.1:5672/coulobre"
),
"COULOBRE_LOCAL_DATABASE_PROVISIONING": "1",
"COULOBRE_SERVICE_HEALTH": json.dumps(
{"panel": {"local": services}}, separators=(",", ":")
),
}
if self.php:
options["COULOBRE_LOCAL_WEB_ACTIVATION"] = "1"
@@ -829,13 +847,19 @@ class Installer:
self.prepare_panel()
self.progress("Validating Apache and starting the panel services.")
self.apache()
for unit in PANEL_UNITS:
identity("coulobre-health")
for unit in (
*PANEL_UNITS,
"coulobre-health.service",
HEALTH_TIMER,
):
install_unit(unit)
systemctl("daemon-reload")
systemctl(
"enable", "--now", *PANEL_UNITS, *workers, "apache2.service"
)
systemctl("reload", "apache2.service")
systemctl("enable", "--now", HEALTH_TIMER)
self.verify_panel()
if self.plan.mail.mode == "local":
with self.step("Checking Postfix for outgoing panel email"):
+6 -3
View File
@@ -2470,8 +2470,10 @@ states. Use the corresponding service tests to check mail delivery, DNS
answers, or website responses. The collector and dashboard both need the
panel database to record and display observations.
Set `COULOBRE_SERVICE_HEALTH` in `/etc/coulobre/panel.env`. This example checks
local panel services and two records for remote mail and DNS services.
The installer configures the collector for the services it installs on the
panel host. To enable a collector on an existing host or change the services
it monitors, set `COULOBRE_SERVICE_HEALTH` in `/etc/coulobre/panel.env`.
This example includes separate mail and DNS nodes.
```ini
COULOBRE_SERVICE_HEALTH='{"panel-01":{"local":["panel","worker","scheduler","apache","php-fpm","mariadb","rabbitmq"]},"mail-01":{"ssh":["postfix","dovecot"]},"dns-01":{"ssh":["bind9"]}}'
@@ -2482,7 +2484,8 @@ starting with a letter. Keep the IDs stable for the same hosts. List one
`local` node per panel installation and use `ssh` for each additional host.
Use `php-fpm` under `local` to monitor the installed stable PHP-FPM services.
The check reports a problem when any of those services is unavailable.
Use `bind9`, `postfix`, `dovecot`, `spamd`, and `spamass-milter` under
Use `bind9`, `postfix`, `dovecot`, `rspamd`, `redis`, `spamd`, and
`spamass-milter` under
`local` for co-located services or under `ssh` for separate nodes. Only
list the spam filter units where filtering is configured. Update the
Coulobre package on a remote node before adding its filter units. The
@@ -36,6 +36,8 @@
</div>
</section>
{% empty %}
<section class="surface"><p class="empty">No services are configured for health checks.</p></section>
<section class="surface">
<p class="empty">Set <code>COULOBRE_SERVICE_HEALTH</code> in <code>/etc/coulobre/panel.env</code> and enable <code>coulobre-health.timer</code> to collect service observations.</p>
</section>
{% endfor %}
{% endblock %}
+4
View File
@@ -29,6 +29,8 @@ SERVICES = {
"bind9": ("BIND9", "named.service"),
"postfix": ("Postfix", "postfix.service"),
"dovecot": ("Dovecot", "dovecot.service"),
"rspamd": ("Rspamd", "rspamd.service"),
"redis": ("Redis", "redis-server.service"),
"spamd": ("SpamAssassin", "spamd.service"),
"spamass-milter": ("SpamAssassin milter", "spamass-milter.service"),
"firewall": ("Coulobre firewall", "coulobre-firewall.service"),
@@ -38,6 +40,8 @@ REMOTE_SERVICES = (
"bind9",
"postfix",
"dovecot",
"rspamd",
"redis",
"spamd",
"spamass-milter",
"firewall",
+49
View File
@@ -1,3 +1,4 @@
import json
import stat
import tempfile
import unittest
@@ -12,6 +13,7 @@ from deploy.panel_installer.config import (
read_password,
read_plan,
)
from deploy.panel_installer.engine import Installer
from deploy.panel_installer.web import Wizard, WizardHandler, form_plan
PROXY = {
@@ -24,6 +26,53 @@ ADMIN = {"username": "operator", "email": "ops@example.net"}
class InstallerParametersTests(unittest.TestCase):
def test_default_health_targets_follow_locally_installed_roles(self):
cases = (
({}, None, []),
(
{
"dns": {"mode": "local"},
"mail": {
"mode": "local",
"host": "panel.example.net",
"tls": "acme",
},
},
"8.5",
["php-fpm", "bind9", "postfix", "dovecot", "rspamd", "redis"],
),
)
for roles, php, extras in cases:
with (
self.subTest(roles=roles),
patch(
"deploy.panel_installer.engine.platform_settings",
return_value=(php, True),
),
):
plan = parse_plan({"panel": PROXY, "admin": ADMIN, **roles})
installer = Installer(plan, "test-only", Mock())
installer.state = dict.fromkeys(
("secret_key", "database_password", "broker_password"),
"test-only",
)
env = dict(
line.split("=", 1)
for line in installer.environment().splitlines()
)
base = [
"panel",
"worker",
"scheduler",
"apache",
"mariadb",
"rabbitmq",
]
self.assertEqual(
json.loads(env["COULOBRE_SERVICE_HEALTH"]),
{"panel": {"local": base + extras}},
)
def test_interactive_export_reuses_the_same_plan(self):
plan = parse_plan(
{