diff --git a/system_setup/common/wsl_conf.py b/system_setup/common/wsl_conf.py index 341c8aca..8724d945 100644 --- a/system_setup/common/wsl_conf.py +++ b/system_setup/common/wsl_conf.py @@ -111,12 +111,13 @@ def default_loader(is_advanced=False): return data -def wsl_config_update(config_class, root_dir): +def wsl_config_update(config_class, root_dir, default_user=None): """ - This update the configuration file for the given class.zzd + This update the configuration file for the given class. :param config_class: WSLConfigurationBase or WSLConfigurationAdvanced - :param is_dry_run: boolean, True if it is a dry run + :param root_dir: string, the root directory of the WSL + :param create_user: string, the user to create """ temp_conf_default = {} temp_confname = config_class.__str__() @@ -162,6 +163,11 @@ def wsl_config_update(config_class, root_dir): config.add_section(config_section) config[config_section][config_setting] = config_value + if config_type == "wsl" and default_user is not None: + if "user" not in config: + config.add_section("user") + config["user"]["default"] = default_user + # sort config in ascii order for section in config._sections: config._sections[section] = \ diff --git a/system_setup/server/controllers/configure.py b/system_setup/server/controllers/configure.py index 2d1951cc..096c4996 100644 --- a/system_setup/server/controllers/configure.py +++ b/system_setup/server/controllers/configure.py @@ -69,8 +69,10 @@ class ConfigureController(SubiquityController): dryrun = self.app.opts.dry_run variant = self.app.variant root_dir = self.model.root + username = None if variant == "wsl_setup": wsl_id = self.model.identity.user + username = wsl_id.username if dryrun: log.debug("mimicking creating user %s", wsl_id.username) @@ -105,7 +107,8 @@ class ConfigureController(SubiquityController): wsl_config_update(self.model.wslconfadvanced.wslconfadvanced, root_dir) - wsl_config_update(self.model.wslconfbase.wslconfbase, root_dir) + wsl_config_update(self.model.wslconfbase.wslconfbase, root_dir, + default_user=username) self.app.update_state(ApplicationState.DONE) except Exception: diff --git a/system_setup/tests/golden/answers/wsl.conf b/system_setup/tests/golden/answers/wsl.conf index a4a69cfe..442a8b52 100644 --- a/system_setup/tests/golden/answers/wsl.conf +++ b/system_setup/tests/golden/answers/wsl.conf @@ -6,3 +6,6 @@ root = /custom_mnt_path generatehosts = false generateresolvconf = false +[user] +default = ubuntu + diff --git a/system_setup/tests/golden/autoinstall-full/wsl.conf b/system_setup/tests/golden/autoinstall-full/wsl.conf index 449819ba..39ef73cf 100644 --- a/system_setup/tests/golden/autoinstall-full/wsl.conf +++ b/system_setup/tests/golden/autoinstall-full/wsl.conf @@ -12,3 +12,6 @@ enabled = false generatehosts = false generateresolvconf = false +[user] +default = ubuntu + diff --git a/system_setup/tests/golden/autoinstall/wsl.conf b/system_setup/tests/golden/autoinstall/wsl.conf index a4a69cfe..442a8b52 100644 --- a/system_setup/tests/golden/autoinstall/wsl.conf +++ b/system_setup/tests/golden/autoinstall/wsl.conf @@ -6,3 +6,6 @@ root = /custom_mnt_path generatehosts = false generateresolvconf = false +[user] +default = ubuntu +