Preserve installed release metadata and receiver assignments

This commit is contained in:
parkel committed 2026-11-24 02:07:23 +01:00
1 parent 8f5f9ef510
commit 09672ef18e
4 files changed
+44 -12

No files matched your search

+13 -4
View File
@@ -288,7 +288,9 @@ def authorize_panel(role, key_path):
write_new_file(destination, entry, mode=0o644)
def authorize_scoped_panel(role, panel, key_path, domains):
def authorize_scoped_panel(
role, panel, key_path, domains, *, keep_domains=False
):
account = scoped_account(role.name, panel)
key = one_public_key(key_path)
if not key.startswith("ssh-ed25519 "):
@@ -335,8 +337,10 @@ def authorize_scoped_panel(role, panel, key_path, domains):
check_ssh_receiver(role, account)
entry = f'command="{role.relay}",restrict {key}\n'
contents = json.dumps(sorted(domains)) + "\n"
if path.exists():
scoped_domains(path)
if path.exists() and scoped_domains(path) != domains and keep_domains:
raise ValueError(
"Use the existing domain assignment when reenrolling a panel."
)
put_file(destination, entry)
replace_configuration(path, contents, mode=0o600)
return account
@@ -594,6 +598,7 @@ def main(argv=None):
action.add_argument("panel")
action.add_argument("public_key", type=Path)
action.add_argument("domains", nargs="+")
action.add_argument("--keep-domains", action="store_true")
if command in {"begin-maintenance", "finish-maintenance"}:
action.add_argument("inventory", type=Path)
if command == "enrol-panel":
@@ -625,7 +630,11 @@ def main(argv=None):
print(f"Authorized the panel key for the {role.name} receiver.")
elif args.command == "authorize-scoped-panel":
account = authorize_scoped_panel(
role, args.panel, args.public_key, args.domains
role,
args.panel,
args.public_key,
args.domains,
keep_domains=args.keep_domains,
)
print(
f"Authorized {account}. Use --scope {args.panel} on the panel."
+12 -1
View File
@@ -360,6 +360,16 @@ def run_deployment(payload, status):
raise DeploymentError(
f"The {name} receiver did not pass its installation check."
)
if name == "mail":
changes[name].update(
mail_hostname=mail_host, tls=tls, certificate=chain, key=key
)
for option in (
"COULOBRE_MAIL_IMAP_HOST",
"COULOBRE_MAIL_SUBMISSION_HOST",
):
if not re.search(rf"(?m)^[ \t]*{option}[ \t]*=", env):
env = env.rstrip("\n") + f"\n{option}={mail_host}\n"
installation["plan"][name] = changes[name]
flag = ROLE_FLAGS[name]
env = re.sub(rf"(?m)^[ \t]*{flag}[ \t]*=[^\n]*\n?", "", env)
@@ -425,7 +435,8 @@ def handle(peer):
"Resolve the panel update before installing a host."
)
report(status, "running", "Preparing the selected release.")
send(peer, accepted=True)
with suppress(OSError):
send(peer, accepted=True)
peer.close()
try:
run_deployment(payload, status)