Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multiple execstarts by converting $execstart to array, #32

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions manifests/service.pp
Expand Up @@ -3,7 +3,7 @@
$execstop = undef,
$execreload = undef,
$execstartpre = undef,
$restart = 'always',
$restart = 'no',
$user = 'root',
$group = 'root',
$servicename = $name,
Expand All @@ -16,7 +16,7 @@
$env_vars = [],
$environment_files = [],
$wants = [],
$wantedby = [ 'multi-user.target' ],
$wantedby = [],
$requiredby = [],
$after_units = [],
$before_units = [],
Expand Down Expand Up @@ -53,6 +53,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 -%>