Defined Type: systemd::network

Defined in:
manifests/network.pp

Summary

Creates network config for systemd-networkd

Overview

Parameters:

  • ensure (Enum['file', 'absent']) (defaults to: file)

    configure if the file should be configured or deleted

  • path (Stdlib::Absolutepath) (defaults to: '/etc/systemd/network')

    directory where the network configs are stored

  • content (Optional[String]) (defaults to: undef)

    the content of the file

  • source (Optional[String]) (defaults to: undef)

    a path to a file that’s used as source

  • target (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    optional absolute path in case the file should be stored somewhere else

  • owner (String) (defaults to: 'root')

    the user who owns the file

  • group (String) (defaults to: 'root')

    the group that owns the file

  • mode (String) (defaults to: '0444')

    the mode of the file

  • show_diff (Boolean) (defaults to: true)

    whether the file diff should be shown on modifications

  • restart_service (Boolean) (defaults to: true)

    whether systemd-networkd should be restarted on changes, defaults to true. ‘$systemd::manage_networkd` needs to be true as well

Author:

  • Tim Meusel <tim@bastelfreak.de>



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
# File 'manifests/network.pp', line 15

define systemd::network (
  Enum['file', 'absent']         $ensure          = file,
  Stdlib::Absolutepath           $path            = '/etc/systemd/network',
  Optional[String]               $content         = undef,
  Optional[String]               $source          = undef,
  Optional[Stdlib::Absolutepath] $target          = undef,
  String                         $owner           = 'root',
  String                         $group           = 'root',
  String                         $mode            = '0444',
  Boolean                        $show_diff       = true,
  Boolean                        $restart_service = true,
) {
  include systemd

  if $restart_service and $systemd::manage_networkd and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-networkd.service'] {
    $notify = Service['systemd-networkd']
  } else {
    $notify = undef
  }

  if $ensure == 'file' {
    if $content =~ Undef and $source =~ Undef {
      fail('Either content or source must be set')
    }
    if $content =~ NotUndef and $source =~ NotUndef {
      fail('Either content or source must be set but not both')
    }
  }
  file { "${path}/${name}":
    ensure    => $ensure,
    content   => $content,
    source    => $source,
    target    => $target,
    owner     => $owner,
    group     => $group,
    mode      => $mode,
    show_diff => $show_diff,
    notify    => $notify,
  }
}