Help on ERB teample
Hi I am new to puppet/ruby . Appreciate if someone help me on this.
<% if TCPSocket.new("host1", 636) and TCPSocket.new("host2", 1636) %> host xxxx port 636 <% else -%> host yyyy port 389 <% end %> <% end %>
Above is sample code of my ERB template..I wana check if port is open for specific hosts before doing anything. The problem is when the port is not opened it raises Connection refused error and hence it failing puppet apply. Can't I catch exception and exit if exception is raised? Also how to define timeout?
rescue Errno::ECONNREFUSED => e exit
I tried above code but it didnt work.
Can someone suggest pls?