2

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.

miken32
  • 942
  • 1
  • 13
  • 35
  • What happens if you remove `--groups=myname` for the user `myname`. Useradd automatically creates the user-specific group. – Mark Wagner Dec 18 '19 at 00:51
  • Yeah, was just coming back to add that to my answer. No change. – miken32 Dec 18 '19 at 01: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 Dec 24 '21 at 09:01

1 Answers1

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
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972