-
Notifications
You must be signed in to change notification settings - Fork 3
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
can't create the admin user on a fresh install #326
Comments
The recipe has tests in the kitchen.yml that run on fresh servers and the tests pass fine. And it does work for me as well. Could you give more information about the setup you have? Are you using sharding or replication? What platform / version are you trying to install it on? |
i have a cloudformation, cloud init that is spinning up a single instance mongo replicaset. i have overriden the admin user and password. when it tries to apply user_management (line 17) it appears that the replicaset is not all the way up yet and as such it fails the chef run.
Error executing action Mongo::ConnectionFailure Cookbook Trace: |
Just an update for you guys, I'm slightly struggling on coming up with a solution that works well with this so I'm going to have to ask for help. I've gotten it to a point where the mongod servers come up successfully, but no user is created. Re-provisioning the nodes does successfully create the user though. The problem, I believe, is that ==> d2: [2014-09-12T20:29:57+00:00] INFO: Configuring replicaset with members d0, d1, d2
==> d2: [2014-09-12T20:29:57+00:00] INFO: ruby_block[config_replicaset] called
==> d2: [2014-09-12T20:29:57+00:00] INFO: ruby_block[config_replicaset] sending create action to ruby_block[create_replicaset_users] (delayed)
==> d2: [2014-09-12T20:29:57+00:00] INFO: ruby_block[create_replicaset_users] called
==> d2: [2014-09-12T20:29:57+00:00] INFO: [ruby_block[create_replicaset_users]] sending add action to mongodb_user[admin] (delayed)
==> d2: [2014-09-12T20:29:57+00:00] WARN: Default username / password detected for admin user
==> d2: [2014-09-12T20:29:57+00:00] WARN: These should be overridden to different, unique values
==> d2: [2014-09-12T20:29:57+00:00] WARN: Unable to authenticate as admin user. If this is a fresh install, ignore warning: Failed to authenticate user 'admin' on db 'admin'.
==> d2: [2014-09-12T20:29:57+00:00] WARN: Unable to add user, if this is a secondary replica, ignore: not master I don't know the mongo ruby driver that well, if it has a method that will return the primary of a replicaset maybe we can have the recipe hold on until it returns a value? If that wasn't enough, I don't have any leads on why the mongos server will not run with the user_management recipe. mongos just fails to start, and doesn't write out any logs. If I manually try to do The error that appears in the Chef run is simply that it can't connect to itself (probably because mongos failed to start... why, I'm not sure): ==> s0: [2014-09-12T20:32:09+00:00] INFO: service[mongos] sending create action to ruby_block[config_sharding] (immediate)
==> s0: [2014-09-12T20:32:09+00:00] INFO: {"rs_default"=>["d0:27017", "d1:27017", "d2:27017"]}
==> s0: [2014-09-12T20:32:09+00:00] INFO: ["rs_default/d0:27017,d1:27017,d2:27017"]
==> s0: [2014-09-12T20:32:09+00:00] WARN: Could not connect to database: 'localhost:27017', reason Failed to connect to a master node at localhost:27017 |
Sorry for the lack of updates guys. I figured out the reason mongos wouldn't start was because Not my favorite way to handle things, but it looks like the recipe already was doing that for replicaset and shards. The main problem is the service restarting when it's trying to connect to the database to add users. I can't seem to reliably notify in chef after certain steps and ensure the service is currently running. Anyways, this branch has worked for me with configuring a 3 config server, 3 mongod shard/replicaset, and 1 mongos VM with user management. You can see that working in my Vagrant example. |
@ceejh I believe the issue is that the mongodb service notification that runs |
Also, I don't understand |
Any update on getting the fix merged in? I'm running across this issue now, and the only thing I've been able to do is modify the role after the initial run. |
I've been having this problem too, I solved it by having a custom recipe get called before recipe[mongodb::user_management] is run in my chef role:
This gives it a maximum of two minutes to wait for Mongo to respond before it tries to create the admin user. Seems to work fine for me :) |
I have gone a similar route to @codezomb to workaround this issue, but ultimately, I hope that this bug gets fixed. 👍 |
The replicaSet not being ready until the end should be fixed by now by PR #352. However, the server may not be ready yet when chef sends commands (create user, but also configure replicaSet): IMO the real issue is that the service start should not return until the server is ready to accept requests. I don't know if it's standard for services to do that, but it would simplify a lot automation, like chef. |
When using user_management to create the admin user on a fresh install, it fails to add the admin user because the mongodb server is not started yet.
If you run the recipe again against the same server, it will pass on the second time.
I think it can be quickly solved by using retries / delay in order to let the mongodb server starts properly.
The text was updated successfully, but these errors were encountered: