aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorAntoine Beaupré <anarcat@koumbit.org>2015-06-18 15:58:51 -0400
committerAntoine Beaupré <anarcat@koumbit.org>2015-06-18 17:11:21 -0400
commit72b4eadc2db6ed72625f3322f466d21c556ef69b (patch)
tree2a675065161dcb881417a78569fc5fcd63898410 /manifests
parentabd504a5f459873f547ccdf4940c0ac5ae7fe874 (diff)
downloadpuppet-sshd-72b4eadc2db6ed72625f3322f466d21c556ef69b.tar.gz
puppet-sshd-72b4eadc2db6ed72625f3322f466d21c556ef69b.tar.bz2
import from autossh package
Diffstat (limited to 'manifests')
-rw-r--r--manifests/autossh.pp34
1 files changed, 34 insertions, 0 deletions
diff --git a/manifests/autossh.pp b/manifests/autossh.pp
new file mode 100644
index 0000000..80d571b
--- /dev/null
+++ b/manifests/autossh.pp
@@ -0,0 +1,34 @@
+class sshd::autossh($host,
+ $port = undef, # this should be a remote->local hash
+ $remote_user = undef,
+) {
+ 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 => "DAEMON_OPTS='-o ServerAliveInterval=15 -o ServerAliveCountMax=4 -q -N -R $port_ensure:localhost:22 $user_ensure@$host'\n";
+ }
+ service { 'autossh':
+ ensure => running,
+ enable => true,
+ subscribe => [
+ File['/etc/init.d/autossh'],
+ File['/etc/default/autossh']
+ ],
+ }
+}