6ea0beb114
this is important to make it easier to guess the ssh port from the central server. we rely on ServerAliveInterval instead to reconnect when we lose the server. this was unintentionally removed in november 2012 in the isuma-autossh package, saying it was "not supported everywhere" and due to some confusion about the defaults (defaults are to *enable* the port). see commit ec0ebdd9533a29ee4f62f9fbb84ee9e80219ef84 in there.
40 lines
1.1 KiB
Puppet
40 lines
1.1 KiB
Puppet
class sshd::autossh($host,
|
|
$port = undef, # this should be a remote->local hash
|
|
$remote_user = undef,
|
|
$user = 'root',
|
|
$pidfile = '/var/run/autossh.pid',
|
|
) {
|
|
if $port {
|
|
$port_ensure = $port
|
|
}
|
|
else {
|
|
# random port between 10000 and 20000
|
|
$port_ensure = fqdn_rand(10000) + 10000
|
|
}
|
|
if $remote_user {
|
|
$remote_user_ensure = $remote_user
|
|
}
|
|
else {
|
|
$remote_user_ensure = "host-$fqdn"
|
|
}
|
|
file {
|
|
'/etc/init.d/autossh':
|
|
mode => '0555',
|
|
source => 'puppet:///modules/sshd/autossh.init.d';
|
|
'/etc/default/autossh':
|
|
mode => '0444',
|
|
content => "USER=$user\nPIDFILE=$pidfile\nDAEMON_ARGS='-M0 -f -o ServerAliveInterval=15 -o ServerAliveCountMax=4 -q -N -R $port_ensure:localhost:22 $remote_user_ensure@$host'\n";
|
|
}
|
|
package { 'autossh':
|
|
ensure => present,
|
|
}
|
|
service { 'autossh':
|
|
ensure => running,
|
|
enable => true,
|
|
subscribe => [
|
|
File['/etc/init.d/autossh'],
|
|
File['/etc/default/autossh'],
|
|
Package['autossh'],
|
|
],
|
|
}
|
|
}
|