From d655ecc4884beb1e793e147021cdc121c28d258b Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 29 Mar 2018 15:20:13 -0700 Subject: [PATCH] Ensure /etc/resolv.conf is a regular file in final image As described in the inline comment, this ensures that on Bionic (and any similar platform using systemd-resolved) we use a regular /etc/resolv.conf file for nameserver configuration. Depends-On: https://review.openstack.org/#/c/558362/ Change-Id: I1e1d285787f88370fec6e9e21701164cc232e153 --- .../nodepool-base/finalise.d/89-unbound | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nodepool/elements/nodepool-base/finalise.d/89-unbound b/nodepool/elements/nodepool-base/finalise.d/89-unbound index 91e425d093..c0c2360d73 100755 --- a/nodepool/elements/nodepool-base/finalise.d/89-unbound +++ b/nodepool/elements/nodepool-base/finalise.d/89-unbound @@ -168,6 +168,23 @@ supersede domain-name ""; EOF fi +# On bionic and later, the install of the new systemd-resolved in the +# chroot will see that there is no /etc/resolv.conf and assume it is a +# blank system where it will be the nameserver provider. It thus +# creates /etc/resolv.conf as a link back to its compatability files. +# To configure systemd-resolved's resolvers you need to modify +# /etc/systemd/resolved.conf; which would be possible, but we'd prefer +# to be consistent across all our platforms. +# +# dib will copy whatever is in /etc/resolv.conf.ORIG to +# /etc/resolv.conf as one of the final steps in image creation. Thus +# we are hard-coding resolution to localhost (unbound) here. +# +# Note that with /etc/resolv.conf as a regular file, systemd-resolved +# will also obey it for nameserver info when it starts at boot. +rm -f /etc/resolv.conf.ORIG +echo "nameserver 127.0.0.1" > /etc/resolv.conf.ORIG + case "$DIB_INIT_SYSTEM" in upstart) # nothing to do