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

@ -198,6 +198,7 @@ def build_vm():
default_interface_name=primary_interface,
)
user_data = build_user_data(
hostname=args.vm_name,
username=args.username,
password=password,
target_dir=cloud_init_tempdir_path,
@ -293,7 +294,9 @@ def get_ssh_keys(username: str) -> List[str]:
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.
"""
@ -316,7 +319,12 @@ def build_user_data(username: str, password: str, target_dir: Path) -> Path:
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"
with target_path.open("w+") as f: