Puppet Function: bind::zonefile_path

Defined in:
functions/zonefile_path.pp
Function type:
Puppet Language

Summary

Generate the zonefile name from zone

Overview

bind::zonefile_path(String $zone, Optional[String] $view = '')String

Parameters:

  • zone (String)

    The name of the zone for which the path should be returned. Example: ‘example.com’

  • view (Optional[String]) (defaults to: '')

    Optional The name of the view for which the path should be returned. Example: ‘internal’

Returns:

  • (String)

    The relative path and filename where the zonefile should be stored. Example: ‘com/example/db.example.com_internal’



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'functions/zonefile_path.pp', line 17

function bind::zonefile_path(String $zone, Optional[String] $view = '') >> String {
  $names = split($zone, '[.]')

  if (length($names) > 1) {
    $tld = $names[-1]
    $dom = $names[-2]

    $dir = "${tld}/${dom}"
    $part = $tld ? {
      'arpa'  => join(reverse($names[0, -3]), '.'),
      default => $zone,
    }
  }
  else {
    $dir = $zone
    $part = $zone
  }

  ($view =~ NotUndef and $view != '') ? {
    true    => "${dir}/db.${part}_${view}",
    default => "${dir}/db.${part}",
  }
}