diff options
author | Markus Strauss <Markus@ITstrauss.eu> | 2011-10-28 14:27:47 -0400 |
---|---|---|
committer | Markus Strauss <Markus@ITstrauss.eu> | 2011-10-28 14:27:47 -0400 |
commit | 80dd5f659566d11b4f210b218e0c254271f1cb24 (patch) | |
tree | d8de8154bb9b51dc73f52978da3e723d8a007abd | |
parent | 8bd3fba55a717bae459ead2b03bc7ccdd9f2a82e (diff) | |
download | puppet-runit-80dd5f659566d11b4f210b218e0c254271f1cb24.tar.gz puppet-runit-80dd5f659566d11b4f210b218e0c254271f1cb24.tar.bz2 |
new command parameter with default run script template
-rw-r--r-- | manifests/service.pp | 33 | ||||
-rw-r--r-- | templates/run.erb | 8 |
2 files changed, 32 insertions, 9 deletions
diff --git a/manifests/service.pp b/manifests/service.pp index 56433fd..3258bec 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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 index 0000000..f02a486 --- /dev/null +++ b/templates/run.erb @@ -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 %> |