Defined Type: systemd::service
- Defined in:
- modules/systemd/manifests/service.pp
Summary
Manages a systemd-based unit as a puppet service, properly handling:Overview
-
the unit file
-
the puppet service definition and state
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 |
# File 'modules/systemd/manifests/service.pp', line 21
define systemd::service (
String $content,
Wmflib::Ensure $ensure = 'present',
Systemd::Unit::Type $unit_type = 'service',
Boolean $restart = false,
Boolean $override = false,
Optional[String[1]] $override_filename = undef,
Boolean $monitoring_enabled = false,
String $monitoring_contact_group = 'admins',
Optional[Stdlib::HTTPUrl] $monitoring_notes_url = undef,
Boolean $monitoring_critical = false,
Optional[Wmflib::Team] $team = undef,
Hash $service_params = {},
) {
if $unit_type == 'service' {
$label = $title
$provider = undef
} else {
# Use a fully specified label for the unit.
$label = "${title}.${unit_type}"
# Force the provider of the service to be systemd if the unit type is
# not service.
$provider = 'systemd'
}
$enable = $ensure ? {
'present' => true,
default => false,
}
$base_params = {
ensure => stdlib::ensure($ensure, 'service'),
enable => $enable,
provider => $provider,
}
$params = merge($base_params, $service_params)
ensure_resource('service', $label, $params)
systemd::unit { $label:
ensure => $ensure,
content => $content,
override => $override,
override_filename => $override_filename,
restart => $restart,
team => $team,
}
if $monitoring_enabled {
unless $monitoring_notes_url {
fail('Must provide $monitoring_notes_url if $monitoring_enabled')
}
systemd::monitor { $title:
ensure => $ensure,
notes_url => $monitoring_notes_url,
contact_group => $monitoring_contact_group,
critical => $monitoring_critical,
}
}
}
|