summaryrefslogtreecommitdiff
path: root/manifests/a.pp
blob: d457413bcd8c2480e7e562dd879794ed8e24c0f7 (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
37
38
39
40
41
42
43
# = Definition: bind::a
#
# Creates an IPv4 record.
#
# Arguments:
# *$zone*:  Bind::Zone name
# *$owner*: owner of the Resource Record
# *$host*:  target of the Resource Record
# *$ttl*:   Time to Live for the Resource Record. Optional.
# *$ptr*:   create the corresponding ptr record (default=false)
#
#
define bind::a(
  $zone,
  $host,
  $ensure = present,
  $owner  = false,
  $ttl    = false,
  $ptr    = false
) {

  bind::record {$name:
    ensure      => $ensure,
    zone        => $zone,
    owner       => $owner,
    host        => $host,
    ttl         => $ttl,
    record_type => 'A',
  }

  if $ptr {
    $arpa      = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse %>")
    $arpa_zone = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse.split('.')[1..-1].join('.') %>")

    bind::ptr {"${arpa}.":
      ensure => $ensure,
      zone   => $arpa_zone,
      host   => $name,
      ttl    => $ttl,
    }
  }

}