@@ -144,7 +144,6 @@ def self.replset_properties
144144 end
145145 nil
146146 rescue Puppet ::ExecutionFailure => e
147- #if e.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command} || e.message =~ %r{no replset config has been received}
148147 if e . message =~ %r{command replSetGetConfig requires authentication} || e . message =~ %r{not authorized on admin to execute command}
149148 output = mongo_command ( 'rs.status()' , conn_string )
150149 if output [ 'members' ]
@@ -188,9 +187,9 @@ def get_hosts_status(members)
188187 case e . message
189188 when %r{no replset config has been received}
190189 Puppet . warning ( 'No replicaset config received, needs initialisation' )
191- when / Authentication failed/ , / not authorized on admin/ , /Authentication failed/
190+ when %r{ Authentication failed} , %r{ not authorized on admin}
192191 Puppet . warning "Host #{ host } is available, but you are unauthorized because of authentication is enabled: #{ auth_enabled } "
193- when / command replSetGetStatus requires authentication/
192+ when %r{ command replSetGetStatus requires authentication}
194193 Puppet . warning ( "Node #{ host } is reachable but requires authentication: ReplicaSet not initialized" )
195194 end
196195 alive . push ( member )
@@ -410,11 +409,9 @@ def mongo_command(command, host, retries = 4)
410409
411410 def self . mongo_command ( command , host = nil , retries = 4 )
412411 output = mongo_eval ( "EJSON.stringify(#{ command } )" , 'admin' , retries , host )
413- if output =~ %r{no replset config has been received} || output =~ %r{Authentication failed}
414- output = '{}'
415- end
416412
417413 # Hack to avoid non-json empty sets
414+ output = '{}' if output =~ %r{no replset config has been received} || output =~ %r{Authentication failed}
418415 output = '{}' if output == "null\n "
419416 output = '{}' if output == "\n null\n "
420417
0 commit comments