feat(plugins): default-enable generic bundled plugins on fresh install
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 7s
CI / integration (push) Failing after 2m16s
CI / publish (push) Has been skipped

A fresh install enabled zero plugins — settings.py DEFAULTS had no plugin.*
keys, so to_plugins_cfg returned {} and every plugin had to be flipped on
by hand. Seed docker, host_agent, http, snmp as default-on (generic, non-
vendor-specific); traefik and unifi stay opt-in. Stored choices override
the default, so disabling persists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-15 21:24:21 -04:00
parent 80613d6310
commit b49496b57b
2 changed files with 52 additions and 0 deletions
+11
View File
@@ -60,6 +60,17 @@ DEFAULTS: dict[str, Any] = {
"ping.threshold.good_ms": 50, "ping.threshold.good_ms": 50,
"ping.threshold.warn_ms": 200, "ping.threshold.warn_ms": 200,
"plugins.index_url": "https://git.fabledsword.com/bvandeusen/Steward-plugins/raw/branch/main/index.yaml", "plugins.index_url": "https://git.fabledsword.com/bvandeusen/Steward-plugins/raw/branch/main/index.yaml",
# Default-enabled plugins. These are the generic, non-vendor-specific
# bundled plugins (protocols/standards, not a single product) — useful on
# almost any install, so a fresh deployment comes up monitoring rather than
# blank. Vendor-specific plugins (traefik, unifi) stay opt-in. An operator
# who disables one writes plugin.<name>={"enabled": False}, which overrides
# these defaults (stored value wins in get_all_settings/load_settings_sync).
# Per-plugin yaml config defaults are merged on top at load time.
"plugin.docker": {"enabled": True},
"plugin.host_agent": {"enabled": True},
"plugin.http": {"enabled": True},
"plugin.snmp": {"enabled": True},
# OIDC single-sign-on # OIDC single-sign-on
"oidc.enabled": False, "oidc.enabled": False,
"oidc.discovery_url": "", "oidc.discovery_url": "",
@@ -0,0 +1,41 @@
"""Pure-function tests for the default-enabled plugin set.
A fresh install (no stored plugin.* rows) should come up with the generic,
non-vendor-specific bundled plugins already enabled, while vendor-specific
plugins stay opt-in. An operator's stored choice must override the default.
No DB / Quart fixtures — we exercise to_plugins_cfg over the DEFAULTS dict
and a DEFAULTS-merged-with-stored dict, mirroring get_all_settings' merge.
"""
from steward.core import settings as settings_module
from steward.core.settings import DEFAULTS, to_plugins_cfg
DEFAULT_ON = {"docker", "host_agent", "http", "snmp"}
VENDOR_OPT_IN = {"traefik", "unifi"}
def test_generic_plugins_enabled_by_default():
cfg = to_plugins_cfg(DEFAULTS)
for name in DEFAULT_ON:
assert cfg.get(name, {}).get("enabled") is True, name
def test_vendor_plugins_not_enabled_by_default():
cfg = to_plugins_cfg(DEFAULTS)
for name in VENDOR_OPT_IN:
assert name not in cfg, name
def test_stored_choice_overrides_default():
# get_all_settings / load_settings_sync overlay stored values onto DEFAULTS;
# a stored disable must win over the built-in default-on.
merged = {**DEFAULTS, "plugin.docker": {"enabled": False}}
cfg = to_plugins_cfg(merged)
assert cfg["docker"]["enabled"] is False
# untouched defaults remain enabled
assert cfg["http"]["enabled"] is True
def test_defaults_use_plugin_dot_namespace():
# The keys must live under the plugin.<name> namespace to_plugins_cfg reads.
for name in DEFAULT_ON:
assert f"plugin.{name}" in settings_module.DEFAULTS