Align NOMAD Pi-hole replica with stack SOP

This commit is contained in:
Fizzlepoof
2026-05-15 15:43:17 +00:00
parent 6278191614
commit e5de7c532d
5 changed files with 19 additions and 12 deletions

View File

@@ -27,22 +27,27 @@ def main() -> int:
env = load_env(ENV_FILE)
required = [
'LAN_INTERFACE', 'VIP_CIDR', 'KEEPALIVED_ROUTER_ID', 'KEEPALIVED_STATE',
'KEEPALIVED_PRIORITY', 'KEEPALIVED_PASSWORD', 'PD_PIHOLE_WEB_PORT'
'KEEPALIVED_PRIORITY', 'KEEPALIVED_PASSWORD'
]
missing = [k for k in required if not env.get(k)]
if missing:
print(f'Missing required vars in {ENV_FILE}: {", ".join(missing)}', file=sys.stderr)
return 1
web_port = env.get('PIHOLE_WEB_PORT') or env.get('PD_PIHOLE_WEB_PORT') or env.get('SERENITY_PIHOLE_WEB_PORT') or env.get('RPI4_PIHOLE_WEB_PORT')
if not web_port:
print('Missing Pi-hole web port in .env (set PIHOLE_WEB_PORT or node-specific port variable).', file=sys.stderr)
return 1
keepalived_password = env['KEEPALIVED_PASSWORD']
if len(keepalived_password) > 8:
print('KEEPALIVED_PASSWORD must be 8 characters or fewer for VRRP PASS auth.', file=sys.stderr)
return 1
try:
web_port_hex = f"{int(env['PD_PIHOLE_WEB_PORT']):04X}"
web_port_hex = f"{int(web_port):04X}"
except ValueError:
print('PD_PIHOLE_WEB_PORT must be an integer.', file=sys.stderr)
print('Pi-hole web port must be an integer.', file=sys.stderr)
return 1
router_id_name = f"pihole_{re.sub(r'[^a-z0-9]+', '_', env['KEEPALIVED_STATE'].lower())}"
@@ -55,6 +60,7 @@ def main() -> int:
'NOPREEMPT_LINE': nopreempt_line,
}
replacements.update({k: env[k] for k in required})
replacements['PIHOLE_WEB_PORT'] = web_port
for key, value in replacements.items():
rendered = rendered.replace('${' + key + '}', value)

View File

@@ -1,6 +1,7 @@
TZ=America/Chicago
APPDATA_PIHOLE_ROOT=/mnt/hdd-2/docker/appdata/pihole-nomad
APPDATA_UNBOUND_ROOT=/mnt/hdd-2/docker/appdata/unbound-nomad
APPDATA_PIHOLE_ROOT=/mnt/docker-ssd/docker/appdata/pihole-nomad
APPDATA_UNBOUND_ROOT=/mnt/docker-ssd/docker/appdata/unbound-nomad
PIHOLE_WEB_PORT=8954
NOMAD_PIHOLE_WEB_PORT=8954
PIHOLE_PASSWORD=CHANGE_ME
LAN_INTERFACE=enp5s0

View File

@@ -1,7 +1,7 @@
# NOMAD Pi-hole / Unbound / Keepalived Replica
- **Repo stack path:** `/home/fizzlepoof/repos/truenas-stacks/pihole/nomad`
- **Suggested live stack path:** `/mnt/hdd-1/docker/compose/pihole-nomad`
- **Suggested live stack path:** `/mnt/docker-ssd/docker/compose/pihole-nomad`
- **Node role:** NOMAD backup / BACKUP1
- **VIP target:** `10.5.1.53/24`
- **LAN interface:** `enp5s0`
@@ -10,7 +10,7 @@
Bring-up:
```bash
cd /mnt/hdd-1/docker/compose/pihole-nomad
cd /mnt/docker-ssd/docker/compose/pihole-nomad
cp .env.example .env
bash bin/prepare_nomad.sh --up
```

View File

@@ -34,7 +34,7 @@ def main() -> int:
print(f'Missing required vars in {ENV_FILE}: {", ".join(missing)}', file=sys.stderr)
return 1
web_port = env.get('PIHOLE_WEB_PORT') or env.get('PD_PIHOLE_WEB_PORT') or env.get('SERENITY_PIHOLE_WEB_PORT') or env.get('RPI4_PIHOLE_WEB_PORT')
web_port = env.get('PIHOLE_WEB_PORT') or env.get('PD_PIHOLE_WEB_PORT') or env.get('NOMAD_PIHOLE_WEB_PORT') or env.get('SERENITY_PIHOLE_WEB_PORT') or env.get('RPI4_PIHOLE_WEB_PORT')
if not web_port:
print('Missing Pi-hole web port in .env (set PIHOLE_WEB_PORT or node-specific port variable).', file=sys.stderr)
return 1