-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add ability to enable mongo auth and add users #162
Conversation
3cd7339
to
7477ed9
Compare
dcd362e
to
a907ee0
Compare
0eb943f
to
b5ec084
Compare
obsolete comment |
b5ec084
to
064a4ee
Compare
obsolete comment |
I added a todo list based on #75 |
obsolete comment |
1 similar comment
obsolete comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall direction and at a high-level looks good 👍
Left some comments where we need to think about the corner cases.
Also let's not rush with the random passwords for st2mongo user. Not sure yet where we should generate it: is it user's responsibility and we show how in Let's clarify this PR and hopefully we can add more password generation functionality as another PR. |
_obsolete comment_
|
064a4ee
to
b4ff559
Compare
obsolete comment |
ba77aac
to
3a15717
Compare
obsolete comment |
3a15717
to
a3d5f3d
Compare
obsolete comment |
1 similar comment
obsolete comment |
44e700c
to
1a42bf0
Compare
obsolete comment |
798c6b6
to
7705014
Compare
DONE! No longer WIP. Travis is now testing two suites: one without auth enabled, and one with auth enabled. I think this is ready for another review, and hopefully, a merge @armab. |
3a644fa
to
758a09e
Compare
Rebased and squashed various commits to make it easier to review each piece/commit of this PR. |
obsolete comment |
449810c
to
e817bb0
Compare
Dropped changes to |
686e714
to
8b56c9a
Compare
Adds auth to mongo when the mongodb_auth_enable flag is true. Any additional users should be passed in via mongodb_users. There are several other default variables as well (like mongodb_host, mongodb_port) that can be overridden in the play or inventory that uses this role. This does not attempt to generate any passwords. It only adds users if explicitly requested, but allows external tasks/roles to import the mongodb_auth.yml tasks to add users as required after mongo is installed. This uses lineinfile to edit mongod.conf with regexs to catch as many edge cases in yaml formatting (spaces, quotes) as possible. Also, this uses a bit of python to validate that the yaml file was modified in such a way that it is still valid yaml, and the entries intrduced in the file are present as expected. This uses the mongo shell to see if authorization is required before adding the admin user. This should handle cases such as the localhost exception in a new install or upgrades where auth is not enabled or upgrades where auth is enabled. This installs pip using system packages if `pip` is not present. `pip` is needed to install pymongo which is used to manage mongo users through the mongodb_user ansible module. As explained in comments, we only update mongo user passwords on_create because that is the only way to maintain idempotency. This should be idempotent. Part of StackStorm#75.
8b56c9a
to
3b9ed18
Compare
When you review, I recommend this order (which puts files with the simplest changes first):
|
I will try to break this down into ity-bity PRs. Starting with Next steps:
|
Adds auth to mongo when the
mongodb_auth_enable
flag is true.Any additional users should be passed in via
mongodb_users
.There are several other default variables as well (like
mongodb_host
,mongodb_port
which are used when logging in) that can be overriddenin the play or inventory that uses this role.
That is this PR completes this TODO from #75 for mongo security:
This does not attempt to generate any passwords. It only adds users if
explicitly requested, but allows external tasks/roles to import the
mongodb_auth.yml tasks to add users as required after mongo is installed.
That is, this PR skips this TODO from #75:
This uses lineinfile to edit mongod.conf with regexs to catch as many
edge cases in yaml formatting (spaces, quotes) as possible.
Also, this uses a bit of python to validate that the yaml file was
modified in such a way that it is still valid yaml, and the entries
intrduced in the file are present as expected.
This uses the mongo shell to see if authorization is required before
adding the admin user. This should handle cases such as the localhost
exception in a new install or upgrades where auth is not enabled or
upgrades where auth is enabled.
This installs pip using system packages if
pip
is not present.pip
is needed to install pymongo which is used to manage mongo users through
the mongodb_user ansible module.
As explained in comments, we only update mongo user passwords on_create
because that is the only way to maintain idempotency.
This should be idempotent.
TODO:
To configure host (in a separate PR) we need to modify
net.bindIp
inmongod.conf
(see https://docs.mongodb.com/manual/reference/configuration-options/#net-options). I believe mongo only listens on 127.0.0.1 by default, but we might add some checks to be more explicit.That is, this PR skips these TODOs from #75: