]> gitweb.fluxo.info Git - puppet-runit.git/commitdiff
new command parameter with default run script template
authorMarkus Strauss <Markus@ITstrauss.eu>
Fri, 28 Oct 2011 18:27:47 +0000 (14:27 -0400)
committerMarkus Strauss <Markus@ITstrauss.eu>
Fri, 28 Oct 2011 18:27:47 +0000 (14:27 -0400)
manifests/service.pp
templates/run.erb [new file with mode: 0644]

index 56433fd772a064e58f719c1494544edaab0f9f24..3258bec149367fb4e57d0e7cd60dec09322c9b21 100644 (file)
@@ -1,14 +1,26 @@
 define runit::service (
-  $user    = root,       # the service's user name
-  $group   = root,       # the service's group name
-  $enable  = true,       # shall the service be linked to /etc/service
-  $ensure  = present,    # shall the service be present in /etc/sv
-  $logger  = false,      # shall we setup an logging service
-  # either one of these must be given:
-  $source  = undef,      # either source or content must be defined; 
-  $content = undef       # this will be the run script /etc/sv/$name/run
+  $user     = root,       # the service's user name
+  $group    = root,       # the service's group name
+  $enable   = true,       # shall the service be linked to /etc/service
+  $ensure   = present,    # shall the service be present in /etc/sv
+  # either one of these three must be declared - it defines the content of the run script /etc/sv/$name/run
+  $commmand = undef,      # the most simple way;  just state command here - it may not daemonize itself,
+                          # but rather stay in the foreground;  all output is logged automatically to $logdir/current
+                          # this uses a default template which provides logging
+  $source   = undef,      # specify a source file on your puppet master 
+  $content  = undef,      # specify the content directly (mostly via 'template')
+  # service directory - this is required if you use 'command'
+  $rundir   = undef,
+  # logging stuff
+  $logger   = false,      # shall we setup an logging service;  if you use 'command' before, 
+                          # all output from command will be logged automatically to $logdir
+  $logdir   = $svdir      # override logging directory
 ) {
 
+  # FixMe: Validate parameters
+  # fail("Only one of 'command', 'content', or 'source' parameters is allowed")
+
+
   # resource defaults
   File { owner => root, group => root, mode => 644 }
 
@@ -32,7 +44,10 @@ define runit::service (
         purge => true,
       ;
     "${svbase}/run":
-      content => $content,
+      content => $content ? {
+        undef   => template('runit/run.erb'),
+        default => $content,
+      },
       source  => $source,
       ensure  => $ensure,
       mode    => 755,
diff --git a/templates/run.erb b/templates/run.erb
new file mode 100644 (file)
index 0000000..f02a486
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+envdir=<%= svbase %>/env
+root=<%= rundir %>
+echo Starting <%= name %> from $root
+cd $root
+
+exec 2>&1
+exec chpst -e $envdir -u <%= user %>:<%= group %> <%= command %>