RexOps / RexOps/Rex

create_user and groups option

Open
#581 6 comments 0 reactions 1 assignee View on GitHub

@ferki is already working on this.

Since Oct 6, 2015.

ready
Dominant language
Perl
Stars
737
Forks
214
PR merge metrics
No merged PRs in 30d

Description

If a user account does not exist yet on the (Linux) remote, and create_user command is being run with a groups option, then the first group will be treated as primary group for the user, therefore it will get passed as --gid primary_group to useradd, stg like this:

useradd --gid primary_group --groups group2,group3 username

In this case useradd fails with a useradd: group 'primary_group' does not exist error. I think we should detect this case, create the user without any group settings, and apply the group membership settings once the account has been created, just before returning.

This way useradd can do its job (optionally creating the user's default primary group based on the remote system's default settings), and then ensure the requested group memberships.

For bonus points, there could be a force_groups => TRUE option or similar, which forcibly creates all the missing groups, before useradd is called.

As far as I can tell, the above does not affect the case when the account is already there (e.g. create_user acts in usermod mode).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.