ipam: a subnet domain names records only inside the authority's zone
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2706fd65e7
commit
9a11d03567
3 files changed
+13
-8
No files matched your search
@@ -511,7 +511,7 @@ address Rollcall hands out is registered there first:
|
||||
Rollcall-owned records that are no longer in use deleted.
|
||||
- **DNS follows the record.** `dns_name` is `<host>.<zone>` for a machine's
|
||||
provisioning/mgmt address and `<host>-<iface>.<zone>` elsewhere (a subnet's
|
||||
`domain` overrides the zone). A NetBox-to-DNS sync (PowerDNS here, a host
|
||||
`domain` replaces the zone when it lies inside it; `pxe.local` stays local). A NetBox-to-DNS sync (PowerDNS here, a host
|
||||
record on Infoblox) publishes it; Rollcall writes one object per address.
|
||||
- **Prefixes are delegated in NetBox.** Tag a prefix `rollcall`;
|
||||
`rollcall ipam prefixes` lists them and `rollcall ipam import` creates the
|
||||
|
||||
@@ -150,17 +150,20 @@ func (a *App) extFor(x IPAddr, sn *Subnet) extAddr {
|
||||
}
|
||||
|
||||
// extDNSName: the machine's main address gets <host>.<zone>; addresses on
|
||||
// other subnets (storage, IB, a tagged VLAN) get <host>-<iface>.<zone>.
|
||||
// other subnets (storage, IB, a tagged VLAN) get <host>-<iface>.<zone>. A
|
||||
// subnet's domain replaces the zone when it lies inside it.
|
||||
func (a *App) extDNSName(x IPAddr, sn *Subnet) string {
|
||||
zone := a.cfg.IPAM.DNSZone
|
||||
if sn != nil && sn.Domain != "" {
|
||||
zone = sn.Domain
|
||||
zone := strings.TrimSuffix(strings.ToLower(a.cfg.IPAM.DNSZone), ".")
|
||||
if sn != nil && sn.Domain != "" { // a subnet domain counts only inside the authority's zone; "pxe.local" stays local
|
||||
d := strings.TrimSuffix(strings.ToLower(sn.Domain), ".")
|
||||
if zone == "" || d == zone || strings.HasSuffix(d, "."+zone) {
|
||||
zone = d
|
||||
}
|
||||
}
|
||||
host := strings.ToLower(strings.TrimSuffix(x.Hostname, "."))
|
||||
if zone == "" || host == "" {
|
||||
return ""
|
||||
}
|
||||
zone = strings.TrimSuffix(strings.ToLower(zone), ".")
|
||||
if strings.HasSuffix(host, "."+zone) {
|
||||
return host
|
||||
}
|
||||
|
||||
@@ -140,7 +140,8 @@ func testIPAM(t *testing.T) (*App, *fakeNetBox) {
|
||||
a.subnets = []Subnet{
|
||||
{CIDR: "10.213.77.0/24", Purpose: "provisioning"},
|
||||
{CIDR: "10.213.79.0/24", Purpose: "storage"},
|
||||
{CIDR: "10.213.78.0/24", Purpose: "provisioning", Domain: "hall-b.example"},
|
||||
{CIDR: "10.213.78.0/24", Purpose: "provisioning", Domain: "hall-b.int.example"},
|
||||
{CIDR: "10.213.76.0/24", Purpose: "provisioning", Domain: "pxe.local"},
|
||||
}
|
||||
return a, f
|
||||
}
|
||||
@@ -154,7 +155,8 @@ func TestIPAMDNSNames(t *testing.T) {
|
||||
}{
|
||||
{IPAddr{IP: "10.213.77.50", Subnet: "10.213.77.0/24", Hostname: "node001", Iface: "bond0"}, "node001.int.example"},
|
||||
{IPAddr{IP: "10.213.79.50", Subnet: "10.213.79.0/24", Hostname: "node001", Iface: "bond0.200"}, "node001-bond0-200.int.example"},
|
||||
{IPAddr{IP: "10.213.78.50", Subnet: "10.213.78.0/24", Hostname: "Node002"}, "node002.hall-b.example"},
|
||||
{IPAddr{IP: "10.213.78.50", Subnet: "10.213.78.0/24", Hostname: "Node002"}, "node002.hall-b.int.example"},
|
||||
{IPAddr{IP: "10.213.76.50", Subnet: "10.213.76.0/24", Hostname: "node003", Iface: "eth0"}, "node003.int.example"},
|
||||
{IPAddr{IP: "10.213.77.5", Subnet: "10.213.77.0/24", Hostname: "core switch", Kind: "reserved"}, ""},
|
||||
{IPAddr{IP: "10.213.77.6", Subnet: "10.213.77.0/24", Kind: "reserved"}, ""},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user