30 lines
1.0 KiB
Markdown
30 lines
1.0 KiB
Markdown
# Standby Hostname & OS Renaming
|
|
|
|
After deploying the standby watchdog script, also rename the standby's OS to match its DNS name.
|
|
|
|
## On the standby box
|
|
|
|
```bash
|
|
hostnamectl set-hostname app1-bu.itpropartner.com
|
|
```
|
|
|
|
Verify with both `hostname` and `hostname -f`.
|
|
|
|
## Also rename in the cloud provider API
|
|
|
|
The cloud provider labels (Hetzner Cloud Console, API `server.name`) and the OS hostname are separate. Update both:
|
|
|
|
```python
|
|
import urllib.request, json
|
|
headers = {'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'}
|
|
data = json.dumps({"name": "app1-bu.itpropartner.com"})
|
|
req = urllib.request.Request(f'https://api.hetzner.cloud/v1/servers/{SERVER_ID}', data=data.encode(), headers=headers, method='PUT')
|
|
urllib.request.urlopen(req, timeout=10)
|
|
```
|
|
|
|
## Why this matters
|
|
|
|
- The DNS A record, the cloud provider name, and the OS hostname should all agree
|
|
- Scripts that check `hostname` for routing decisions won't break
|
|
- The DR documentation references the DNS name — matching OS hostname reduces confusion during failover
|