NM resolve prepender:  Update for systemd-resolved logic
remove OS check.  If node has systemd-resolved enabled this will work
Check to see if systemd-resolved is enabled.  Otherwise skip
Check if /etc/systemd/resolved.conf.d/60-kni.conf exists.  If it doesn't create it and restart systemd-resolved if active
Add logging
@@ -52,11 +52,18 @@ contents:
"{{ onPremPlatformIngressIP . }}")
DOMAIN="{{.DNS.Spec.BaseDomain}}"
if [[ -n "$NAMESERVER_IP" ]]; then
- source /etc/os-release
- if [[ "$NAME" == "Fedora" ]]; then
+ if [[ "$(systemctl is-enabled systemd-resolved)" == "enabled" ]]; then
+ >&2 echo "NM resolv-prepender: Setting up systemd-resolved for OKD domain and local IP"
+ if [[ ! -f /etc/systemd/resolved.conf.d/60-kni.conf ]]; then
+ >&2 echo "NM resolv-prepender: Creating /etc/systemd/resolved.conf.d/60-kni.conf"
echo "[Resolve]" > /etc/systemd/resolved.conf.d/60-kni.conf
echo "DNS=$NAMESERVER_IP" >> /etc/systemd/resolved.conf.d/60-kni.conf
echo "Domains=$DOMAIN" >> /etc/systemd/resolved.conf.d/60-kni.conf
+ if [[ "$(systemctl is-active systemd-resolved)" == "active" ]]; then
+ >&2 echo "NM resolv-prepender: restarting systemd-resolved"
+ systemctl restart systemd-resolved
+ fi
+ fi
else
>&2 echo "NM resolv-prepender: Prepending 'nameserver $NAMESERVER_IP' to /etc/resolv.conf (other nameservers from /var/run/NetworkManager/resolv.conf)"
sed -e "/^search/d" \
