added hostname setting

This commit is contained in:
Johannes Erwerle 2025-07-21 15:03:58 +02:00
parent 04b7cc9836
commit d25f7aeec3
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,6 @@
[project] [project]
name = "swagspace_cloud_init" name = "swagspace_cloud_init"
version = "0.3.0" version = "0.4.0"
description = "" description = ""
authors = [ authors = [
{name = "Johannes Erwerle",email = "jo@swagspace.org"} {name = "Johannes Erwerle",email = "jo@swagspace.org"}

View file

@ -198,6 +198,7 @@ def build_vm():
default_interface_name=primary_interface, default_interface_name=primary_interface,
) )
user_data = build_user_data( user_data = build_user_data(
hostname=args.vm_name,
username=args.username, username=args.username,
password=password, password=password,
target_dir=cloud_init_tempdir_path, target_dir=cloud_init_tempdir_path,
@ -293,7 +294,9 @@ def get_ssh_keys(username: str) -> List[str]:
return keys return keys
def build_user_data(username: str, password: str, target_dir: Path) -> Path: def build_user_data(
hostname: str, username: str, password: str, target_dir: Path
) -> Path:
""" """
Builds the user-data file in *target_dir* and returns a Path to it. Builds the user-data file in *target_dir* and returns a Path to it.
""" """
@ -316,7 +319,12 @@ def build_user_data(username: str, password: str, target_dir: Path) -> Path:
keyboard = {"layout": "de", "model": "pc105"} keyboard = {"layout": "de", "model": "pc105"}
user_data = {"users": users, "power_state": power_state, "keyboard": keyboard} user_data = {
"users": users,
"power_state": power_state,
"keyboard": keyboard,
"hostname": hostname,
}
target_path = target_dir / "user-data" target_path = target_dir / "user-data"
with target_path.open("w+") as f: with target_path.open("w+") as f: