summaryrefslogtreecommitdiff
path: root/manifests/networkd_instance.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/networkd_instance.pp')
-rw-r--r--manifests/networkd_instance.pp71
1 files changed, 67 insertions, 4 deletions
diff --git a/manifests/networkd_instance.pp b/manifests/networkd_instance.pp
index cbad0a2..8e732a2 100644
--- a/manifests/networkd_instance.pp
+++ b/manifests/networkd_instance.pp
@@ -1,11 +1,74 @@
+# @summary A single systemd-networkd configuration
+#
+# @example A simple instanciation
+# networking::networkd_instance { 'br0':
+# type => 'network',
+# content => {
+# 'Match' => {
+# 'Name' => 'br0',
+# },
+# 'Network' => {
+# 'Address' => [
+# '10.0.0.1/24',
+# '10.0.0.2/24',
+# ],
+# },
+# }
+# }
+#
+# @example The generated content form the above example
+# [Match]
+# Name=br0
+#
+# [Network]
+# Address=10.0.0.1/24
+# Address=10.0.0.2/24
+#
+# @see systemd.network(5)
+# For valid options in network files.
+# @see systemd.netdev(5)
+# For valid options in netdev files.
+# @see systemd.link(5)
+# For valid options in link files.
+#
+# @param content
+# Complete content which will be used to generate the unit file.
+# Each top level key is a section, while each sub key is a direct
+# option name. If the value of an option is a list, then multiple
+# instances of that option will be created. If an inline list is
+# required then the strings must be joined beforehand.
+#
+# If multiple instances of a section is required, then a list of
+# hashes can instead be given as the top level value.
+#
+# TODO reword the above text
+# @param ensure
+# @param path
+# Path to base directory in which unit files will be placed.
+# @param filename
+# Part of the local filename. Will be used to create human readable
+# unit file names.
+# @param priority
+# Relative priority when loading files.
+# @param type
+# If it's a network, netdev, or link file.
+# @param real_filename
+# The final (local) filename. usefull when you *really* need to set a
+# specific filename.
+# @param file
+# Absolute path to generated file, usefull you ***REALLY*** need to
+# change a specific file.
+# @param mode
+# Passed along to the generated file. Networkd requires that files
+# containing secrets are non-world readable.
define networking::networkd_instance (
Hash[String,Variant[Hash,Array[Hash]]] $content,
Enum['present','absent'] $ensure = 'present',
String $path = $networking::networkd::path,
String $filename = $name,
- Integer $priority = 20,
+ Integer[0, 99] $priority = 20,
Enum['network', 'netdev', 'link'] $type = 'network',
- String $real_filename = "${priority}-${filename}.${type}",
+ String $real_filename = "${sprintf('%02d', priority)}-${filename}.${type}",
String $file = "${path}/${real_filename}",
Optional[String] $mode = undef,
) {
@@ -13,7 +76,7 @@ define networking::networkd_instance (
ensure => $ensure,
owner => 'systemd-network',
mode => $mode,
- content => epp('networking/unit_file.epp', {
+ content => epp("${module_name}/unit_file.epp", {
# Keys are unit file sections
# Values are list of section content, so
# {
@@ -28,7 +91,7 @@ define networking::networkd_instance (
# key=value
# mvalued=v1
# mvalued=v2
- data => networking::repack($content),
+ data => networking::repack($content),
}),
notify => if $networking::networkd::notify_ { Exec['reload networkd'] } else { [] },
}