ns-record + hostmaster

This commit is contained in:
Jörg Thalheim 2015-01-26 10:05:29 +01:00
parent 77052cacc4
commit 29f9613cfb
4 changed files with 39 additions and 13 deletions

View File

@ -2,11 +2,13 @@
"zone": {
"soa": "eve.dn42.",
"ns": "eve.dn42.",
"serial": 93,
"serial": 102,
"refresh": "1H",
"retry": "4H",
"expire": "3W",
"minimum": "1D",
"hostmaster": "hostmaster.higgsboson.tk",
"domain": "eve.higgsboson.tk",
"v4_subnet": "172.23.75.0/24",
"v6_subnet": "fdc0:4992:6a6d::/48"
},

View File

@ -33,14 +33,18 @@ class RdnsZone
def write_zone_file(root_path)
zone_template = Template.new(root_path.join("templates/rdns-zone.erb"))
rdns_path = root_path.join("zones", name)
atomic_write(rdns_path, zone_template.render(zone: self))
atomic_write(rdns_path, zone_template.render(zone: self, data: data))
end
end
registry = Registry.new
registry.data["zone"]["serial"] += 1
registry.save
root_path = Pathname.new(File.expand_path("../..", __FILE__))
zone_template = Template.new(root_path.join("templates/dn42-zone.erb"))
result = zone_template.render(data: registry.data)
zone = registry.data["zone"] || {}
result = zone_template.render(data: registry.data, zone: zone)
atomic_write(root_path.join("zones/dn42.zone"), result)
if subnet = try(registry.data, "zone", "v4_subnet")

View File

@ -1,10 +1,14 @@
@ IN SOA <%= data["zone"]["soa"] %> hostmaster (
<%= data["zone"]["serial"] %> ; serial
<%= data["zone"]["refresh"] %> ; refresh
<%= data["zone"]["retry"] %> ; retry
<%= data["zone"]["expire"] %> ; expire
<%= data["zone"]["minimum"] %>) ; minimum
NS <%= data["zone"]["ns"] %>
@ IN SOA <%= zone["soa"] %> <%= zone["hostmaster"] %> (
<%= zone["serial"] %> ; serial
<%= zone["refresh"] %> ; refresh
<%= zone["retry"] %> ; retry
<%= zone["expire"] %> ; expire
<%= zone["minimum"] %>) ; minimum
<% data["network"].each do |name, value| -%>
<% if value["ns"] -%>
IN NS <%= name %>
<% end -%>
<% end -%>
<% data["network"].each do |name, value| %>
<% if value["cname"] -%>

View File

@ -1,11 +1,27 @@
@ IN SOA <%= zone["soa"] %> hostmaster (
@ IN SOA <%= zone["soa"] %> <%= zone["hostmaster"] %> (
<%= zone["serial"] %> ; serial
<%= zone["refresh"] %> ; refresh
<%= zone["retry"] %> ; retry
<%= zone["expire"] %> ; expire
<%= zone["minimum"] %>) ; minimum
NS <%= zone["ns"] %>
<% data["network"].each do |name, value| -%>
<% if value["ns"] -%>
IN NS <%= name %>
<% end -%>
<% end -%>
<% data["network"].each do |name, value| -%>
<% if value["ns"] -%>
<% if value["ipv4"] -%>
<%= name %> A <%= ip(value["ipv4"]) %>
<% end -%>
<% if value["ipv6"] -%>
<%= name %> AAAA <%= ip(value["ipv6"]) %>
<% end -%>
<% end -%>
<% end -%>
<% zone.pointers do |name, host_part| %>
<%= host_part %> PTR <%= name %>.dn42.higgsboson.tk
<%= host_part %> PTR <%= name %>.<%= zone["domain"] %>
<% end -%>