Enable local service health checks during installation
This commit is contained in:
1 parent
7e51716122
commit
52b3e84413
5 files changed
+87
-5
No files matched your search
@@ -34,6 +34,7 @@ PANEL_UNITS = (
|
|||||||
"coulobre-worker.service",
|
"coulobre-worker.service",
|
||||||
"coulobre-beat.service",
|
"coulobre-beat.service",
|
||||||
)
|
)
|
||||||
|
HEALTH_TIMER = "coulobre-health.timer"
|
||||||
BASE_PACKAGES = (
|
BASE_PACKAGES = (
|
||||||
"apache2",
|
"apache2",
|
||||||
"mariadb-server",
|
"mariadb-server",
|
||||||
@@ -547,6 +548,20 @@ class Installer:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def environment(self):
|
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 = {
|
options = {
|
||||||
"DJANGO_SETTINGS_MODULE": "coulobre.settings",
|
"DJANGO_SETTINGS_MODULE": "coulobre.settings",
|
||||||
"COULOBRE_ALLOWED_HOSTS": self.plan.hostname,
|
"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"
|
f"amqp://coulobre:{self.state['broker_password']}@127.0.0.1:5672/coulobre"
|
||||||
),
|
),
|
||||||
"COULOBRE_LOCAL_DATABASE_PROVISIONING": "1",
|
"COULOBRE_LOCAL_DATABASE_PROVISIONING": "1",
|
||||||
|
"COULOBRE_SERVICE_HEALTH": json.dumps(
|
||||||
|
{"panel": {"local": services}}, separators=(",", ":")
|
||||||
|
),
|
||||||
}
|
}
|
||||||
if self.php:
|
if self.php:
|
||||||
options["COULOBRE_LOCAL_WEB_ACTIVATION"] = "1"
|
options["COULOBRE_LOCAL_WEB_ACTIVATION"] = "1"
|
||||||
@@ -829,13 +847,19 @@ class Installer:
|
|||||||
self.prepare_panel()
|
self.prepare_panel()
|
||||||
self.progress("Validating Apache and starting the panel services.")
|
self.progress("Validating Apache and starting the panel services.")
|
||||||
self.apache()
|
self.apache()
|
||||||
for unit in PANEL_UNITS:
|
identity("coulobre-health")
|
||||||
|
for unit in (
|
||||||
|
*PANEL_UNITS,
|
||||||
|
"coulobre-health.service",
|
||||||
|
HEALTH_TIMER,
|
||||||
|
):
|
||||||
install_unit(unit)
|
install_unit(unit)
|
||||||
systemctl("daemon-reload")
|
systemctl("daemon-reload")
|
||||||
systemctl(
|
systemctl(
|
||||||
"enable", "--now", *PANEL_UNITS, *workers, "apache2.service"
|
"enable", "--now", *PANEL_UNITS, *workers, "apache2.service"
|
||||||
)
|
)
|
||||||
systemctl("reload", "apache2.service")
|
systemctl("reload", "apache2.service")
|
||||||
|
systemctl("enable", "--now", HEALTH_TIMER)
|
||||||
self.verify_panel()
|
self.verify_panel()
|
||||||
if self.plan.mail.mode == "local":
|
if self.plan.mail.mode == "local":
|
||||||
with self.step("Checking Postfix for outgoing panel email"):
|
with self.step("Checking Postfix for outgoing panel email"):
|
||||||
|
|||||||
+6
-3
@@ -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
|
answers, or website responses. The collector and dashboard both need the
|
||||||
panel database to record and display observations.
|
panel database to record and display observations.
|
||||||
|
|
||||||
Set `COULOBRE_SERVICE_HEALTH` in `/etc/coulobre/panel.env`. This example checks
|
The installer configures the collector for the services it installs on the
|
||||||
local panel services and two records for remote mail and DNS services.
|
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
|
```ini
|
||||||
COULOBRE_SERVICE_HEALTH='{"panel-01":{"local":["panel","worker","scheduler","apache","php-fpm","mariadb","rabbitmq"]},"mail-01":{"ssh":["postfix","dovecot"]},"dns-01":{"ssh":["bind9"]}}'
|
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.
|
`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.
|
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.
|
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
|
`local` for co-located services or under `ssh` for separate nodes. Only
|
||||||
list the spam filter units where filtering is configured. Update the
|
list the spam filter units where filtering is configured. Update the
|
||||||
Coulobre package on a remote node before adding its filter units. The
|
Coulobre package on a remote node before adding its filter units. The
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{% empty %}
|
{% 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 %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -29,6 +29,8 @@ SERVICES = {
|
|||||||
"bind9": ("BIND9", "named.service"),
|
"bind9": ("BIND9", "named.service"),
|
||||||
"postfix": ("Postfix", "postfix.service"),
|
"postfix": ("Postfix", "postfix.service"),
|
||||||
"dovecot": ("Dovecot", "dovecot.service"),
|
"dovecot": ("Dovecot", "dovecot.service"),
|
||||||
|
"rspamd": ("Rspamd", "rspamd.service"),
|
||||||
|
"redis": ("Redis", "redis-server.service"),
|
||||||
"spamd": ("SpamAssassin", "spamd.service"),
|
"spamd": ("SpamAssassin", "spamd.service"),
|
||||||
"spamass-milter": ("SpamAssassin milter", "spamass-milter.service"),
|
"spamass-milter": ("SpamAssassin milter", "spamass-milter.service"),
|
||||||
"firewall": ("Coulobre firewall", "coulobre-firewall.service"),
|
"firewall": ("Coulobre firewall", "coulobre-firewall.service"),
|
||||||
@@ -38,6 +40,8 @@ REMOTE_SERVICES = (
|
|||||||
"bind9",
|
"bind9",
|
||||||
"postfix",
|
"postfix",
|
||||||
"dovecot",
|
"dovecot",
|
||||||
|
"rspamd",
|
||||||
|
"redis",
|
||||||
"spamd",
|
"spamd",
|
||||||
"spamass-milter",
|
"spamass-milter",
|
||||||
"firewall",
|
"firewall",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import stat
|
import stat
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@@ -12,6 +13,7 @@ from deploy.panel_installer.config import (
|
|||||||
read_password,
|
read_password,
|
||||||
read_plan,
|
read_plan,
|
||||||
)
|
)
|
||||||
|
from deploy.panel_installer.engine import Installer
|
||||||
from deploy.panel_installer.web import Wizard, WizardHandler, form_plan
|
from deploy.panel_installer.web import Wizard, WizardHandler, form_plan
|
||||||
|
|
||||||
PROXY = {
|
PROXY = {
|
||||||
@@ -24,6 +26,53 @@ ADMIN = {"username": "operator", "email": "ops@example.net"}
|
|||||||
|
|
||||||
|
|
||||||
class InstallerParametersTests(unittest.TestCase):
|
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):
|
def test_interactive_export_reuses_the_same_plan(self):
|
||||||
plan = parse_plan(
|
plan = parse_plan(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user