feature: the PKI's schema is a file of its own that another slapd loads, a certificate can carry the name an application files it under, and the members of pki-managers manage the PKI with its keys.
Release / release (push) Successful in 24s

This commit is contained in:
slawek committed 2026-11-24 14:30:50 +01:00
1 parent 6911d16fa3
commit b61d1593b7
14 files changed
+378 -169

No files matched your search

+19 -16
View File
@@ -1,18 +1,19 @@
#!/usr/bin/env python3
"""Launch one Linux Manager server VM on an LXD remote to work with, or remove it: lm-dev-vm.py create|remove.
create launches the VM --vm (lm-dev by default) on the remote --remote (LXD_REMOTE) in the project
create launches the VM --vm (router by default) on the remote --remote (LXD_REMOTE) in the project
--project (LXD_PROJECT, lm-dev by default) with that project's default profile. In a test project
made by lm-dev-lxd-project.py, which .lm-dev-config/lxd-project-PROJECT.json describes, the VM gets the package
from that project's repository, as its apt source, so later dev builds reach it as updates;
elsewhere it gets --deb, or else the package built last, in out/ or out/dev/. The administrator is admin with a
generated password, kept as username and password in .lm-dev-config/vm-PROJECT-VM.json, and a TOTP
token, the key VM-admin of the project's Vault's TOTP engine, unless --no-otp is given;
lm-dev-otp-code.py prints its codes. The VM gets a configuration from tests/remote/configs/
(--config, core.json by default), whose @ETH0@ is the interface of its default route, @CIDR0@ its
network and @PSK@ a generated key. The VM gets an AppRole of its own in the project's Vault
elsewhere it gets --deb, or else the package built last, in out/ or out/dev/. The administrator is admin with the
password of .lm-dev-config/vm-PROJECT-VM.json, and a TOTP token, the key VM-admin of the project's Vault's TOTP
engine made from the file's otp_url, unless --no-otp is given; lm-dev-otp-code.py prints its codes. A password or
otp_url the file lacks, or all of them when there is no file, is generated and kept in the file, so a VM made again
has the same password and token until they are deleted from the file.
The VM gets a configuration from tests/remote/configs/ (--config, core.json by default), whose @ETH0@ is the
interface of its default route, @CIDR0@ its network and @PSK@ a generated key. The VM gets an AppRole of its own in the project's Vault
(lm_dev.enrol_instance), with which it reads the debconf preseed with the admin's password and the
configuration with its key, kept there as VM/preseed and VM/config, and creates its TOTP key; no
configuration with its key, kept there as VM/preseed and VM/config, and its TOTP key, generated or from otp_url; no
secret is an argument or on standard input, so create needs a project with a Vault
(lm-dev-lxd-project.py vault create). The admin's password is also kept there as VM/admin.
@@ -21,8 +22,8 @@ the same ports of the VM, and port 2222 to its SSH port. In a test project the l
network forward's on the project's WAN, --forward-address (LXD_FORWARD_ADDRESS) or else one allocated
from its uplink's routes; elsewhere NAT proxy
devices listen on the host address --listen (LXD_LISTEN, by default the IPv4 address of the host of
the remote's URL). remove deletes the VM, its forward, its .lm-dev-config/vm-PROJECT-VM.json and what
the Vault keeps for it. The defaults of the options come from the environment, else from
the remote's URL). remove deletes the VM, its forward and what the Vault keeps
for it, and keeps .lm-dev-config/vm-PROJECT-VM.json. The defaults of the options come from the environment, else from
.lm-dev-config/settings.json (lm_dev.setting).
"""
@@ -36,7 +37,7 @@ import subprocess
import sys
import time
from lm_dev import HANDOVER_DIR, PROJECT, ROOT, TESTS, VAULT_MOUNT, MissingSetting, VaultError, config_path, \
from lm_dev import HANDOVER_DIR, PROJECT, VM, ROOT, TESTS, VAULT_MOUNT, MissingSetting, VaultError, config_path, \
credentials_path, enrol_instance, enrol_otp, forget_instance, hand_over, host_address, lxc_exec, newest_deb, \
setting, store_secret, vault_state, write_private
@@ -50,7 +51,7 @@ def main():
parser.add_argument('--remote', help='the lxc remote (LXD_REMOTE)')
parser.add_argument('--project', default=setting('LXD_PROJECT', PROJECT),
help=f'the project of the VM (LXD_PROJECT, default {PROJECT})')
parser.add_argument('--vm', default='lm-dev', help='the name of the VM (default lm-dev)')
parser.add_argument('--vm', default=VM, help=f'the name of the VM (default {VM})')
parser.add_argument('--image', default=setting('LXD_IMAGE', 'ubuntu:26.04'),
help='the image of the VM (LXD_IMAGE, default ubuntu:26.04)')
parser.add_argument('--config', default='core.json',
@@ -111,8 +112,7 @@ def main():
forget_instance(vault, args.vm)
except VaultError as error:
print(f'the Vault keeps what it had for {args.vm}: {error}', file=sys.stderr)
credentials.unlink(missing_ok=True)
print(f'removed {where}')
print(f'removed {where}; {credentials} is kept for the next create')
return
if exists:
@@ -129,8 +129,11 @@ def main():
sys.exit(f'project {args.project} has no Vault, which the secrets reach the VM through; make it with '
'lm-dev-lxd-project.py vault create')
password, psk = secrets.token_hex(16), secrets.token_hex(24)
write_private(credentials, json.dumps({'username': 'admin', 'password': password}, indent=2) + '\n')
# The password and otp_url of the credentials file are reused; a missing one is generated.
known = json.loads(credentials.read_text(encoding='utf-8')) if credentials.is_file() else {}
password, psk = known.get('password') or secrets.token_hex(16), secrets.token_hex(24)
known.update(username='admin', password=password)
write_private(credentials, json.dumps(known, indent=2) + '\n')
reached = f'a forward on {project["networks"][0]}' if project else f'proxies on {args.listen}'
print(f'launching {where} from {args.image} with {source}; reached through {reached}')