Skip to content

Commit 6e3c95a

Browse files
author
Johan De Wit
committed
add mechanisms attribute during fetching
1 parent c1ba3d7 commit 6e3c95a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/puppet/provider/mongodb_user/mongodb.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ def self.instances
2323
Puppet.debug("Fetching user #{user}")
2424
db = if user['db'] == '$external'
2525
# For external users, we need to retreive the original DB name from here.
26-
user['customData']['createdBy'][%r{.*on db (.*)'\]$}, 1]
26+
user['customData']['createdBy'][%r{.* (.*)'\]$}, 1]
2727
else
2828
user['db']
2929
end
30-
new(name: user['_id'],
30+
u = new(name: user['_id'],
3131
ensure: :present,
3232
username: user['user'],
3333
database: db,
3434
roles: from_roles(user['roles'], db),
3535
password_hash: user['credentials']['MONGODB-CR'],
3636
scram_credentials: user['credentials']['SCRAM-SHA-1'])
37+
Puppet.debug("Fetching users, creating the found resources: #{u}")
38+
u
3739
end
3840
else
3941
Puppet.warning 'User info is available only from master host'
@@ -57,6 +59,7 @@ def create
5759
password_hash = @resource[:password_hash]
5860
password_hash = Puppet::Util::MongodbMd5er.md5(@resource[:username], @resource[:password]) if !password_hash && @resource[:password]
5961

62+
6063
command = {
6164
createUser: @resource[:username],
6265
customData: {
@@ -88,8 +91,6 @@ def create
8891
Puppet.debug("Creating user for with command #{command}")
8992
mongo_eval("db.runCommand(#{command.to_json})", @resource[:database])
9093
end
91-
else
92-
Puppet.warning 'User creation is available only from master host'
9394

9495
@property_hash[:ensure] = :present
9596
@property_hash[:username] = @resource[:username]
@@ -98,6 +99,9 @@ def create
9899
@property_hash[:roles] = @resource[:roles]
99100

100101
exists?
102+
103+
else
104+
Puppet.warning 'User creation is available only from master host'
101105
end
102106
end
103107

0 commit comments

Comments
 (0)