Skip to content

Commit

Permalink
add multiple execstarts by converting $execstart to array, change som…
Browse files Browse the repository at this point in the history
…e settings to default values
  • Loading branch information
Henrik Oelze committed Mar 7, 2017
1 parent 8722026 commit 0a6e8b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 19 additions & 2 deletions manifests/service.pp
Expand Up @@ -3,9 +3,10 @@
$execstop = undef,
$execreload = undef,
$execstartpre = undef,
$restart = 'always',
$restart = 'no',
$user = 'root',
$group = 'root',
$umask = undef,
$servicename = $name,
$forking = false,
$pid_file = undef,
Expand All @@ -16,7 +17,7 @@
$env_vars = [],
$environment_files = [],
$wants = [],
$wantedby = [ 'multi-user.target' ],
$wantedby = [],
$requiredby = [],
$after_units = [],
$before_units = [],
Expand Down Expand Up @@ -53,6 +54,22 @@
fail('Incompatible options: type / forking')
}

if($type != "oneshot" and is_array($execstart) and count($execstart) > 1)
{
fail('Incompatible options: There are multiple execstart values and Type is not "oneshot"')
}
else
{
if($type == "oneshot" and is_array($execstart))
{
$execstart_entries = $execstart
}
else
{
$execstart_entries = any2array($execstart)
}
}

# Takes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.
validate_re($restart, [ '^no$', '^on-success$', '^on-failure$', '^on-abnormal$', '^on-watchdog$', '^on-abort$', '^always$'], "Not a supported restart type: ${restart} - Takes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always")

Expand Down
13 changes: 10 additions & 3 deletions templates/service.erb
Expand Up @@ -22,7 +22,9 @@ Requires=<%= @requires.join(' ') %>
<% end -%>

[Service]
ExecStart=<%= @execstart %>
<%- @execstart_entries.each do |execstart_entry| -%>
ExecStart=<%= execstart_entry %>
<%- end -%>
<% if defined?(@execstop) -%>
ExecStop=<%= @execstop %>
<% end -%>
Expand All @@ -39,8 +41,6 @@ ExecStartPre=<%= @execstartpre %>
<%- end -%>
<% end -%>
Restart=<%= @restart %>
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=<%= @servicename %>
User=<%= @user %>
Group=<%= @group %>
Expand Down Expand Up @@ -86,6 +86,9 @@ RestartPreventExitStatus=<%= @restart_prevent_exit_status %>
<% if defined?(@limit_nofile) -%>
LimitNOFILE = <%= @limit_nofile %>
<% end -%>
<% if defined?(@umask) -%>
UMask = <%= @umask %>
<% end -%>
<% if defined?(@limit_nproc) -%>
LimitNPROC = <%= @limit_nproc %>
<% end -%>
Expand Down Expand Up @@ -128,8 +131,12 @@ StartLimitInterval=<%= @startlimitinterval %>
StartLimitBurst=<%= @startlimitburst %>
<% end -%>
<% if @wantedby.any? || @requiredby.any?-%>
[Install]
<% if @wantedby.any? -%>
WantedBy=<%= @wantedby.join(' ') %>
<% end -%>
<% if @requiredby.any? -%>
RequiredBy=<%= @requiredby.join(' ') %>
<% end -%>
<% end -%>

0 comments on commit 0a6e8b9

Please sign in to comment.