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