← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~smoser/cloud-init/trunk.1562918 into lp:cloud-init

 

Scott Moser has proposed merging lp:~smoser/cloud-init/trunk.1562918 into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1562918 in cloud-init (Ubuntu): "cloud-init does not create defined users"
  https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1562918

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/trunk.1562918/+merge/290542
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.1562918 into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2016-03-22 07:53:33 +0000
+++ cloudinit/distros/__init__.py	2016-03-31 00:22:03 +0000
@@ -362,15 +362,18 @@
 
         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)


Follow ups