640ca56
Index: cloud-init-0.7.6-bzr1060/cloudinit/distros/__init__.py
a510c9b
===================================================================
640ca56
--- cloud-init-0.7.6-bzr1060.orig/cloudinit/distros/__init__.py
640ca56
+++ cloud-init-0.7.6-bzr1060/cloudinit/distros/__init__.py
640ca56
@@ -333,11 +333,16 @@ class Distro(object):
a510c9b
         }
a510c9b
 
a510c9b
         redact_opts = ['passwd']
a510c9b
+        # Options that are comma separated lists which we need to parse
a510c9b
+        list_stripped_opts = ['groups']
a510c9b
 
a510c9b
         # Check the values and create the command
640ca56
         for key, val in kwargs.items():
a510c9b
 
a510c9b
             if key in adduser_opts and val and isinstance(val, str):
a510c9b
+                if key in list_stripped_opts:
a510c9b
+                    values = [x.strip() for x in val.split(',')]
a510c9b
+                    val = ','.join(values)
a510c9b
                 adduser_cmd.extend([adduser_opts[key], val])
a510c9b
 
a510c9b
                 # Redact certain fields from the logs
640ca56
@@ -629,6 +634,9 @@ def _normalize_groups(grp_cfg):
a510c9b
                             raise TypeError("Bad group member type %s" %
a510c9b
                                             type_utils.obj_name(v))
640ca56
             elif isinstance(i, six.string_types):
a510c9b
+                # Common to have leading whitespace in string lists,
a510c9b
+                # but not all useradd tools will support it.-
a510c9b
+                i = i.strip()
a510c9b
                 if i not in c_grp_cfg:
a510c9b
                     c_grp_cfg[i] = []
a510c9b
             else: