1
2
3
4
5
6
7
8
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
|
# @summary Systemd Networkd network provider
#
# Networkd is rather nice to work with, since it relies heavily on different files.
#
# @see systemd-networkd(8)
# An introduction to how networkd works.
#
# @param notify_
# Should the network daemon be reloaded when things changes. This is
# most likely a transient setting as part of the development, since
# currently things can self-destruct if not carefull.
# @param manage_directory
# If enabled, then the directory mentioned by `path` will both be
# created, and purged by this module.
#
# TODO this should be split into two:
# - Manage directory existance
# - Purge directory
# @param path
# Directory in which network and netdev files will be placed.
#
# The following directories are the default search paths for Networkd,
# so it's recommended to chose one of them:
#
# - `/usr/lib/systemd/network`
# - `/usr/local/lib/systemd/network`
# - `/run/systemd/network`
# - `/etc/systemd/network`
class networking::networkd (
Boolean $notify_ = true,
Boolean $manage_directory = true,
String $path = '/etc/systemd/network',
) {
if $manage_directory {
file { $path:
ensure => directory,
purge => true,
recurse => true,
}
}
# Force a full restart of systemd networkd to reload all configuration.
# The alternative is to first run `networkctl reload` which reloads
# network files, followed by a `networkctl reconfigure <iface>`.
#
# When this was writen, I didn't realize that a reload +
# reconfigure was required. Note that old configurations might
# lingerif done that way.
if $notify_ {
exec { 'reload networkd':
command => 'systemctl reload-or-restart systemd-networkd',
path => ['/bin', '/usr/bin',],
refreshonly => true,
}
}
service { 'systemd-networkd':
ensure => running,
enable => true,
}
}
|