aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorJerome <jerome@perlo.lib3.net>2009-12-25 04:11:25 -0500
committerJerome <jerome@perlo.lib3.net>2009-12-25 04:11:25 -0500
commit0321a3210ef6bb42ef8b536d0964bef081294d1d (patch)
tree1f66c99526ffa1bebe96f8279539511b2f96d228 /manifests
parent9d0fd33d5a30f385b6a1b84665858c063e11a8e7 (diff)
downloadpuppet-autossh-0321a3210ef6bb42ef8b536d0964bef081294d1d.tar.gz
puppet-autossh-0321a3210ef6bb42ef8b536d0964bef081294d1d.tar.bz2
Define autossh::tunnel resource and improve initscript
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp16
-rw-r--r--manifests/tunnel.pp70
2 files changed, 70 insertions, 16 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 6915a44..0fb316a 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -2,20 +2,4 @@ class autossh {
package { "autossh":
ensure => installed,
}
-
- file {
- "/etc/init.d/tunnel-autossh":
- owner => root,
- group => root,
- mode => 755,
- require => Package["autossh"],
- content => template("autossh/tunnel-autossh.erb");
- }
-
- exec { "autossh_update_rcd":
- command => "update-rc.d tunnel-autossh start 18 2 3 4 5 . stop 81 0 1 6 .",
- creates => "/etc/rc2.d/S18tunnel-autossh",
- path => "/bin:/sbin:/usr/sbin:/usr/bin",
- require => [ Package["autossh"], File["/etc/init.d/tunnel-autossh"]],
- }
}
diff --git a/manifests/tunnel.pp b/manifests/tunnel.pp
new file mode 100644
index 0000000..6d9c9d1
--- /dev/null
+++ b/manifests/tunnel.pp
@@ -0,0 +1,70 @@
+define autossh::tunnel (
+ $ensure = present,
+ $user,
+ $bind_address = 'localhost',
+ $port,
+ $host = 'localhost',
+ $hostport,
+ $remote_host,
+ $monitor_port = 0,
+ $gatetime = 'absent',
+ $first_poll = 'absent',
+ $poll = 'absent',
+ $maxstart = 'absent',
+ $maxlifetime = 'absent',
+ $logfile = 'absent'
+) {
+
+ include autossh
+
+ if ($ensure == 'present') {
+
+ file { "/etc/init.d/autossh-tunnel-${name}":
+ content => template("autossh/autossh-tunnel.erb"),
+ owner => root,
+ group => root,
+ mode => 755,
+ require => Package["autossh"],
+ notify => Service["autossh-tunnel-${name}"],
+ }
+
+ exec { "autossh-tunnel-${name}_update_rcd":
+ command => "update-rc.d autossh-tunnel-${name} start 18 2 3 4 5 . stop 81 0 1 6 .",
+ creates => "/etc/rc2.d/S18autossh-tunnel-${name}",
+ path => "/bin:/sbin:/usr/sbin:/usr/bin",
+ require => [ Package["autossh"], File["/etc/init.d/autossh-tunnel-${name}"]],
+ }
+
+ service { "autossh-tunnel-${name}":
+ ensure => running,
+ hasrestart => true,
+ hasstatus => true,
+ require => File["/etc/init.d/autossh-tunnel-${name}"],
+ }
+
+ }
+ else {
+
+ exec { "autossh-tunnel-${name}_stop":
+ command => "/etc/init.d/autossh-tunnel-${name} stop",
+ path => "/bin:/sbin:/usr/sbin:/usr/bin",
+ onlyif => "test -x /etc/init.d/autossh-tunnel-${name} && test -e /var/run/autossh-tunnel-${name}.pid",
+ }
+
+ file { "/etc/init.d/autossh-tunnel-${name}":
+ ensure => absent,
+ require => Exec["autossh-tunnel-${name}_stop"],
+ }
+
+ exec { "autossh-tunnel-${name}_update_rcd_remove":
+ command => "update-rc.d autossh-tunnel-${name} remove",
+ path => "/bin:/sbin:/usr/sbin:/usr/bin",
+ onlyif => "test -L /etc/rc2.d/S18autossh-tunnel-${name}",
+ require => File["/etc/init.d/autossh-tunnel-${name}"],
+ }
+
+ }
+
+}
+
+