No, it is remote. I am deploying a application cluster that has some nodes dependencies, so basically in order to execute a script in one node I need to make sure first that the remote node is already listening on a specific port, if that node is not listening on that port I do not want to execute the script.
I used to work with Chef before and it was easy to accomplish that with ruby blocks.
require 'socket'
require 'timeout'
def port_open?(ip, port, seconds=1)
Timeout::timeout(seconds) do
begin
TCPSocket.new(ip, port).close
true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
false
end
end
rescue Timeout::Error
false
end
I'm not sure how I can use something like that in puppet, I don't seem to be able to pass puppet module variables to factors? With custom functions, I can pass variables as arguments but I was having trouble to get a boolean value returned. I might have to play with that some more, I just thought I would ask to see if anybody had any working example of that.
Thanks!!