]> gitweb.fluxo.info Git - puppet-bind.git/commitdiff
(bind) initial import
authorCédric Jeanneret <cedric.jeanneret@camptocamp.com>
Mon, 8 Nov 2010 15:15:43 +0000 (16:15 +0100)
committerCédric Jeanneret <cedric.jeanneret@camptocamp.com>
Mon, 15 Nov 2010 13:21:11 +0000 (14:21 +0100)
Doc will be added later.

17 files changed:
files/empty/.placeholder [new file with mode: 0644]
manifests/classes/bind-base.pp [new file with mode: 0644]
manifests/classes/bind-debian.pp [new file with mode: 0644]
manifests/classes/bind.pp [new file with mode: 0644]
manifests/definitions/bind-a.pp [new file with mode: 0644]
manifests/definitions/bind-aaaa.pp [new file with mode: 0644]
manifests/definitions/bind-cname.pp [new file with mode: 0644]
manifests/definitions/bind-mx.pp [new file with mode: 0644]
manifests/definitions/bind-ns.pp [new file with mode: 0644]
manifests/definitions/bind-record.pp [new file with mode: 0644]
manifests/definitions/bind-zone.pp [new file with mode: 0644]
manifests/init.pp [new file with mode: 0644]
templates/default-record.erb [new file with mode: 0644]
templates/mx-record.erb [new file with mode: 0644]
templates/zone-header.erb [new file with mode: 0644]
templates/zone-master.erb [new file with mode: 0644]
templates/zone-slave.erb [new file with mode: 0644]

