From 80c458bfe9ac5f7fb7db6c83a223a36ed54736eb Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 23 Jan 2020 14:59:35 -0500 Subject: [PATCH] baremetal: Fix bootstrap local DNS for IPv6 This was previously done with an option to dhclient, but this doesn't work when doing DHCPv6. Switch to a script run by NetworkManager to do the same thing. This matches the same approach moved to by the MCO in this PR: https://github.com/openshift/machine-config-operator/pull/1396 --- .../dispatcher.d/30-local-dns-prepender | 20 +++++++++++++++++++ .../baremetal/files/etc/dhcp/dhclient.conf | 7 ------- pkg/asset/ignition/bootstrap/bootstrap.go | 3 ++- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100755 data/data/bootstrap/baremetal/files/etc/NetworkManager/dispatcher.d/30-local-dns-prepender delete mode 100644 data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf diff --git a/data/data/bootstrap/baremetal/files/etc/NetworkManager/dispatcher.d/30-local-dns-prepender b/data/data/bootstrap/baremetal/files/etc/NetworkManager/dispatcher.d/30-local-dns-prepender new file mode 100755 index 00000000000..307e86ae696 --- /dev/null +++ b/data/data/bootstrap/baremetal/files/etc/NetworkManager/dispatcher.d/30-local-dns-prepender @@ -0,0 +1,20 @@ +#!/bin/bash +IFACE=$1 +STATUS=$2 +case "$STATUS" in + up) + logger -s "NM local-dns-prepender triggered by ${1} ${2}." + DNS_IP="127.0.0.1" + set +e + logger -s "NM local-dns-prepender: Checking if local DNS IP is the first entry in resolv.conf" + if grep nameserver /etc/resolv.conf | head -n 1 | grep -q "$DNS_IP" ; then + logger -s "NM local-dns-prepender: local DNS IP already is the first entry in resolv.conf" + exit 0 + else + logger -s "NM local-dns-prepender: Looking for '# Generated by NetworkManager' in /etc/resolv.conf to place 'nameserver $DNS_IP'" + sed -i "/^# Generated by.*$/a nameserver $DNS_IP" /etc/resolv.conf + fi + ;; + *) + ;; +esac diff --git a/data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf b/data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf deleted file mode 100644 index f46c0f6cc10..00000000000 --- a/data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf +++ /dev/null @@ -1,7 +0,0 @@ -# Specifies that the bootstrap node should use its own local DNS server for -# name resolution. -# -# For more information, see installer/data/data/bootstrap/baremetal/README.md -# - -prepend domain-name-servers 127.0.0.1; diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index e3ac199d286..af43aa6b369 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -292,10 +292,11 @@ func (a *Bootstrap) addStorageFiles(base string, uri string, templateData *boots } filename := path.Base(uri) + parentDir := path.Base(path.Dir(uri)) var mode int appendToFile := false - if path.Base(path.Dir(uri)) == "bin" { + if parentDir == "bin" || parentDir == "dispatcher.d" { mode = 0555 } else if filename == "motd" { mode = 0644