diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-30 20:16:46 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-30 20:16:46 -0400 |
commit | 638191cd07ba1afe5ea61ff5268351ab77541139 (patch) | |
tree | bc79192024e5a0f2403bd7e1382ad94b57a464be /cloudinit/distros | |
parent | 210b041b2fead7a57af91f60a6f89d9e5aa1ed4a (diff) | |
download | vyos-cloud-init-638191cd07ba1afe5ea61ff5268351ab77541139.tar.gz vyos-cloud-init-638191cd07ba1afe5ea61ff5268351ab77541139.zip |
fix adding of users without a group
revision 1179 regressed adding a user that did not have a 'groups'
entry present. This should handle that correctly, making 'add_user'
able to take:
a.) groups="group1,group2"
b.) groups=["group1", "group2"]
c.) groups=None
d.) no groups parameter
LP: #1562918
Diffstat (limited to 'cloudinit/distros')
-rw-r--r-- | cloudinit/distros/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 418421b9..5563ae43 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -362,15 +362,18 @@ class Distro(object): redact_opts = ['passwd'] + # support kwargs having groups=[list] or groups="g1,g2" groups = kwargs.get('groups') if groups: if isinstance(groups, (list, tuple)): + # kwargs.items loop below wants a comma delimeted string + # that can go right through to the command. kwargs['groups'] = ",".join(groups) else: groups = groups.split(",") - if create_groups: - for group in kwargs.get('groups').split(","): + if create_groups and groups: + for group in groups: if not util.is_group(group): self.create_group(group) LOG.debug("created group %s for user %s", name, group) |