diff options
author | Micah <micah@leap.se> | 2016-07-12 16:45:28 -0400 |
---|---|---|
committer | Micah <micah@leap.se> | 2016-07-12 16:45:28 -0400 |
commit | 4ccae8700fb136bfbc6b7ef7bb0ab482e632139f (patch) | |
tree | 9711bb668fb93ebb05b7efad982f3d988c88afd7 /puppet/modules/sshd/manifests/autossh.pp | |
parent | b85f8c1b914a09b6001d4c1b5c7d07ef17ac766f (diff) |
git subrepo clone https://leap.se/git/puppet_sshd puppet/modules/sshd
subrepo:
subdir: "puppet/modules/sshd"
merged: "76f4f87"
upstream:
origin: "https://leap.se/git/puppet_sshd"
branch: "master"
commit: "76f4f87"
git-subrepo:
version: "0.3.0"
origin: "https://github.com/ingydotnet/git-subrepo"
commit: "1e79595"
Change-Id: Icf616796837cdbe40deb188d2b72f1c726c9e807
Diffstat (limited to 'puppet/modules/sshd/manifests/autossh.pp')
-rw-r--r-- | puppet/modules/sshd/manifests/autossh.pp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/puppet/modules/sshd/manifests/autossh.pp b/puppet/modules/sshd/manifests/autossh.pp new file mode 100644 index 00000000..5650584a --- /dev/null +++ b/puppet/modules/sshd/manifests/autossh.pp @@ -0,0 +1,40 @@ +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'], + ], + } +} |