Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Create user if it doesn't exist #36

Closed
gingerwizard opened this issue Dec 15, 2015 · 11 comments
Closed

Create user if it doesn't exist #36

gingerwizard opened this issue Dec 15, 2015 · 11 comments
Milestone

Comments

@gingerwizard
Copy link

Currently the default user "elasticsearch" is used - this is installed by the package manager.
If installed through a manual URL this might not be the case. User may also wish to use another user.
Proposal is to create the user if it doesn't exist.

@electrical
Copy link
Contributor

any rpm/deb package no matter how you install it ( rpm / dpkg / yum / apt ) it will always create the user.
Lets leave it up to the user to create the right user/group stuff.

@jerrac
Copy link
Contributor

jerrac commented Jan 20, 2016

When I wrote my own ansible role to install elasticsearch, I eventually had to add configuration to set the elasticsearch users uid and gid. The reason being that mismatched uid/gid's on different nodes resulted in some nodes being unable to read/write snapshots. Since the repo directory was on an nfs mount with an owner/group of the elasticsearch user on the node I initiated the repo from. At I think that's the initial problem I ran into, it's been a while.

I do know forcing all nodes to have the same username and uid/gid's fixed that issue.

So I'd love to be able to force the uid/gid's to be the same.

Of course, I haven't checked to see if the owner/group issue still occurs with elasticsearch 2.x. I suppose I'm posting this a bit early... :\

@gingerwizard
Copy link
Author

I'd like to get @electrical view on this. Easily added but its whether this is the appropriate place or whether it should be supported elsewhere.

@jakommo
Copy link
Contributor

jakommo commented Jan 21, 2016

I think that's only a problem when using NFS. S3 shouldn't have a problem with different ID's.

@jerrac
Copy link
Contributor

jerrac commented Jan 21, 2016

Yes, S3 would not have issues with id's. But we're not using it for this.

@gingerwizard
Copy link
Author

I can manually reproduce @jerrac issue. Its hard for us to automate and test for this in the kitchen tests as we currently don't form clusters across docker images.

The alternative is to ask users to create users using a separate ansible role and simply specify the es_user and es_group. These will be used for the service.

@jerrac
Copy link
Contributor

jerrac commented Jan 22, 2016

If I remember correctly, the package manager should use the existing user if one exists, right? So if I create a "elasticsearch" user before installing elasticsearch, the package manager would use the user I created.

So, could we add a couple optional tasks to the role? If es_custom_user_id is True, then create a user and a group named "elasticsearch" with the user and group ids in the es_custom_user_uid and es_custom_user_gid variables. After that, run the installation tasks.

Does that make sense?

@jerrac
Copy link
Contributor

jerrac commented Jan 22, 2016

So, what I described does seem to work just fine. See https://github.com/LaneCommunityCollege/ansible-elasticsearch/commit/de82918584edd5159643b43c1dff07cc4e5d63ca

Is that enough for a pull request? Or is there something else I need to do?

@gingerwizard
Copy link
Author

Hi
If we specify the creation of user_id it seems we should just support creation of a user as well. If the user specifies a user "elasticsearch" and provides an id, it would simply overwrite the id.
@electrical Would you be prepared to reconsider user management given the issues it proposes if ids are not identical per node.

@electrical
Copy link
Contributor

Can support it yeah. es_user, es_uid, es_gid would make sense i think.

@gingerwizard
Copy link
Author

@jerrac will you make a pull request here? If not, i'll work on this and try to get it to the next release.

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

No branches or pull requests

4 participants