Kickstart create users and add to groups

https://serverfault.com/questions/995957/kickstart-create-users-and-add-to-groups

Asked 6 years ago Modified 4 years ago Viewed 6k times 3

I’m doing a CentOS 8 automated install. I’ve previously had no problem creating a single user and adding it to a group like so:

user –name=othername –password=big_long_hash –iscrypted –groups=myname –homedir=/var/ftp –shell=/sbin/nologin Despite documentation saying the group has to exist already, I’ve never had any issues.

Now I want to add multiple users to this group, so I add another line to my file

user –name=myname –groups=myname –homedir=/var/ftp –shell=/sbin/nologin user –name=othername –password=big_long_hash –iscrypted –groups=myname –homedir=/var/ftp –shell=/sbin/nologin And I get an error:

anaconda[1842]: program: Running… useradd -R /mnt/sysimage -U -G myname -d /var/ftp -m -s /sbin/nologin myname useradd[25852]: failed adding user ‘myname’, exit code: 9 anaconda[1842]: program: useradd: group myname exists - if you want to add this user to that group, use -g. anaconda[1842]: program: Return code: 9 anaconda[1842]: anaconda: kickstart.kickstart.user: User myname already exists So I tried adding the line to create the group:

group –name=myname user –name=myname –groups=myname –homedir=/var/ftp –shell=/sbin/nologin user –name=othername –password=big_long_hash –iscrypted –groups=myname –homedir=/var/ftp –shell=/sbin/nologin But no change. Tried not specifying the group:

group –name=myname user –name=myname –homedir=/var/ftp –shell=/sbin/nologin user –name=othername –password=big_long_hash –iscrypted –groups=myname –homedir=/var/ftp –shell=/sbin/nologin This time the useradd command doesn’t have the group in it, but still fails with the same error. I think I’m just going to work around it by calling usermod from the post-install script, but wanted to check if there’s something I’m not understanding about adding groups and users in the Kickstart file.

centoskickstartanaconda Share Improve this question Follow edited Dec 18, 2019 at 1:11 asked Dec 18, 2019 at 0:19 miken32’s user avatar miken32 1,05111 gold badge1414 silver badges3737 bronze badges What happens if you remove –groups=myname for the user myname. Useradd automatically creates the user-specific group. – Mark Wagner CommentedDec 18, 2019 at 0:51 Yeah, was just coming back to add that to my answer. No change. – miken32 CommentedDec 18, 2019 at 1:10 Does –groups need to be –groups=othername,myname, so it sets the primary group as othername and treats the others as supplementary groups? – shearn89 CommentedDec 24, 2021 at 9:01 Add a comment 1 Answer Sorted by:

Highest score (default) 1

I’ve never bothered with Kickstart’s functionality for adding users or groups. I just do it myself in %post.

%post –erroronfail groupadd groupname useradd -m user1 useradd -m user2 usermod -a -G groupname user1 usermod -a -G groupname user2 Share Improve this answer Follow answered Jan 4, 2021 at 17:48 Michael Hampton’s user avatar Michael Hampton 254k4949 gold badges528528 silver badges1k1k bronze badges Yup; as mentioned, that’s what I’m doing as a workaround. – miken32 CommentedJan 4, 2021 at 19:03 @miken32 And to be clear, I wouldn’t bother trying to use it either. – Michael Hampton CommentedJan 4, 2021 at 19:06

Updated: