Add support for customized mirror and apt-cacher

This commit is contained in:
2023-08-30 14:25:50 +00:00
parent 6cfc75e321
commit 3f0b0b2d7b
6 changed files with 37 additions and 3 deletions

View File

@ -58,6 +58,12 @@ pvc:
# Per-host TFTP path (almost always "/host" under "root_path"; must be writable)
host_path: "/srv/tftp/pvc-installer/host"
# Debian repository configuration
repo:
# Mirror path; defaults to using the apt-cacher-ng instance located on the current machine
# Replace "10.199.199.254" if you change "dhcp" -> "address" above
mirror: http://10.199.199.254:3142/ftp.debian.org/debian
# PVC Ansible repository configuration
# Note: If "path" does not exist, "remote" will be cloned to it via Git using SSH private key "keyfile".
# Note: The VCS will be refreshed regularly via the API in response to webhooks.

View File

@ -21,6 +21,8 @@ pvc:
tftp:
root_path: "ROOT_DIRECTORY/tftp"
host_path: "ROOT_DIRECTORY/tftp/host"
repo:
mirror: http://BOOTSTRAP_ADDRESS:3142/UPSTREAM_MIRROR
ansible:
path: "ROOT_DIRECTORY/repo"
keyfile: "ROOT_DIRECTORY/id_ed25519"

View File

@ -121,6 +121,7 @@ def read_config():
o_queue = o_base["queue"]
o_dhcp = o_base["dhcp"]
o_tftp = o_base["tftp"]
o_repo = o_base["repo"]
o_ansible = o_base["ansible"]
o_notifications = o_base["notifications"]
except KeyError as k:
@ -178,6 +179,15 @@ def read_config():
f"Missing second-level key '{key}' under 'tftp'"
)
# Get the Repo configuration
for key in ["mirror"]:
try:
config[f"repo_{key}"] = o_repo[key]
except Exception:
raise MalformedConfigurationError(
f"Missing second-level key '{key}' under 'repo'"
)
# Get the Ansible configuration
for key in ["path", "key_file", "remote", "branch", "clusters_file", "lock_file"]:
try:

View File

@ -67,7 +67,7 @@ def add_preseed(config, cspec_node, host_macaddr, system_drive_target):
# We use the dhcp_address here to allow the listen_address to be 0.0.0.0
rendered = template.render(
debrelease=cspec_node.get("config", {}).get("release"),
debmirror=cspec_node.get("config", {}).get("mirror"),
debmirror=config.get("repo_mirror"),
addpkglist=add_packages,
filesystem=cspec_node.get("config", {}).get("filesystem"),
skip_blockcheck=False,

View File

@ -28,7 +28,7 @@ import pvcbootstrapd.lib.notifications as notifications
def build_tftp_repository(config):
# Generate an installer config
build_cmd = [ f"{config['ansible_path']}/pvc-installer/buildpxe.sh", "-o", config['tftp_root_path'], "-u", config['deploy_username'] ]
build_cmd = [ f"{config['ansible_path']}/pvc-installer/buildpxe.sh", "-o", config['tftp_root_path'], "-u", config['deploy_username'], "-m", config["repo_mirror"] ]
print(f"Building TFTP contents via pvc-installer command: {' '.join(build_cmd)}")
notifications.send_webhook(config, "begin", f"Building TFTP contents via pvc-installer command: {' '.join(build_cmd)}")
retcode = run(build_cmd)