You're right, it should still work as your describe. You are likely
right that it cannot connect to the database when trying user.present.
Have you checked the minion logs? If it cannot connect to the database,
it should log this:
log.error('Error connecting to database {0}'.format(database))
The mongodb_user.present first checks to see if the user is already in
the database before it tries to add it. Following the mongodb.py module
code, and by the Traceback you are seeing in your state run output, the
user_exists() function is returning a string on error:
>>> user = 'Failed to connect to mongo database'
>>> name = 'root'
>>> if name == dict(user).get('user'):
... print name
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 1; 2 is
required
As a workaround, maybe you can add a cmd.run to sleep for a few seconds
in between the service restart and adding the first user?
Regardless, tracebacks are bad and a bug should be filed to fix this -
please file one on github.
--
Dave
On 11/4/13 10:42 AM, Evan Johnson wrote:
> Thanks for the response, Dave.
>
> You are saying that the "user" and "password" args (not to be confused
> with "name" and "passwd", which are for the /new /user) need to be
> supplied using a user that is "already created and has sufficient
> privileges". That makes sense - except how does that work when running
> this immediately after installed MongoDb for the first time, before
> any users or privileges have been set up?
>
> I am attempting to create the first user here - the 'root' user. No
> users have been created. What "user" and "password" would I supply at
> this stage?
>
> I get the same error result if I specify a blank "user"/"password", or
> a made up "user" and a blank "password", or made up "user" AND
> "password". What else should I try?
>
> It /does/ complete on the 2nd run, still without specifying a "user"
> and "password". It just doesn't work on the 1st run.
>
> Also, "auth" is "False". It's my understanding that user's don't need
> passwords anyway under this configuration? I intend to eventually
> enable "auth" - which is why I am creating the "root" user with a
> password - but for the sake of simplifying my question and this test
> case, I am not running with "auth" enabled.
>
> Since I /do/ want auth enabled eventually, I may have to just use
> > an email to
salt-users+...@googlegroups.com <javascript:>.
> <
https://groups.google.com/groups/opt_out>.