diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-08-22 23:48:23 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-08-22 23:48:23 -0400 |
commit | 55f6e4cb09d568d1a0679c41570b5c6d570a16f0 (patch) | |
tree | 9c10edc2a67205b72d5b1fdf4c77b0f4fd8508eb /cloudinit/config/cc_ssh.py | |
parent | 56979d20b9c56c45bfbcaf93bc5f93fa505ece50 (diff) | |
parent | bbbaeca0c375dc166ef8ffe0598d5f384b722c00 (diff) | |
download | vyos-cloud-init-55f6e4cb09d568d1a0679c41570b5c6d570a16f0.tar.gz vyos-cloud-init-55f6e4cb09d568d1a0679c41570b5c6d570a16f0.zip |
add support for creating initial users and groups
Added "userless" mode to cloud-init for handling the creation of the users
and the default user on Ubuntu. The end goal of this is to remove the need
for the 'ubuntu' user in the cloud images and to allow individuals to
choose the default user name.
LP: #1028503
Diffstat (limited to 'cloudinit/config/cc_ssh.py')
-rw-r--r-- | cloudinit/config/cc_ssh.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cloudinit/config/cc_ssh.py b/cloudinit/config/cc_ssh.py index 3431bd2a..439c8eb8 100644 --- a/cloudinit/config/cc_ssh.py +++ b/cloudinit/config/cc_ssh.py @@ -102,7 +102,16 @@ def handle(_name, cfg, cloud, log, _args): " %s to file %s"), keytype, keyfile) try: - user = util.get_cfg_option_str(cfg, 'user') + # TODO(utlemming): consolidate this stanza that occurs in: + # cc_ssh_import_id, cc_set_passwords, maybe cc_users_groups.py + user = cloud.distro.get_default_user() + + if 'users' in cfg: + user_zero = cfg['users'].keys()[0] + + if user_zero != "default": + user = user_zero + disable_root = util.get_cfg_option_bool(cfg, "disable_root", True) disable_root_opts = util.get_cfg_option_str(cfg, "disable_root_opts", DISABLE_ROOT_OPTS) @@ -124,7 +133,9 @@ def apply_credentials(keys, user, paths, disable_root, disable_root_opts): if user: ssh_util.setup_user_keys(keys, user, '', paths) - if disable_root and user: + if disable_root: + if not user: + user = "NONE" key_prefix = disable_root_opts.replace('$USER', user) else: key_prefix = '' |