From 3baca05501fbb3de51a08beefb96a05aafde944c Mon Sep 17 00:00:00 2001 From: Rick Box Date: Mon, 20 Feb 2017 12:36:01 +0000 Subject: [PATCH] Adds in option to modify DNS - removes hardcoded values Some networks may not allow 8.8.8.8 Google DNS servers. This patch allows this to be specified in the variables file or to pull the value from the systems resolv.conf file. Change-Id: I494ab82c41bcd59ea85404d49cb2696029353a0e --- multi-node-aio/openstack-service-setup.sh | 2 +- multi-node-aio/setup-cobbler.sh | 7 ++++++- multi-node-aio/templates/dhcp.template | 4 ++-- multi-node-aio/variables.sh | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/multi-node-aio/openstack-service-setup.sh b/multi-node-aio/openstack-service-setup.sh index 11120c00..cdb70de7 100644 --- a/multi-node-aio/openstack-service-setup.sh +++ b/multi-node-aio/openstack-service-setup.sh @@ -59,7 +59,7 @@ neutron subnet-create GATEWAY_NET ${NETWORK_BASE}.248.0/22 \ --name GATEWAY_NET_SUBNET \ --gateway ${NETWORK_BASE}.248.1 \ --allocation-pool start=${NETWORK_BASE}.248.201,end=${NETWORK_BASE}.248.255 \ - --dns-nameservers list=true 8.8.4.4 8.8.8.8 + --dns-nameservers list=true ${DNS_NAMESERVER} # Neutron private network setup neutron net-create PRIVATE_NET \ diff --git a/multi-node-aio/setup-cobbler.sh b/multi-node-aio/setup-cobbler.sh index 33ddeec1..3a1e499d 100755 --- a/multi-node-aio/setup-cobbler.sh +++ b/multi-node-aio/setup-cobbler.sh @@ -17,6 +17,9 @@ set -eu # Load all functions source functions.rc +# bring in variable definitions if there is a variables.sh file +[[ -f variables.sh ]] && source variables.sh + # The default image for VMs, change it to 16.04 if you want to use xenial as operation system. DEFAULT_IMAGE="${DEFAULT_IMAGE:-"$(lsb_release -sd | awk '{print $2}')"}" @@ -58,7 +61,9 @@ mkdir_check "/tftpboot" chown www-data /var/lib/cobbler/webui_sessions # when templated replace \$ with $ +# Copy dhcp template and replace with DNS var cp -v templates/dhcp.template /etc/cobbler/dhcp.template +sed -i "s|__DNS_NAMESERVER__|${DNS_NAMESERVER}|g" /etc/cobbler/dhcp.template # Create a sources.list file if [[ $DEFAULT_IMAGE == "14.04."* ]]; then @@ -155,7 +160,7 @@ for node_type in $(get_all_types); do --ip-address="10.0.0.${node#*":"}" \ --subnet=255.255.255.0 \ --gateway=10.0.0.200 \ - --name-servers=8.8.8.8 8.8.4.4 \ + --name-servers="${DNS_NAMESERVER}" \ --static=1 done done diff --git a/multi-node-aio/templates/dhcp.template b/multi-node-aio/templates/dhcp.template index c176cd36..1864134e 100644 --- a/multi-node-aio/templates/dhcp.template +++ b/multi-node-aio/templates/dhcp.template @@ -20,7 +20,7 @@ option pxe-system-type code 93 = unsigned integer 16; subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.200; - option domain-name-servers 8.8.8.8; + option domain-name-servers __DNS_NAMESERVER__; option subnet-mask 255.255.255.0; range dynamic-bootp 10.0.0.1 10.0.0.50; default-lease-time 21600; @@ -82,4 +82,4 @@ group { } #end for } -#end for \ No newline at end of file +#end for diff --git a/multi-node-aio/variables.sh b/multi-node-aio/variables.sh index f579cba8..1256d9d5 100755 --- a/multi-node-aio/variables.sh +++ b/multi-node-aio/variables.sh @@ -1,2 +1,6 @@ # Variables used by multi-node-aio +# Network subnet used for all the virtual machines NETWORK_BASE=172.29 +# DNS used throughout the deploy +#DNS_NAMESERVER=$(cat /etc/resolv.conf | grep -m 1 "nameserver" | sed "s/nameserver //") +DNS_NAMESERVER=8.8.8.8