2014-03-26 32 views
3

我正致力于使用puppetlabs mongodb module启用验证。启用验证的木偶MongoDb

正如文档所说,要启用身份验证,我应该添加auth => true。 但是,为了验证工作,我have to add a user to the admin database,所以我做了,像这样:

mongodb::db { 'admin': 
    user   => 'adminuser', 
    password_hash => 'a15fbfca5e3a758be80ceaf42458bcd8', 
} 

这适用于第一轮,但随后的运行中导致错误:

Mongodb::Db[admin]/Mongodb_database[admin]: Could not evaluate: Execution of '/usr/bin/mongo --quiet --eval db.getMongo().getDBNames()' returned 252: Wed Mar 26 16:28:40 uncaught exception: listDatabases failed:{ "errmsg" : "need to login", "ok" : 0 }

这使得因为现在无法进行身份验证来检查管理数据库是否已经存在。

你如何处理配置这个模块的mongodb密码认证?

+0

有[dba.stackexchangecom](http://dba.stackexchange.com/)网站,你知道。和堆栈溢出**是**旨在**编程**问题和答案。 http://stackoverflow.com/help/on-topic –

+0

@NeilLunn这更多的是一个devops问题。我现在也把它发布在ServerFault上。但似乎有些混淆,最好在哪里发布这类问题。 DBA甚至只提6个问题,甚至提到傀儡。 – bencoder

+0

@bencoder上个月在https://ask.puppetlabs.com/question/5307/mongodb-authtrue/ –

回答

1

看起来这拉动请求(合并2015年3月23日)可能会解决此问题:https://github.com/puppetlabs/puppetlabs-mongodb/pull/194

有了这个,你可以到服务器创建提供管理员用户名和密码这样的:

class {'::mongodb::server': 
    auth   => true, 
    create_admin => true, 
    admin_username => "admin", 
    admin_password => "admin" 
} 

现在傀儡应该能够在随后的运行中对MongoDB的验证。

+0

我们用不同的方式解决了它 - 只是注意到了这个答案,它看起来不错,所以批准这个 – bencoder

1

这是我完成的清单文件,使我的部署工作(在Vagrant设置上)。我只想安装Mongo,这就是我所取得的成就。

class {'::mongodb::server': 
    #port => 27017, #the default port 
    verbose => true, 
    auth => true, 
    bind_ip => ['0.0.0.0'] #Necessary for Vagrant to bind on the correct IP address instead of the loopback 127.0.0.1 
} 

#if we install a different port this did not work for me 
mongodb::db { 'testdb': 
    user   => 'user1', 
    password_hash => 'a15fbfca5e3a758be80ceaf42458bcd8', #this means pass1 
} 

include '::mongodb::server' 

请注意,在你的modules文件夹中的以下模块:

+0

上发布了一个可能相关的问题。这是我们最终做的。尽管原始问题的目的是启用管理员身份验证 - 这意味着它需要本地主机的用户名和密码,但这似乎是不可能的,因为puppet模块依赖于无需用户名/密码就能访问服务器,密码才能执行设置。 – bencoder