Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable creation of root user #46

Closed
apiening opened this issue May 28, 2020 · 11 comments
Closed

Disable creation of root user #46

apiening opened this issue May 28, 2020 · 11 comments

Comments

@apiening
Copy link

I have the root user in my users: variable and weareinteractive.users fails for obvious reasons:

weareinteractive.users : Adding user 'root' to the system
usermod: user root is currently used by process 1

Is there an option to disable the creation of a specific user?

@apiening apiening changed the title Disable creation for root user Disable creation of root user May 28, 2020
@franklinkim
Copy link
Member

Hi, I added a check so that the root user is being ignored.

@j8r
Copy link
Contributor

j8r commented Aug 13, 2020

That's not a great fix, because it also ignore configuring the root home directory.
I would say having a new options, like a user_create boolean in a when for the task https://github.com/weareinteractive/ansible-users/blob/master/tasks/manage_user.yml#L3

Also, if you don't want to manage the root user at all: do not list it in the first place in users?

@apiening
Copy link
Author

Hi @j8r,

I agree that this is not an optimal solution.

Not listing the root user in the users list is not an option, when this list does also feed other playbooks.

I submitted a PR that enables to choose whether the user and / or home should be created on a per user basis: #47

In the discussion of the PR I also provided a use case where another role references the users variable to setup additional things.

@j8r
Copy link
Contributor

j8r commented Aug 13, 2020

Agree @apiening , your PR is exactly what I would done.
@franklinkim can you reconsider it? This can also happen to other users, like admin on Debian/Ubuntu.

That's indeed a not uncommon practice to modify the root dotfiles, like the .bashrc, aliases etc, for example to have a`red warning prompt in production, or providing useful aliases/commands.

@zen
Copy link

zen commented Oct 28, 2020

I agree with above, I'm also managing some of the root dotfiles for the same reason.
Since other user roles are not maintained, you are our only hope @franklinkim :)

@franklinkim
Copy link
Member

Since this seems to be a wanted feature, let's take another look.

@franklinkim franklinkim reopened this Nov 5, 2020
@franklinkim
Copy link
Member

Would 038d8c0 work for you all?

You would need to define some variables for the root user though in order to work:

- hosts: all
  become: yes
  roles:
    - weareinteractive.users
  vars:
    users:
      - username: root
        # don't create the user
        user_create: no
        # define root's home directory
        home: /root
        # override group in case you used users_group
        group: root

@j8r
Copy link
Contributor

j8r commented Nov 5, 2020

@franklinkim Yes, but to make it works it also means to revert 55d3c48
I suggest to reopen #47.

There are other options, but this one is the simplest and most flexible implementation (e.g. one may want to change the root's password or SSH keys.)

@franklinkim
Copy link
Member

@j8r picked the wrong commit hash. Take a look at the diff.

@apiening
Copy link
Author

apiening commented Nov 6, 2020

@franklinkim Thank you very much for reconsidering this.
This diff looks pretty much like my PR #47 so it looks good to me.

@j8r
Copy link
Contributor

j8r commented Nov 6, 2020

Ok for me too, thanks @franklinkim, that's a great little change 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants