ns-record + hostmaster
This commit is contained in:
parent
77052cacc4
commit
29f9613cfb
@ -2,11 +2,13 @@
|
|||||||
"zone": {
|
"zone": {
|
||||||
"soa": "eve.dn42.",
|
"soa": "eve.dn42.",
|
||||||
"ns": "eve.dn42.",
|
"ns": "eve.dn42.",
|
||||||
"serial": 93,
|
"serial": 102,
|
||||||
"refresh": "1H",
|
"refresh": "1H",
|
||||||
"retry": "4H",
|
"retry": "4H",
|
||||||
"expire": "3W",
|
"expire": "3W",
|
||||||
"minimum": "1D",
|
"minimum": "1D",
|
||||||
|
"hostmaster": "hostmaster.higgsboson.tk",
|
||||||
|
"domain": "eve.higgsboson.tk",
|
||||||
"v4_subnet": "172.23.75.0/24",
|
"v4_subnet": "172.23.75.0/24",
|
||||||
"v6_subnet": "fdc0:4992:6a6d::/48"
|
"v6_subnet": "fdc0:4992:6a6d::/48"
|
||||||
},
|
},
|
||||||
|
@ -33,14 +33,18 @@ class RdnsZone
|
|||||||
def write_zone_file(root_path)
|
def write_zone_file(root_path)
|
||||||
zone_template = Template.new(root_path.join("templates/rdns-zone.erb"))
|
zone_template = Template.new(root_path.join("templates/rdns-zone.erb"))
|
||||||
rdns_path = root_path.join("zones", name)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
registry = Registry.new
|
registry = Registry.new
|
||||||
|
registry.data["zone"]["serial"] += 1
|
||||||
|
registry.save
|
||||||
|
|
||||||
root_path = Pathname.new(File.expand_path("../..", __FILE__))
|
root_path = Pathname.new(File.expand_path("../..", __FILE__))
|
||||||
zone_template = Template.new(root_path.join("templates/dn42-zone.erb"))
|
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)
|
atomic_write(root_path.join("zones/dn42.zone"), result)
|
||||||
|
|
||||||
if subnet = try(registry.data, "zone", "v4_subnet")
|
if subnet = try(registry.data, "zone", "v4_subnet")
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
@ IN SOA <%= data["zone"]["soa"] %> hostmaster (
|
@ IN SOA <%= zone["soa"] %> <%= zone["hostmaster"] %> (
|
||||||
<%= data["zone"]["serial"] %> ; serial
|
<%= zone["serial"] %> ; serial
|
||||||
<%= data["zone"]["refresh"] %> ; refresh
|
<%= zone["refresh"] %> ; refresh
|
||||||
<%= data["zone"]["retry"] %> ; retry
|
<%= zone["retry"] %> ; retry
|
||||||
<%= data["zone"]["expire"] %> ; expire
|
<%= zone["expire"] %> ; expire
|
||||||
<%= data["zone"]["minimum"] %>) ; minimum
|
<%= zone["minimum"] %>) ; minimum
|
||||||
NS <%= data["zone"]["ns"] %>
|
<% data["network"].each do |name, value| -%>
|
||||||
|
<% if value["ns"] -%>
|
||||||
|
IN NS <%= name %>
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
<% data["network"].each do |name, value| %>
|
<% data["network"].each do |name, value| %>
|
||||||
<% if value["cname"] -%>
|
<% if value["cname"] -%>
|
||||||
|
@ -1,11 +1,27 @@
|
|||||||
@ IN SOA <%= zone["soa"] %> hostmaster (
|
@ IN SOA <%= zone["soa"] %> <%= zone["hostmaster"] %> (
|
||||||
<%= zone["serial"] %> ; serial
|
<%= zone["serial"] %> ; serial
|
||||||
<%= zone["refresh"] %> ; refresh
|
<%= zone["refresh"] %> ; refresh
|
||||||
<%= zone["retry"] %> ; retry
|
<%= zone["retry"] %> ; retry
|
||||||
<%= zone["expire"] %> ; expire
|
<%= zone["expire"] %> ; expire
|
||||||
<%= zone["minimum"] %>) ; minimum
|
<%= 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| %>
|
<% zone.pointers do |name, host_part| %>
|
||||||
<%= host_part %> PTR <%= name %>.dn42.higgsboson.tk
|
<%= host_part %> PTR <%= name %>.<%= zone["domain"] %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
Loading…
Reference in New Issue
Block a user