summaryrefslogtreecommitdiff
path: root/manifests/networkd_instance.pp
blob: 8a2693d82dc9c59c646110243374ffd6dc40ee82 (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
36
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 { [] },
  }
}