From a1c06e606dbb0c7ddc68bb600505ef9316593502 Mon Sep 17 00:00:00 2001 From: "Frank A. Zdarsky" Date: Thu, 21 Jun 2018 20:08:20 +0000 Subject: [PATCH] Use system's configured DNS servers This patch takes the system's effective DNS servers and updates common-addresses.yaml to use these servers in the genesis process. It first attempts to query the DNS servers via nmcli, which is typically installed on desktop systems and is robust against the use of caching stub resolvers. If nmcli is not installed (typically on server systems), it falls back to reading DNS servers from /etc/resolv.conf. Change-Id: I881e0f87a1699080171ae18f6461097bdee5c242 Story: 2002639 Task: 22295 --- .../dev_single_node/airship-in-a-bottle.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/manifests/dev_single_node/airship-in-a-bottle.sh b/manifests/dev_single_node/airship-in-a-bottle.sh index 83068155..a9913c10 100755 --- a/manifests/dev_single_node/airship-in-a-bottle.sh +++ b/manifests/dev_single_node/airship-in-a-bottle.sh @@ -133,6 +133,28 @@ export NODE_NET_IFACE=$HOST_IFACE export TARGET_SITE="demo" set +x +# Changes DNS servers in common-addresses.yaml to the system's DNS servers +get_dns_servers () +{ + if hash nmcli 2>/dev/null; then + nmcli dev show | awk '/IP4.DNS/ {print $2}' | xargs + else + cat /etc/resolv.conf | awk '/nameserver/ {print $2}' | xargs + fi +} + +if grep -q "10.96.0.10" "/etc/resolv.conf"; then + echo "Not changing DNS servers, /etc/resolv.conf already updated." +else + DNS_CONFIG_FILE="../../deployment_files/site/$TARGET_SITE/networks/common-addresses.yaml" + declare -a DNS_SERVERS=($(get_dns_servers)) + NS1=${DNS_SERVERS[0]:-8.8.8.8} + NS2=${DNS_SERVERS[1]:-$NS1} + echo "Using DNS servers $NS1 and $NS2." + sed -i "s/8.8.8.8/$NS1/" $DNS_CONFIG_FILE + sed -i "s/8.8.4.4/$NS2/" $DNS_CONFIG_FILE +fi + echo "" echo "Starting Airship deployment..." sleep 1