$host = 'localhost',
$hostport,
$remote_host,
- $monitor_port = 0,
+ $monitor_port = 'absent',
$gatetime = 'absent',
$first_poll = 'absent',
$poll = 'absent',
include autossh
+ # According to the autossh documentation, using OpenSSH ServerAlive
+ # options is better than using a monitor port, so we do that by default.
+ if ($monitor_port == 'absent') {
+ $real_monitor_port = 0
+ $ssh_extra_options = "-o ServerAliveInterval=30 -o ServerAliveCountMax=3"
+ }
+ else {
+ $real_monitor_port = $monitor_port
+ $ssh_extra_options = ''
+ }
+
if ($ensure == 'present') {
file { "/etc/init.d/autossh-tunnel-${name}":
#
# AutoSSH configuration
#
-AUTOSSH_ARGS="-M <%= monitor_port %> -N -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L <%= bind_address %>:<%= port %>:<%= host %>:<%= hostport %> <%= remote_host %>"
+AUTOSSH_ARGS="-M <%= real_monitor_port %> -N -L <%= bind_address %>:<%= port %>:<%= host %>:<%= hostport %> <%= ssh_extra_options %> <%= remote_host %>"
<% if gatetime != 'absent' -%>
AUTOSSH_GATETIME=<%= gatetime %>
<% end -%>