Skip to content

Commit ce85922

Browse files
hblockhblock
authored andcommitted
parse NumberLong data type from mongodb outputs to generate valid json. This fixes errors like "Error: /Stage[main]/Mongodb::Replset/Mongodb_replset[rsmain]: Could not evaluate: 751: unexpected token at ... "protocolVersion" : NumberLong(1), .... "
1 parent 852b097 commit ce85922

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/puppet/provider/mongodb.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ def self.mongo_eval(cmd, db = 'admin', retries = 10, host = nil)
166166
raise Puppet::ExecutionFailure, "Could not evalute MongoDB shell command: #{cmd}"
167167
end
168168

169-
out.gsub!(/ObjectId\(([^)]*)\)/, '\1')
169+
['ObjectId','NumberLong'].each do |data_type|
170+
out.gsub!(/#{data_type}\(([^)]*)\)/, '\1')
171+
end
170172
out.gsub!(/^Error\:.+/, '')
171173
out
172174
end

0 commit comments

Comments
 (0)