Skip to content

Commit

Permalink
Mongo shell 2.6 doesn't support param digestpassword (Fixes voxpupuli…
Browse files Browse the repository at this point in the history
  • Loading branch information
webcompas committed Feb 5, 2018
1 parent 417c3b6 commit f581be9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/puppet/provider/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,13 @@ def self.mongo_24?
def mongo_24?
self.class.mongo_24?
end

def self.mongo_26?
v = mongo_version
!v[%r{^2\.6\.}].nil?
end

def mongo_26?
self.class.mongo_26?
end
end
11 changes: 10 additions & 1 deletion lib/puppet/provider/mongodb_user/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def self.prefetch(resources)

def create
if db_ismaster
if mongo_24?
if mongo_24? || mongo_26?
if @resource[:password_hash]
raise Puppet::Error, "password_hash can't be set on MongoDB older than 3.0; use password instead"
end
Expand Down Expand Up @@ -134,6 +134,15 @@ def password_hash=(_value)
def password=(value)
if mongo_24?
mongo_eval("db.changeUserPassword('#{@resource[:username]}','#{value}')", @resource[:database])
elsif mongo_26?
cmd_json = <<-EOS.gsub(%r{^\s*}, '').gsub(%r{$\n}, '')
{
"updateUser": "#{@resource[:username]}",
"pwd": "#{@resource[:password]}"
}
EOS

mongo_eval("db.runCommand(#{cmd_json})", @resource[:database])
else
cmd_json = <<-EOS.gsub(%r{^\s*}, '').gsub(%r{$\n}, '')
{
Expand Down

0 comments on commit f581be9

Please sign in to comment.