Puppet Class: systemd

Defined in:
manifests/init.pp

Overview

This module allows triggering systemd commands once for all modules

Parameters:

  • default_target (Optional[Pattern['^.+\.target$']]) (defaults to: undef)

    The default systemd boot target, unmanaged if set to undef.

  • service_limits (Hash[String[1],Hash[String[1], Any]]) (defaults to: {})

    May be passed a resource hash suitable for passing directly into the “create_resources()“ function as called on “systemd::service_limits“

  • networks (Hash[String[1],Hash[String[1], Any]]) (defaults to: {})

    Hash of ‘systemd::network` resources

  • timers (Hash[String[1],Hash[String[1], Any]]) (defaults to: {})

    Hash of ‘systemd::timer` resources

  • tmpfiles (Hash[String[1],Hash[String[1], Any]]) (defaults to: {})

    Hash of ‘systemd::tmpfile` resources

  • unit_files (Hash[String[1],Hash[String[1], Any]]) (defaults to: {})

    Hash of ‘systemd::unit_file` resources

  • manage_resolved (Boolean) (defaults to: false)

    Manage the systemd resolver

  • resolved_ensure (Enum['stopped','running']) (defaults to: 'running')

    The state that the “resolved“ service should be in. When migrating from ‘running’ to ‘stopped’ an attempt will be made to restore a working ‘/etc/resolv.conf` using `/run/systemd/resolve/resolv.conf`.

  • resolved_package (Optional[Enum['systemd-resolved']]) (defaults to: undef)

    The name of a systemd sub package needed for systemd-resolved if one needs to be installed.

  • dns (Optional[Variant[Array[String],String]]) (defaults to: undef)

    A space-separated list of IPv4 and IPv6 addresses to use as system DNS servers. DNS requests are sent to one of the listed DNS servers in parallel to suitable per-link DNS servers acquired from systemd-networkd.service(8) or set at runtime by external applications. requires puppetlabs-inifile

  • fallback_dns (Optional[Variant[Array[String],String]]) (defaults to: undef)

    A space-separated list of IPv4 and IPv6 addresses to use as the fallback DNS servers. Any per-link DNS servers obtained from systemd-networkd take precedence over this setting. requires puppetlabs-inifile

  • domains (Optional[Variant[Array[String],String]]) (defaults to: undef)

    A space-separated list of domains host names or IP addresses to be used systemd-resolved take precedence over this setting.

  • llmnr (Optional[Variant[Boolean,Enum['resolve']]]) (defaults to: undef)

    Takes a boolean argument or “resolve”.

  • multicast_dns (Optional[Variant[Boolean,Enum['resolve']]]) (defaults to: undef)

    Takes a boolean argument or “resolve”.

  • dnssec (Optional[Variant[Boolean,Enum['allow-downgrade']]]) (defaults to: undef)

    Takes a boolean argument or “allow-downgrade”.

  • dnsovertls (Variant[Boolean,Enum['yes', 'opportunistic', 'no']]) (defaults to: false)

    Takes a boolean argument or one of “yes”, “opportunistic” or “no”. “true” corresponds to “opportunistic” and “false” (default) to “no”.

  • cache (Optional[Variant[Boolean,Enum['no-negative']]]) (defaults to: undef)

    Takes a boolean argument or “no-negative”. If left ‘undef` the cache setting will not be modified.

  • dns_stub_listener (Optional[Variant[Boolean,Enum['udp','tcp']]]) (defaults to: undef)

    Takes a boolean argument or one of “udp” and “tcp”.

  • dns_stub_listener_extra (Optional[Array[String[1]]]) (defaults to: undef)

    Additional addresses for the DNS stub listener to listen on

  • manage_resolv_conf (Boolean) (defaults to: true)

    For when ‘manage_resolved` is `true` should the file `/etc/resolv.conf` be managed.

  • use_stub_resolver (Boolean) (defaults to: false)

    Takes a boolean argument. When “false” (default) it uses /run/systemd/resolve/resolv.conf as /etc/resolv.conf. When “true”, it uses /run/systemd/resolve/stub-resolv.conf When ‘resolved_ensure` is `stopped` this parameter is ignored.

  • manage_networkd (Boolean) (defaults to: false)

    Manage the systemd network daemon

  • networkd_ensure (Enum['stopped','running']) (defaults to: 'running')

    The state that the “networkd“ service should be in

  • networkd_package (Optional[String[1]]) (defaults to: undef)

    Name of the package required for systemd-networkd, if any

  • manage_timesyncd (Boolean) (defaults to: false)

    Manage the systemd timesyncd daemon

  • timesyncd_ensure (Enum['stopped','running']) (defaults to: 'running')

    The state that the “timesyncd“ service should be in

  • timesyncd_package (Optional[String[1]]) (defaults to: undef)

    Name of the package required for systemd-timesyncd, if any

  • ntp_server (Optional[Variant[Array,String]]) (defaults to: undef)

    comma separated list of ntp servers, will be combined with interface specific addresses from systemd-networkd. requires puppetlabs-inifile

  • fallback_ntp_server (Optional[Variant[Array,String]]) (defaults to: undef)

    A space-separated list of NTP server host names or IP addresses to be used as the fallback NTP servers. Any per-interface NTP servers obtained from systemd-networkd take precedence over this setting. requires puppetlabs-inifile

  • manage_journald (Boolean) (defaults to: true)

    Manage the systemd journald

  • journald_settings (Systemd::JournaldSettings) (defaults to: {})

    Config Hash that is used to configure settings in journald.conf

  • manage_udevd (Boolean) (defaults to: false)

    Manage the systemd udev daemon

  • udev_log (Optional[Variant[Integer,String]]) (defaults to: undef)

    The value of /etc/udev/udev.conf udev_log

  • udev_children_max (Optional[Integer]) (defaults to: undef)

    The value of /etc/udev/udev.conf children_max

  • udev_exec_delay (Optional[Integer]) (defaults to: undef)

    The value of /etc/udev/udev.conf exec_delay

  • udev_event_timeout (Optional[Integer]) (defaults to: undef)

    The value of /etc/udev/udev.conf event_timeout

  • udev_resolve_names (Optional[Enum['early', 'late', 'never']]) (defaults to: undef)

    The value of /etc/udev/udev.conf resolve_names

  • udev_timeout_signal (Optional[Variant[Integer,String]]) (defaults to: undef)

    The value of /etc/udev/udev.conf timeout_signal

  • udev_rules (Hash) (defaults to: {})

    Config Hash that is used to generate instances of our ‘udev::rule` define.

  • machine_info_settings (Systemd::MachineInfoSettings) (defaults to: {})

    Settings to place into /etc/machine-info (hostnamectl)

  • manage_logind (Boolean) (defaults to: false)

    Manage the systemd logind

  • logind_settings (Systemd::LogindSettings) (defaults to: {})

    Config Hash that is used to configure settings in logind.conf

  • loginctl_users (Hash) (defaults to: {})

    Config Hash that is used to generate instances of our type ‘loginctl_user`.

  • dropin_files (Hash) (defaults to: {})

    Configure dropin files via hiera with factory pattern

  • manage_all_network_files (Boolean) (defaults to: false)
  • network_path (Stdlib::Absolutepath) (defaults to: '/etc/systemd/network')

    where all networkd files are placed in

  • manage_accounting (Boolean) (defaults to: false)

    when enabled, the different accounting options (network traffic, IO, CPU util…) are enabled for units

  • accounting (Hash[String,String]) (defaults to: {})

    Hash of the different accounting options. This highly depends on the used systemd version. The module provides sane defaults per operating system using Hiera.

  • purge_dropin_dirs (Boolean) (defaults to: true)

    When enabled, unused directories for dropin files will be purged

  • manage_coredump (Boolean) (defaults to: false)

    Should systemd-coredump configuration be managed

  • coredump_settings (Systemd::CoredumpSettings) (defaults to: {})

    Hash of systemd-coredump configurations for coredump.conf

  • coredump_backtrace (Boolean) (defaults to: false)

    Add –backtrace to systemd-coredump call systemd-coredump@.service unit

  • manage_oomd (Boolean) (defaults to: false)

    Should systemd-oomd configuration be managed

  • oomd_ensure (Enum['stopped','running']) (defaults to: 'running')

    The state that the “oomd“ service should be in

  • oomd_settings (Systemd::OomdSettings) (defaults to: {})

    Hash of systemd-oomd configurations for oomd.conf



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'manifests/init.pp', line 186

