Replace a Designate Node
Problem
Environment
Procedure
BEGIN {
SERVER_IP = "<BIND_IP>"
KEY = ""
MASTERS = "<DESIGNATE_NODE_1_IP> port 5354; <DESIGNATE_NODE_2_IP> port 5354;"
RNDC_ADD_CMD = "rndc -s %s addzone %s '%s'<br>"
RNDC_DEL_CMD = "rndc -s %s delzone %s<br>"
}
/^zone/ {
# Remove quotes from zone name
gsub("\"", "", $2)
zone_name = $2
# Iterate over remaining fields. Concatenate into 'zone_data'.
zone_data = ""
for(i=3; i<=NF; i++){
zone_data=zone_data" "$i
}
sub("^ ", "", zone_data)
# Find configured DNS servers
match(zone_data, /( ?([0-9]+.){4}( port [0-9]+);){1,}/, master_servers)
sub("^ ", "", master_servers[0])
# If configured masters do not match desired masters
if (master_servers[0] != MASTERS){
sub(master_servers[0], MASTERS, zone_data)
# Print command to delete zones
printf RNDC_DEL_CMD, SERVER_IP, zone_name
# Print command to add zones
printf RNDC_ADD_CMD, SERVER_IP, zone_name, zone_data
}
}
END {}PreviousUnable to Delete Stacks Stuck in "DELETE_FAILED" StateNextObtain Compute Hosts/Hypervisor Info Using API
Last updated
