summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_users_groups.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-09-24 18:30:35 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-09-24 18:30:35 -0700
commit0be941f74f54ecafcb628451f531b90f30723fbc (patch)
tree0ba181c7a95143db4dc807f1edb1f025f9dda165 /cloudinit/config/cc_users_groups.py
parent1278285241d017affa2d03f8023afaf2d35a9543 (diff)
downloadvyos-cloud-init-0be941f74f54ecafcb628451f531b90f30723fbc.tar.gz
vyos-cloud-init-0be941f74f54ecafcb628451f531b90f30723fbc.zip
Refactor the ug normalization to take in a distro
and produce a user and group list. Clean this up to be simpler as well as handle the old 'user' case when it exists in configuration.
Diffstat (limited to 'cloudinit/config/cc_users_groups.py')
-rw-r--r--cloudinit/config/cc_users_groups.py29
1 files changed, 1 insertions, 28 deletions
diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py
index 13eb1102..464f55c3 100644
--- a/cloudinit/config/cc_users_groups.py
+++ b/cloudinit/config/cc_users_groups.py
@@ -25,35 +25,8 @@ frequency = PER_INSTANCE
def handle(name, cfg, cloud, log, _args):
- def_u = None
- def_u_gs = None
- try:
- def_u = cloud.distro.get_default_user()
- def_u_gs = cloud.distro.get_default_user_groups()
- except NotImplementedError:
- log.warn(("Distro has not implemented default user "
- "creation. No default user will be added."))
-
- ((users, default_user), groups) = distros.normalize_users_groups(cfg,
- def_u,
- def_u_gs)
+ (users, groups) = distros.normalize_users_groups(cfg, cloud.distro)
for (name, members) in groups.items():
cloud.distro.create_group(name, members)
-
- if default_user:
- user = default_user['name']
- config = default_user['config']
- def_base_config = {
- 'plain_text_passwd': user,
- 'home': "/home/%s" % user,
- 'shell': "/bin/bash",
- 'lock_passwd': True,
- 'gecos': "%s%s" % (user.title()),
- 'sudo': "ALL=(ALL) NOPASSWD:ALL",
- }
- u_config = util.mergemanydict([def_base_config, config])
- cloud.distro.create_user(user, **u_config)
- log.info("Added default '%s' user with passwordless sudo", user)
-
for (user, config) in users.items():
cloud.distro.create_user(user, **config)