class systemd (
  Optional[Pattern['^.+\.target$']]                   $default_target = undef,
  Hash[String,String]                                 $accounting = {},
  Hash[String[1],Hash[String[1], Any]]                $service_limits = {},
  Hash[String[1],Hash[String[1], Any]]                $networks = {},
  Hash[String[1],Hash[String[1], Any]]                $timers = {},
  Hash[String[1],Hash[String[1], Any]]                $tmpfiles = {},
  Hash[String[1],Hash[String[1], Any]]                $unit_files = {},
  Boolean                                             $manage_resolved = false,
  Optional[Enum['systemd-resolved']]                  $resolved_package = undef,
  Enum['stopped','running']                           $resolved_ensure = 'running',
  Optional[Variant[Array[String],String]]             $dns = undef,
  Optional[Variant[Array[String],String]]             $fallback_dns = undef,
  Optional[Variant[Array[String],String]]             $domains = undef,
  Optional[Variant[Boolean,Enum['resolve']]]          $llmnr = undef,
  Optional[Variant[Boolean,Enum['resolve']]]          $multicast_dns = undef,
  Optional[Variant[Boolean,Enum['allow-downgrade']]]  $dnssec = undef,
  Variant[Boolean,Enum['yes', 'opportunistic', 'no']] $dnsovertls = false,
  Optional[Variant[Boolean,Enum['no-negative']]]      $cache = undef,
  Optional[Variant[Boolean,Enum['udp','tcp']]]        $dns_stub_listener = undef,
  Optional[Array[String[1]]] $dns_stub_listener_extra = undef,
  Boolean                                             $manage_resolv_conf = true,
  Boolean                                             $use_stub_resolver = false,
  Boolean                                             $manage_networkd = false,
  Enum['stopped','running']                           $networkd_ensure = 'running',
  Optional[String[1]]                                 $networkd_package = undef,
  Boolean                                             $manage_timesyncd = false,
  Enum['stopped','running']                           $timesyncd_ensure = 'running',
  Optional[String[1]]                                 $timesyncd_package = undef,
  Optional[Variant[Array,String]]                     $ntp_server = undef,
  Optional[Variant[Array,String]]                     $fallback_ntp_server = undef,
  Boolean                                             $manage_accounting = false,
  Boolean                                             $purge_dropin_dirs = true,
  Boolean                                             $manage_journald = true,
  Systemd::JournaldSettings                           $journald_settings = {},
  Systemd::MachineInfoSettings                        $machine_info_settings = {},
  Boolean                                             $manage_udevd = false,
  Optional[Variant[Integer,String]]                   $udev_log = undef,
  Optional[Integer]                                   $udev_children_max = undef,
  Optional[Integer]                                   $udev_exec_delay = undef,
  Optional[Integer]                                   $udev_event_timeout = undef,
  Optional[Enum['early', 'late', 'never']]            $udev_resolve_names = undef,
  Optional[Variant[Integer,String]]                   $udev_timeout_signal = undef,
  Boolean                                             $manage_logind = false,
  Systemd::LogindSettings                             $logind_settings = {},
  Boolean                                             $manage_all_network_files = false,
  Stdlib::Absolutepath                                $network_path = '/etc/systemd/network',
  Hash                                                $loginctl_users = {},
  Hash                                                $dropin_files = {},
  Hash                                                $udev_rules = {},
  Boolean                                             $manage_coredump = false,
  Systemd::CoredumpSettings                           $coredump_settings = {},
  Boolean                                             $coredump_backtrace = false,
  Boolean                                             $manage_oomd = false,
  Enum['stopped','running']                           $oomd_ensure = 'running',
  Systemd::OomdSettings                               $oomd_settings = {},
) {
  contain systemd::install

  if $default_target {
    $target = shell_escape($default_target)
    service { $target:
      ensure => 'running',
      enable => true,
    }

    exec { "systemctl set-default ${target}":
      command => "systemctl set-default ${target}",
      unless  => "test $(systemctl get-default) = ${target}",
      path    => $facts['path'],
    }
  }

  $service_limits.each |$service_limit, $service_limit_data| {
    systemd::service_limits { $service_limit:
      * => $service_limit_data,
    }
  }
  $networks.each |$network, $network_data| {
    systemd::network { $network:
      * => $network_data,
    }
  }
  $timers.each |$timer, $timer_data| {
    systemd::timer { $timer:
      * => $timer_data,
    }
  }
  $tmpfiles.each |$tmpfile, $tmpfile_data| {
    systemd::tmpfile { $tmpfile:
      * => $tmpfile_data,
    }
  }
  $unit_files.each |$unit_file, $unit_file_data| {
    systemd::unit_file { $unit_file:
      * => $unit_file_data,
    }
  }

  if $manage_resolved and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-resolved.service'] {
    contain systemd::resolved
    Class['systemd::install'] -> Class['systemd::resolved']
  }

  if $manage_networkd and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-networkd.service'] {
    contain systemd::networkd
    Class['systemd::install'] -> Class['systemd::networkd']
  }

  if $manage_timesyncd and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-timesyncd.service'] {
    contain systemd::timesyncd
  }

  if $manage_udevd {
    contain systemd::udevd
  }

  if $manage_accounting {
    contain systemd::system
  }

  unless empty($machine_info_settings) {
    contain systemd::machine_info
  }

  if $manage_journald {
    contain systemd::journald
  }

  if $manage_logind {
    contain systemd::logind
  }

  if $manage_coredump {
    contain systemd::coredump
  }

  if $manage_oomd {
    contain systemd::oomd
  }

  $dropin_files.each |$name, $resource| {
    systemd::dropin_file { $name:
      * => $resource,
    }
  }
}