Defined Type: systemd::service::simple
- Defined in:
- manifests/service/simple.pp
Overview
This function manages a simple service configuration file. All parameters correspond to directives in the systemd unit file.
Note: for historic reasons, a collection of quite arbitrary service parameters are available as ‘first-class parameters’ in this function.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'manifests/service/simple.pp', line 9
define systemd::service::simple (
String $description,
Variant[[Array[String],String]] $exec_start,
Optional[Variant[[Array[String],String]]] $exec_stop = undef,
Optional[Variant[[Array[String],String]]] $exec_reload = undef,
Optional[Variant[[Array[String],String]]] $requires = undef,
Optional[Variant[[Array[String],String]]] $before = undef,
Optional[Variant[[Array[String],String]]] $after = undef,
Optional[Variant[[Array[String],String]]] $wantedby = 'multi-user.target',
Optional[Variant[[Array[String],String]]] $requiredby = undef,
String $service_type = 'simple',
Optional[String] $service_user = undef,
Optional[String] $service_group = undef,
Optional[String] $working_directory = undef,
Optional[String] $cond_path_is_directory = undef,
Optional[String] $environment = undef,
Optional[String] $environment_file = undef,
String $restart = 'on-failure',
String $restart_sec = '5',
String $start_limit_interval = '120s',
String $start_limit_burst = '3',
String $servicename = $title,
String $ensure = 'present',
Boolean $manage_unitstatus = true,
Enum['running','stopped'] $unit_ensure = 'running',
Boolean $unit_enable = true,
Optional[Hash] $unit_options = {},
Optional[Hash] $install_options = {},
Optional[Hash] $service_options = {},
) {
include ::systemd
#
## Translate parameters into unit directives and delegate to systemd::unit
#
systemd::unit { "${title}::unit::service":
ensure => $ensure,
unit_name => $servicename,
unit_type => 'service',
manage_unitstatus => $manage_unitstatus,
unit_ensure => $unit_ensure,
unit_enable => $unit_enable,
unit_options => $unit_options + {
'Description' => $description,
'Requires' => $requires,
'Before' => $before,
'After' => $after,
'ConditionPathIsDirectory' => $cond_path_is_directory,
}.filter |$k,$v| { !$v.empty },
install_options => $install_options + {
'WantedBy' => $wantedby,
'RequiredBy' => $requiredby,
}.filter |$k,$v| { !$v.empty },
type_options => $service_options + {
'ExecStart' => $exec_start,
'ExecStop' => $exec_stop,
'ExecReload' => $exec_reload,
'Type' => $service_type,
'User' => $service_user,
'Group' => $service_group,
'Environment' => $environment,
'EnvironmentFile' => $environment_file,
'Restart' => $restart,
'RestartSec' => $restart_sec,
'StartLimitBurst' => $start_limit_burst,
'StartLimitInterval' => $start_limit_interval,
'WorkingDirectory' => $working_directory,
}.filter |$k,$v| { !$v.empty }
}
}
|