6 class EsInstanceValidator
7 attr_reader :instance_server
8 attr_reader :instance_port
10 def initialize(instance_server, instance_port)
11 @instance_server = instance_server
12 @instance_port = instance_port
15 # Utility method; attempts to make an https connection to the Elasticsearch instance.
16 # This is abstracted out into a method so that it can be called multiple times
19 # @return true if the connection is successful, false otherwise.
20 def attempt_connection
21 Timeout::timeout(Puppet[:configtimeout]) do
23 TCPSocket.new(@instance_server, @instance_port).close
25 rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
26 Puppet.debug "Unable to connect to Elasticsearch instance (#{@instance_server}:#{@instance_port}): #{e.message}"