Skip to content

Commit

Permalink
Do not remove upstream DNS configuraton in cleanup
Browse files Browse the repository at this point in the history
This PR changes the logic of host cleanup so that the upstream DNS
configuration is not removed. This comes from the fact that by default
dev-scripts configure NetworkManager to use dnsmasq with DHCP-provided
DNS servers and removes the existing /etc/resolv.conf configuration.

This causes problems in environments configured without DHCP with DNS
servers configured manually without use of the NetworkManager. With this
PR user can use `ADDN_DNS` variable to provide their own DNS servers
that will be passed to the dnsmasq. At the same time when removing
dev-scripts from the system, the backup of the original /etc/resolv.conf
will be restored so that the initial system configuration is reverted.
  • Loading branch information
mkowalski committed Jan 4, 2022
1 parent fa70d16 commit f0ae110
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions host_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if systemctl is-active --quiet NetworkManager; then
else
sudo systemctl restart NetworkManager
fi
mv /etc/resolv.conf.dev-scripts.backup /etc/resolv.conf

# There was a bug in this file, it may need to be recreated.
# delete the interface as it can cause issues when not rebooting
Expand Down
3 changes: 3 additions & 0 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ function write_pull_secret() {
}
function switch_to_internal_dns() {
# Create backup of the current resolv.conf in case user is using a manual configuration. This
# file will be used in host_cleanup to revert the initial DNS configuration of the host.
cp /etc/resolv.conf /etc/resolv.conf.dev-scripts.backup
sudo mkdir -p /etc/NetworkManager/conf.d/
ansible localhost -b -m ini_file -a "path=/etc/NetworkManager/conf.d/dnsmasq.conf section=main option=dns value=dnsmasq"
if [ "$ADDN_DNS" ] ; then
Expand Down

0 comments on commit f0ae110

Please sign in to comment.