theforeman/foreman_maintain

Procedure: isc dhcp configuration check

Closed this issue · 3 comments

lzap commented

Manual edits in ISC DHCP often lead to "Cannot add Subnet" error or other parsing issues as our parser is very limited. This procedure (should not be really check but a "command" you can run when needed) would do this (tested on Satellite 6.1+):

#!/bin/bash
curl -ks --cert /etc/foreman/client_cert.pem --key /etc/foreman/client_key.pem --cacert /etc/foreman/proxy_ca.pem https://$(hostname):9090/dhcp
dhcpd -t -cf /etc/dhcp/dhcpd.conf

The first command returns JSON of subnet data, error message otherwise. The second is syntax check of ISC, returns some text (always), we need check the return value instead.

lzap commented

More info at: https://access.redhat.com/solutions/2988341

We can implement the same for DNS.

Also note that certificate paths are different on Server and Katello-Proxy (Capsule), take that into account. When implementing this check, we should not use CURL but directly require parsing API from smart-proxy in order to catch exceptions.

I'm not sure requiring the parser code from proxy is such a good idea: this can get messy pretty quickly

lzap commented

Then just a curl test and testing if that's HTTP 200 is fine, but it will not catch missing subnets. Alternatively there could be external script in smart-proxy with proper unit tests that could be called instead of requiring, that would be cleanest.

Note, I see that certificates are hardcoded in your patch, but the paths are different on Satellite Server and Capsule! I hope maintain will work on Capsule too.