# @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 `. # # 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, } }