Defined Type: systemd::manage_dropin
- Defined in:
- manifests/manage_dropin.pp
Overview
Creates a drop-in file for a systemd unit from a template
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'manifests/manage_dropin.pp', line 94
define systemd::manage_dropin (
Systemd::Unit $unit,
Systemd::Dropin $filename = $name,
Enum['present', 'absent'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Boolean $selinux_ignore_defaults = false,
String $owner = 'root',
String $group = 'root',
Stdlib::Filemode $mode = '0444',
Boolean $show_diff = true,
Boolean $notify_service = false,
Boolean $daemon_reload = true,
Optional[Systemd::Unit::Install] $install_entry = undef,
Optional[Systemd::Unit::Unit] $unit_entry = undef,
Optional[Systemd::Unit::Slice] $slice_entry = undef,
Optional[Systemd::Unit::Service] $service_entry = undef,
Optional[Systemd::Unit::Timer] $timer_entry = undef,
Optional[Systemd::Unit::Path] $path_entry = undef,
Optional[Systemd::Unit::Socket] $socket_entry = undef,
Optional[Systemd::Unit::Mount] $mount_entry = undef,
Optional[Systemd::Unit::Swap] $swap_entry = undef,
) {
if $timer_entry and $unit !~ Pattern['^[^/]+\.timer'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} timer_entry is only valid for timer units")
}
if $path_entry and $unit !~ Pattern['^[^/]+\.path'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} path_entry is only valid for path units")
}
if $socket_entry and $unit !~ Pattern['^[^/]+\.socket'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} socket_entry is only valid for socket units")
}
if $slice_entry and $unit !~ Pattern['^[^/]+\.slice'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} slice_entry is only valid for slice units")
}
if $mount_entry and $unit !~ Pattern['^[^/]+\.mount'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} mount_entry is only valid for mount units")
}
if $swap_entry and $unit !~ Pattern['^[^/]+\.swap'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} swap_entry is only valid for swap units")
}
systemd::dropin_file { $name:
ensure => $ensure,
filename => $filename,
unit => $unit,
path => $path,
selinux_ignore_defaults => $selinux_ignore_defaults,
owner => $owner,
group => $group,
mode => $mode,
show_diff => $show_diff,
notify_service => $notify_service,
daemon_reload => $daemon_reload,
content => epp('systemd/unit_file.epp', {
'unit_entry' => $unit_entry,
'slice_entry' => $slice_entry,
'service_entry' => $service_entry,
'install_entry' => $install_entry,
'timer_entry' => $timer_entry,
'path_entry' => $path_entry,
'socket_entry' => $socket_entry,
'mount_entry' => $mount_entry,
'swap_entry' => $swap_entry,
}),
}
}
|