lxc-zone: handle SRV-records
This commit is contained in:
parent
acf532809a
commit
655cdbb427
@ -21,7 +21,6 @@ def atomic_write(path, content)
|
|||||||
FileUtils.mv(temp_path, path)
|
FileUtils.mv(temp_path, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
class ZoneData
|
class ZoneData
|
||||||
def initialize(data)
|
def initialize(data)
|
||||||
@data = data
|
@data = data
|
||||||
@ -59,26 +58,30 @@ class RdnsData
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
json = JSON.load(File.open(CONTAINER_DATA))
|
def main
|
||||||
json["zone"]["serial"] += 1
|
json = JSON.load(File.open(CONTAINER_DATA))
|
||||||
|
json["zone"]["serial"] += 1
|
||||||
|
|
||||||
rdns_zone_template = File.read(TEMPLATE_PATH.join("rdns-zone.erb"))
|
rdns_zone_template = File.read(TEMPLATE_PATH.join("rdns-zone.erb"))
|
||||||
zone_data = ZoneData.new(json)
|
zone_data = ZoneData.new(json)
|
||||||
|
|
||||||
lxc_zone_template = File.read(TEMPLATE_PATH.join("lxc-zone.erb"))
|
lxc_zone_template = File.read(TEMPLATE_PATH.join("lxc-zone.erb"))
|
||||||
zone = ERB.new(lxc_zone_template, nil, '-').result(zone_data.get_binding)
|
zone = ERB.new(lxc_zone_template, nil, '-').result(zone_data.get_binding)
|
||||||
|
|
||||||
v4_subnet = NetAddr::CIDR.create(json["zone"]["v4_subnet"])
|
v4_subnet = NetAddr::CIDR.create(json["zone"]["v4_subnet"])
|
||||||
v4_rdns_path = ZONE_PATH.join(v4_subnet.arpa.gsub(/\.$/, ""))
|
v4_rdns_path = ZONE_PATH.join(v4_subnet.arpa.gsub(/\.$/, ""))
|
||||||
v4_rdns_zone = ERB.new(rdns_zone_template, nil, '-').result(RdnsData.new(json, v4_subnet).get_binding)
|
v4_rdns_zone = ERB.new(rdns_zone_template, nil, '-').result(RdnsData.new(json, v4_subnet).get_binding)
|
||||||
|
|
||||||
v6_subnet = NetAddr::CIDR.create(json["zone"]["v6_subnet"])
|
v6_subnet = NetAddr::CIDR.create(json["zone"]["v6_subnet"])
|
||||||
v6_rdns_path = ZONE_PATH.join(v6_subnet.arpa.gsub(/\.$/, ""))
|
v6_rdns_path = ZONE_PATH.join(v6_subnet.arpa.gsub(/\.$/, ""))
|
||||||
v6_rdns_zone = ERB.new(rdns_zone_template, nil, '-').result(RdnsData.new(json, v6_subnet).get_binding)
|
v6_rdns_zone = ERB.new(rdns_zone_template, nil, '-').result(RdnsData.new(json, v6_subnet).get_binding)
|
||||||
|
|
||||||
atomic_write(LXC_ZONE, zone)
|
atomic_write(LXC_ZONE, zone)
|
||||||
atomic_write(v4_rdns_path, v4_rdns_zone)
|
atomic_write(v4_rdns_path, v4_rdns_zone)
|
||||||
atomic_write(v6_rdns_path, v6_rdns_zone)
|
atomic_write(v6_rdns_path, v6_rdns_zone)
|
||||||
atomic_write(CONTAINER_DATA, JSON.pretty_generate(json))
|
atomic_write(CONTAINER_DATA, JSON.pretty_generate(json))
|
||||||
|
|
||||||
system("lxc-attach", "-e", "-n", DNS_CONTAINER, "--", "rec_control", "reload-zones")
|
system("lxc-attach", "-e", "-n", DNS_CONTAINER, "--", "rec_control", "reload-zones")
|
||||||
|
end
|
||||||
|
|
||||||
|
main
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
<% if value["cname"] -%>
|
<% if value["cname"] -%>
|
||||||
<%= name %> CNAME <%= value["cname"] %>
|
<%= name %> CNAME <%= value["cname"] %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
<% if value["srv"] -%>
|
||||||
|
<%= name %> SRV <%= value["srv"] %>
|
||||||
|
<% end -%>
|
||||||
<% if value["ipv4"] -%>
|
<% if value["ipv4"] -%>
|
||||||
<%= name %> A <%= ip(value["ipv4"]) %>
|
<%= name %> A <%= ip(value["ipv4"]) %>
|
||||||
ipv4.<%= name %> A <%= ip(value["ipv4"]) %>
|
ipv4.<%= name %> A <%= ip(value["ipv4"]) %>
|
||||||
|
Loading…
Reference in New Issue
Block a user