diff options
author | Ben Howard <ben.howard@canonical.com> | 2012-08-31 12:45:40 -0600 |
---|---|---|
committer | Ben Howard <ben.howard@canonical.com> | 2012-08-31 12:45:40 -0600 |
commit | b696c2a57821e0e1fe18400016c906b92f8c271e (patch) | |
tree | 91d6d25beded00359f318a25f9d4808cc92ed361 /cloudinit/config/cc_users_groups.py | |
parent | 09cec0837a20f6cfafa520aa0ff2e484e1fd9c01 (diff) | |
download | vyos-cloud-init-b696c2a57821e0e1fe18400016c906b92f8c271e.tar.gz vyos-cloud-init-b696c2a57821e0e1fe18400016c906b92f8c271e.zip |
- Converted user list to user dict to allow exclusion of the default user
on Ubuntu systems via cloud-config (LP: #1041384).
- Fixed bug with user creation on Ubuntu where the default user groups are
not set properly (LP: #1044044).
- Fixed documentation for user creation (LP: #1044508).
Diffstat (limited to 'cloudinit/config/cc_users_groups.py')
-rw-r--r-- | cloudinit/config/cc_users_groups.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py index 1e241623..418f3330 100644 --- a/cloudinit/config/cc_users_groups.py +++ b/cloudinit/config/cc_users_groups.py @@ -38,19 +38,17 @@ def handle(name, cfg, cloud, log, _args): if 'users' in cfg: user_zero = None - for name, user_config in cfg['users'].iteritems(): - if not user_zero: - user_zero = name + for user_config in cfg['users']: # Handle the default user creation - if name == "default" and user_config: + if 'default' in user_config: log.info("Creating default user") # Create the default user if so defined try: cloud.distro.add_default_user() - if user_zero == name: + if not user_zero: user_zero = cloud.distro.get_default_user() except NotImplementedError: @@ -60,11 +58,21 @@ def handle(name, cfg, cloud, log, _args): log.warn("Distro has not implemented default user " "creation. No default user will be created") - else: + + elif isinstance(user_config, dict) and 'name' in user_config: + + name = user_config['name'] + if not user_zero: + user_zero = name + # Make options friendly for distro.create_user new_opts = {} if isinstance(user_config, dict): for opt in user_config: - new_opts[opt.replace('-', '')] = user_config[opt] + new_opts[opt.replace('-', '_')] = user_config[opt] + + cloud.distro.create_user(**new_opts) - cloud.distro.create_user(name, **new_opts) + else: + # create user with no configuration + cloud.distro.create_user(user_config) |