summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 12983c0a..5879dabf 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -362,15 +362,22 @@ 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(","):
+ primary_group = kwargs.get('primary_group')
+ if primary_group:
+ groups.append(primary_group)
+
+ 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)