Description of problem:
When creating a new user, I cannot specify multiple groups:
- name: foobar
gecos: User N. Ame
groups: wheel, adm
Version-Release number of selected component (if applicable):
Fedora-Atomic based on rawhide
cloud-init - 9.7.5
Steps to Reproduce:
1. use above user-data snippet
2. boot VM
3. cat /etc/group and see nothing added for user foobar
No groups for user foobar, other than default group
user foobar in default group, wheel, and adm
This works for a single group specified as:
This also fails for
group: wheel adm
group: [wheel adm]
group: [wheel, adm]
Not having this makes it hard to add sudoers
*no space* work?
It does for me, although I'm not using atomic. *Not* having a space does fail, though, on F20. (I think this is a general cloud-init bug. What's happening is that it's passing the data to useradd as a string, so with a space useradd gets
--groups "wheel, adm"
and then complains that there is no " adm" group.
So, cloud-init should probably strip those spaces.
*no space* works.
Upstream shows it with a space:
I support having cloud-init strip those spaces.
I suspect that it works on Ubuntu/Debian because of differences in the user creation command-line tool called. This is possibly actually a useradd bug -- since groupadd won't create groups with spaces, it's kind of silly for useradd to try and add people to them.
I filed bug #1126411 as an RFE for useradd, but I think this should still be fixed in cloud-init. (I notice that the useradd man page documents that spaces aren't allowed.)
Testing this patch now:
$ bzr diff
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py 2014-02-12 19:56:55 +0000
+++ cloudinit/distros/__init__.py 2014-08-04 18:58:51 +0000
@@ -612,6 +612,9 @@
raise TypeError("Bad group member type %s" %
elif isinstance(i, (str, basestring)):
+ # 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] = 
An updated RPM should show up in http://copr.fedoraproject.org/coprs/walters/atomic-next/build/24544/
Upstream bug with tested patch:
This should be fixed in cloud-init-0.7.6-3.fc22. cloud-init-0.7.6-4.20140218bzr1060.fc22 will be pushed shortly with some major changes, so it may be worth testing against that instead.
Update: cloud-init-0.7.6-4.20140218bzr1060.fc22 isn't going to make it into F22 due to bug 1194577. If you're testing rawhide it will appear there, but otherwise feel free to go ahead and test cloud-init-0.7.6-3.fc22. Sorry about the confusion.
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.
More information and reason for this action is here: