Skip to content

Commit

Permalink
[X509] make user idempotent when using $external db
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan De Wit committed Aug 17, 2023
1 parent b7288e5 commit d70d9f8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/puppet/provider/mongodb_user/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ def self.instances
Puppet.debug("XXXXXXXX In self.instances, retrieved users: #{users}")

users.map do |user|
db = if user['db'] == '$external'
# For external users, we need to retreive the original DB name from here.
user['customData']['createdBy'][/.*on db (.*)'\]$/,1]
else
user['db']
end
new(name: user['_id'],
ensure: :present,
username: user['user'],
database: user['db'],
roles: from_roles(user['roles'], user['db']),
database: db,
roles: from_roles(user['roles'], db),
password_hash: user['credentials']['MONGODB-CR'],
scram_credentials: user['credentials']['SCRAM-SHA-1'])
end
Expand Down

0 comments on commit d70d9f8

Please sign in to comment.