diff --git a/files/empty/.placeholder b/files/empty/.placeholder
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/manifests/classes/bind-base.pp b/manifests/classes/bind-base.pp
new file mode 100644 (file)
index 0000000..b31189e
--- /dev/null
@@ -0,0 +1,23 @@
+class bind::base {
+  package {"bind9":
+    ensure => present,
+  }
+
+  service {"bind9":
+    ensure  => running,
+    enable  => true,
+    require => Package["bind9"],
+  }
+
+  file {["/etc/bind/pri", "/etc/bind/zones"]:
+    ensure => directory,
+    owner  => root,
+    group  => root,
+    mode   => 0755,
+    require => Package["bind9"],
+    purge   => true,
+    force   => true,
+    recurse => true,
+    source  => "puppet:///modules/bind/empty",
+  }
+}
diff --git a/manifests/classes/bind-debian.pp b/manifests/classes/bind-debian.pp
new file mode 100644 (file)
index 0000000..f998a80
--- /dev/null
@@ -0,0 +1,5 @@
+class bind::debian inherits bind::base {
+  Service["bind9"] {
+    pattern => "/usr/sbin/named",
+  }
+}
diff --git a/manifests/classes/bind.pp b/manifests/classes/bind.pp
new file mode 100644 (file)
index 0000000..dcede05
--- /dev/null
@@ -0,0 +1,6 @@
+class bind {
+  case $operatingsystem {
+    "Debian": { include bind::debian }
+    default: { fail "Unknown $operatingsystem" }
+  }
+}
diff --git a/manifests/definitions/bind-a.pp b/manifests/definitions/bind-a.pp
new file mode 100644 (file)
index 0000000..37153b8
--- /dev/null
@@ -0,0 +1,15 @@
+define bind::a($ensure=present,
+    $zone,
+    $owner,
+    $host,
+    $ttl=false) {
+
+  bind::record {$name:
+    ensure => $ensure,
+    zone   => $zone,
+    owner  => $owner,
+    host   => $host,
+    ttl    => $ttl,
+    record_type => 'A',
+  }
+}
diff --git a/manifests/definitions/bind-aaaa.pp b/manifests/definitions/bind-aaaa.pp
new file mode 100644 (file)
index 0000000..a20a58c
--- /dev/null
@@ -0,0 +1,16 @@
+define bind::aaaa($ensure=present,
+    $zone,
+    $owner,
+    $host,
+    $ttl=false) {
+
+  bind::record {$name:
+    ensure => $ensure,
+    zone   => $zone,
+    owner  => $owner,
+    host   => $host,
+    ttl   => $ttl,
+    record_type => 'AAAA',
+  }
+
+}
diff --git a/manifests/definitions/bind-cname.pp b/manifests/definitions/bind-cname.pp
new file mode 100644 (file)
index 0000000..e166738
--- /dev/null
@@ -0,0 +1,15 @@
+define bind::cname($ensure=present,
+    $zone,
+    $owner,
+    $host,
+    $ttl=false) {
+
+  bind::record {$name:
+    ensure => $ensure,
+    zone   => $zone,
+    owner  => $owner,
+    host   => $host,
+    ttl    => $ttl,
+    record_type => 'CNAME',
+  }
+}
diff --git a/manifests/definitions/bind-mx.pp b/manifests/definitions/bind-mx.pp
new file mode 100644 (file)
index 0000000..7eb63d0
--- /dev/null
@@ -0,0 +1,16 @@
+define bind::mx($ensure=present,
+    $zone,
+    $owner,
+    $priority,
+    $host,
+    $ttl=false) {
+
+  common::concatfilepart{"bind.${name}":
+    file    => "/etc/bind/pri/${zone}",
+    ensure  => $ensure,
+    notify  => Service["bind9"],
+    content => template("bind/mx-record.erb"),
+    require => Bind::Zone[$zone],
+  }
+}
+
diff --git a/manifests/definitions/bind-ns.pp b/manifests/definitions/bind-ns.pp
new file mode 100644 (file)
index 0000000..9919f53
--- /dev/null
@@ -0,0 +1,15 @@
+define bind::ns($ensure=present,
+    $zone,
+    $owner,
+    $host,
+    $ttl=false) {
+
+  bind::record {$name:
+    ensure => $ensure,
+    zone   => $zone,
+    owner  => $owner,
+    host   => $host,
+    ttl    => $ttl,
+    record_type => 'NS',
+  }
+}
diff --git a/manifests/definitions/bind-record.pp b/manifests/definitions/bind-record.pp
new file mode 100644 (file)
index 0000000..5e0cf6f
--- /dev/null
@@ -0,0 +1,14 @@
+define bind::record($ensure=present,
+    $zone,
+    $owner,
+    $host,
+    $record_type,
+    $record_class='IN',
+    $ttl=false) {
+
+  common::concatfilepart {"${zone}.${record_type}.${name}":
+    ensure  => $ensure,
+    file    => "/etc/bind/pri/${zone}.conf",
+    content => template("bind/default-record.erb"),
+  }
+}
diff --git a/manifests/definitions/bind-zone.pp b/manifests/definitions/bind-zone.pp
new file mode 100644 (file)
index 0000000..137bcd8
--- /dev/null
@@ -0,0 +1,58 @@
+define bind::zone($ensure=present,
+    $is_slave=false,
+    $zone_ttl=false,
+    $zone_contact=false,
+    $zone_serial=false,
+    $zone_refresh="3h",
+    $zone_retry="1h",
+    $zone_expiracy="1w",
+    $zone_ns=false,
+    $zone_xfers=false,
+    $zone_masters=false) {
+
+  common::concatfilepart {"bind.zones.${name}":
+    ensure => $ensure,
+    notify => Service["bind9"],
+    file   => "/etc/bind/zones/${name}.conf",
+  }
+
+  common::concatfilepart {"named.local.zone.${name}":
+    ensure  => $ensure,
+    notify  => Service["bind9"],
+    file    => "/etc/bind/named.conf.local",
+    content => "include \"/etc/bind/zones/${name}.conf\";\n",
+  }
+
+  if $is_slave {
+    if !$zone_masters {
+      fail "No master defined for ${name}!"
+    }
+    Common::Concatfilepart["bind.zones.${name}"] {
+      content => template("bind/zone-slave.erb"),
+    }
+## END of slave
+  } else {
+    if !$zone_contact {
+      fail "No contact defined for ${name}!"
+    }
+    if !$zone_ns {
+      fail "No ns defined for ${name}!"
+    }
+    if !$zone_serial {
+      fail "No serial defined for ${name}!"
+    }
+    if !$zone_ttl {
+      fail "No ttl defined for ${name}!"
+    }
+
+    Common::Concatfilepart["bind.zones.${name}"] {
+      content => template("bind/zone-master.erb"),
+    }
+
+    common::concatfilepart {"bind.00.${name}":
+      ensure => $ensure,
+      file   => "/etc/bind/pri/${name}.conf",
+      content => template("bind/zone-header.erb"),
+    }
+  }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644 (file)
index 0000000..6cc1969
--- /dev/null
@@ -0,0 +1,2 @@
+import "classes/*.pp"
+import "definitions/*.pp"
diff --git a/templates/default-record.erb b/templates/default-record.erb
new file mode 100644 (file)
index 0000000..64aa056
--- /dev/null
@@ -0,0 +1,6 @@
+<% if ttl -%>
+<%=owner%> <%=ttl%> <%=record_class%> <%=record_type%> <%=host%>
+<% else -%>
+<%=owner%> <%=record_class%> <%=record_type%> <%=host%>
+<% end -%>
+
diff --git a/templates/mx-record.erb b/templates/mx-record.erb
new file mode 100644 (file)
index 0000000..a8ec89d
--- /dev/null
@@ -0,0 +1,5 @@
+<% if ttl -%>
+<%=owner%> <%=ttl%> IN MX <%=priority%> <%=host%>
+<% else -%>
+<%=owner%> IN MX <%=priority%> <%=host%>
+<% end -%>
diff --git a/templates/zone-header.erb b/templates/zone-header.erb
new file mode 100644 (file)
index 0000000..da93b31
--- /dev/null
@@ -0,0 +1,10 @@
+; File managed by puppet
+$TTL <%=zone_ttl%>
+@ IN SOA <%=name%>. <%=zone_contact%>. (
+      <%=zone_serial%>  ; serial
+      <%=zone_refresh%> ; refresh
+      <%=zone_retry%>   ; retry
+      <%=zone_expiracy%>; expiracy
+      <%=zone_ttl%> )   ; TTL
+      IN NS <%=zone_ns%>.
+
diff --git a/templates/zone-master.erb b/templates/zone-master.erb
new file mode 100644 (file)
index 0000000..d9e88fd
--- /dev/null
@@ -0,0 +1,12 @@
+# File managed by puppet
+zone "<%=name%>" IN {
+  type master;
+  file "/etc/bind/pri/<%=name%>.conf";
+<% if zone_xfers and not zone_xfers.empty? -%>
+  allow-transfer { <%= zone_xfers.collect! {|i| "#{i}" }.join('; ') -%> };
+<% else -%>
+  allow-transfer { none; };
+<% end -%>
+  allow-query { any; };
+  notify yes;
+};
diff --git a/templates/zone-slave.erb b/templates/zone-slave.erb
new file mode 100644 (file)
index 0000000..02364c1
--- /dev/null
@@ -0,0 +1,7 @@
+# File managed by puppet
+zone <%=name%> IN {
+  type slave;
+  masters { <%= masters.collect! {|i| "#{i}" }.join('; ') -%> };
+  allow-query { any; };
+  notify yes;
+}