octavia/elements/no-resolvconf/finalise.d/99-disable-resolv-conf
Gregory Thiemonge 2043788473 Workaround to fix amphora-agent on centos
dnspython now requires to have at least one nameserver in
/etc/resolv.conf.
The amphora image doesn't need and doesn't use any dns servers, add a
dummy dns server as a workaround on centos (on ubuntu, resolv.conf
contains the systemd resolver).
We will revert this patch when we find a more convenient fix for this
issue

Story: 2009281
Task: 43552

Change-Id: I81af508e7df5ffef343f1614335ffe1a98540912
2021-10-12 18:49:42 +02:00

24 lines
762 B
Bash
Executable File

#!/bin/bash
# Override resolv.conf file from DIB with a custom one.
# Having at least one nameserver is now required by dnfpython (>=)
echo "nameserver 127.0.0.1" > /etc/resolv.conf
echo "nameserver 127.0.0.1" > /etc/resolv.conf.ORIG
if [ -d /etc/dhcp/dhclient-enter-hooks.d ]
then
# Debian/Ubuntu
echo "#!/bin/sh
make_resolv_conf() { : ; }" > /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
chmod +x /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolvconf
else
# RHEL/CentOS/Fedora
echo "#!/bin/sh
make_resolv_conf() { : ; }" > /etc/dhcp/dhclient-enter-hooks
chmod +x /etc/dhcp/dhclient-enter-hooks
fi
if [ -e /etc/nsswitch.conf ]; then
sed -i -e "/hosts:/ s/dns//g" /etc/nsswitch.conf
fi