Skip to content

Commit e19b6a5

Browse files
authored
Merge pull request #561 from identw/fix-create-user-for-4x-versions
Fixed the problem: the user was not created for Mongodb 4.x
2 parents 5b10c90 + a7e21ae commit e19b6a5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/puppet/provider/mongodb.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,13 @@ def self.mongo_26?
174174
def mongo_26?
175175
self.class.mongo_26?
176176
end
177+
178+
def self.mongo_4?
179+
v = mongo_version
180+
!v[%r{^4\.}].nil?
181+
end
182+
183+
def mongo_4?
184+
self.class.mongo_4?
185+
end
177186
end

lib/puppet/provider/mongodb_user/mongodb.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ def create
5353
digestPassword: false
5454
}
5555

56+
if mongo_4?
57+
# SCRAM-SHA-256 requires digestPassword to be true.
58+
command[:mechanisms] = ['SCRAM-SHA-1']
59+
end
60+
5661
mongo_eval("db.runCommand(#{command.to_json})", @resource[:database])
5762
else
5863
Puppet.warning 'User creation is available only from master host'

0 commit comments

Comments
 (0)