# Replace a Designate Node

## Problem

* One or more hosts authorized with the Designate role need to be decommissioned, shutdown, or otherwise replaced.
* If this has already occurred, one or more zones and their respective recordsets may be showing in either **PENDING** or **ERROR** state, depending on how long it's been.

## Environment

* Platform9 Managed OpenStack - All Versions
* Designate

## Procedure

1. Identify the IP address of your BIND server, and also of the Designate host(s) which are to remain or otherwise replace the old hosts.
2. Create a file *update-masters.awk* on the BIND server and populate it with the following content, modifying the bolded variables as per the legend below.

{% tabs %}
{% tab title="None" %}

```none
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 {}
```

{% endtab %}
{% endtabs %}

* **SERVER\_IP** = IP on which the BIND server is listening.
* **MASTERS** = IP(s) of the aforementioned Designate host(s) which will remain to be online and become the active masters.

3. Execute the *awk* script and pipe the stdout to *update\_zones.sh*.

{% tabs %}
{% tab title="None" %}

```none
# awk -f update-masters.awk /var/cache/bind/*.nzf ] update_zones.sh
```

{% endtab %}
{% endtabs %}

4. Set the proper permissions and execute the resulting *update\_zones.sh* script.

{% tabs %}
{% tab title="None" %}

```none
# chmod +x && ./update_zones.sh
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Additional Info**

**Note**: Afterward, it may take approximately 5-10 minutes for the DNS zones to update and reflect an **ACTIVE** status once again. If this does not occur, attempt to create a new DNS record or otherwise create an instance on a provider network or tenant network with a floating IP, either of which would automatically provision a DNS record (based on your Designate configuration). Once a new record is added, the zone and respective recordsets should show **ACTIVE**.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmo/how-to/replace-a-designate-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
