From 09aa9b1d4caeaa090e4a303e101e982ed04123ca Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 29 May 2010 13:52:30 -0300 Subject: Adding initial tunnel support --- manifests/subsystems/tunnel.pp | 76 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 manifests/subsystems/tunnel.pp (limited to 'manifests/subsystems') diff --git a/manifests/subsystems/tunnel.pp b/manifests/subsystems/tunnel.pp new file mode 100644 index 0000000..f034c61 --- /dev/null +++ b/manifests/subsystems/tunnel.pp @@ -0,0 +1,76 @@ +class tunnel { + + User <<| tag == "autossh-$fqdn" |>> + File <<| tag == "autossh-$fqdn" |>> + Ssh_authorized_key <<| tag == "autossh-$real_backupserver_tag" |>> + + define setup($ensure = present, $user = $hostname, $host, $localport, $hostport, $sshport = '22', $keytype = 'dsa') { + $dir = "/var/backups/remote/$user" + $tag = "autossh-$hostname" + $ssh_dir = "$dir/.ssh" + + autossh::tunnel { $name: + ensure => $ensure, + user => $user, + port => $localport, + hostport => $hostport, + remote_host => $host, + sshport => $sshport, + } + + if !defined(File["$dir"]) { + @@file { "$dir": + ensure => directory, + mode => 0750, + owner => $user, + group => 0, + tag => "$tag", + } + } + + if !defined(File["$sshdir"]) { + @@file { "$sshdir": + ensure => directory, + mode => 0700, + owner => $user, + group => 0, + require => [User[$user], File["$dir"]], + tag => "$tag", + } + } + + if !defined(File["${ssh_dir}/authorized_keys"]) { + @@file { "${ssh_dir}/authorized_keys": + ensure => present, + mode => 0644, + owner => 0, + group => 0, + source => "puppet://$server/files/keys/${user}_id_${keytype}.pub", + require => File["${ssh_dir}"], + tag => "$tag", + } + } + + if !defined(User["$user"]) { + @@user { "$user": + ensure => "present", + comment => "$name backup sandbox", + home => "$dir", + managehome => true, + shell => "/bin/sh", + password => '*', + require => Group['backupninjas'], + tag => "$tag" + } + } + } + + define mail ($sshport = '22') { + tunnel::setup { "smtp": + host => "$name.$domain", + sshport => "$sshport", + localport => '25', + hostport => '25', + } + } +} -- cgit v1.2.3