summaryrefslogtreecommitdiff
path: root/manifests/networkd_instance.pp
blob: cbad0a2f9ba2e98f5f2a1fa660fc6436ad0a9b19 (plain)
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
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,
  Enum['network', 'netdev', 'link'] $type = 'network',
  String $real_filename = "${priority}-${filename}.${type}",
  String $file = "${path}/${real_filename}",
  Optional[String] $mode = undef,
) {
  file { $file:
    ensure  => $ensure,
    owner   => 'systemd-network',
    mode    => $mode,
    content => epp('networking/unit_file.epp', {
        # Keys are unit file sections
        # Values are list of section content, so
        # {
        #   'Section' => [
        #     {
        #       'key': 'value',
        #       'mvalued': ['v1', 'v2'],
        #     }
        #   ]
        # }
        # [Section]
        # key=value
        # mvalued=v1
        # mvalued=v2
        data  => networking::repack($content),
    }),
    notify  => if $networking::networkd::notify_ { Exec['reload networkd'] } else { [] },
  }
}