3 #Deploy script to install provisioning server for Foreman/QuickStack
4 #author: Tim Rozet (trozet@redhat.com)
6 #Uses Vagrant and VirtualBox
7 #VagrantFile uses bootsrap.sh which Installs Khaleesi
8 #Khaleesi will install and configure Foreman/QuickStack
11 #Supports 3 or 4 network interface configuration
12 #Target system must be RPM based
13 #Ensure the host's kernel is up to date (yum update)
14 #Provisioned nodes expected to have following order of network connections (note: not all have to exist, but order is maintained):
16 #eth1- private network (+storage network in 3 NIC config)
18 #eth3- storage network
19 #script assumes /24 subnet mask
27 declare -A interface_arr
32 echo -e "\n\n${blue}This script is used to deploy Foreman/QuickStack Installer and Provision OPNFV Target System${reset}\n\n"
33 echo -e "\n${green}Make sure you have the latest kernel installed before running this script! (yum update kernel +reboot)${reset}\n"
34 echo -e "\nUsage:\n$0 [arguments] \n"
35 echo -e "\n -no_parse : No variable parsing into config. Flag. \n"
36 echo -e "\n -base_config : Full path of settings file to parse. Optional. Will provide a new base settings file rather than the default. Example: -base_config /opt/myinventory.yml \n"
37 echo -e "\n -virtual : Node virtualization instead of baremetal. Flag. \n"
40 ##find ip of interface
41 ##params: interface name
43 ip addr show $1 | grep -Eo '^\s+inet\s+[\.0-9]+' | awk '{print $2}'
46 ##finds subnet of ip and netmask
48 function find_subnet {
49 IFS=. read -r i1 i2 i3 i4 <<< "$1"
50 IFS=. read -r m1 m2 m3 m4 <<< "$2"
51 printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
54 ##increments subnet by a value
57 function increment_subnet {
58 IFS=. read -r i1 i2 i3 i4 <<< "$1"
59 printf "%d.%d.%d.%d\n" "$i1" "$i2" "$i3" "$((i4 | $2))"
63 ##finds netmask of interface
65 ##returns long format 255.255.x.x
66 function find_netmask {
67 ifconfig $1 | grep -Eo 'netmask\s+[\.0-9]+' | awk '{print $2}'
70 ##finds short netmask of interface
72 ##returns short format, ex: /21
73 function find_short_netmask {
74 echo "/$(ip addr show $1 | grep -Eo '^\s+inet\s+[\/\.0-9]+' | awk '{print $2}' | cut -d / -f2)"
79 ##assumes a /24 subnet
81 baseaddr="$(echo $1 | cut -d. -f1-3)"
82 lsv="$(echo $1 | cut -d. -f4)"
83 if [ "$lsv" -ge 254 ]; then
90 ##removes the network interface config from Vagrantfile
92 ##assumes you are in the directory of Vagrantfile
93 function remove_vagrant_network {
94 sed -i 's/^.*'"$1"'.*$//' Vagrantfile
97 ##check if IP is in use
99 ##ping ip to get arp entry, then check arp
100 function is_ip_used {
101 ping -c 5 $1 > /dev/null 2>&1
102 arp -n | grep "$1 " | grep -iv incomplete > /dev/null 2>&1
105 ##find next usable IP
107 function next_usable_ip {
109 while [ "$new_ip" ]; do
110 if ! is_ip_used $new_ip; then
114 new_ip=$(next_ip $new_ip)
119 ##increment ip by value
120 ##params: ip, amount to increment by
121 ##increment_ip $next_private_ip 10
122 function increment_ip {
123 baseaddr="$(echo $1 | cut -d. -f1-3)"
124 lsv="$(echo $1 | cut -d. -f4)"
127 if [ "$lsv" -ge 254 ]; then
133 ##translates yaml into variables
134 ##params: filename, prefix (ex. "config_")
135 ##usage: parse_yaml opnfv_ksgen_settings.yml "config_"
138 local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
139 sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
140 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
142 indent = length($1)/2;
144 for (i in vname) {if (i > indent) {delete vname[i]}}
145 if (length($3) > 0) {
146 vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
147 printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
152 ##translates the command line paramaters into variables
153 ##params: $@ the entire command line is passed
154 ##usage: parse_cmd_line() "$@"
156 if [[ ( $1 == "--help") || $1 == "-h" ]]; then
161 echo -e "\n\n${blue}This script is used to deploy Foreman/QuickStack Installer and Provision OPNFV Target System${reset}\n\n"
162 echo "Use -h to display help"
165 while [ "`echo $1 | cut -c1`" = "-" ]
191 ##usage: disable_selinux()
196 ##Install the EPEL repository and additional packages
198 ##usage: install_EPEL()
200 # Install EPEL repo for access to many other yum repos
201 # Major version is pinned to force some consistency for Arno
202 yum install -y epel-release-7*
204 # Install other required packages
205 # Major versions are pinned to force some consistency for Arno
206 if ! yum install -y binutils-2* gcc-4* make-3* patch-2* libgomp-4* glibc-headers-2* glibc-devel-2* kernel-headers-3* kernel-devel-3* dkms-2* psmisc-22*; then
207 printf '%s\n' 'deploy.sh: Unable to install depdency packages' >&2
212 ##Download and install virtual box
214 ##usage: install_vbox()
216 ##install VirtualBox repo
217 if cat /etc/*release | grep -i "Fedora release"; then
218 vboxurl=http://download.virtualbox.org/virtualbox/rpm/fedora/\$releasever/\$basearch
220 vboxurl=http://download.virtualbox.org/virtualbox/rpm/el/\$releasever/\$basearch
223 cat > /etc/yum.repos.d/virtualbox.repo << EOM
225 name=Oracle Linux / RHEL / CentOS-\$releasever / \$basearch - VirtualBox
229 gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
230 skip_if_unavailable = 1
235 if ! yum list installed | grep -i virtualbox; then
236 if ! yum -y install VirtualBox-4.3; then
237 printf '%s\n' 'deploy.sh: Unable to install virtualbox package' >&2
242 ##install kmod-VirtualBox
243 if ! lsmod | grep vboxdrv; then
244 sudo /etc/init.d/vboxdrv setup
245 if ! lsmod | grep vboxdrv; then
246 printf '%s\n' 'deploy.sh: Unable to install kernel module for virtualbox' >&2
250 printf '%s\n' 'deploy.sh: Skipping kernel module for virtualbox. Already Installed'
254 ##install Ansible using yum
256 ##usage: install_anible()
258 if ! yum list installed | grep -i ansible; then
259 if ! yum -y install ansible-1*; then
260 printf '%s\n' 'deploy.sh: Unable to install Ansible package' >&2
266 ##install Vagrant RPM directly with the bintray.com site
268 ##usage: install_vagrant()
270 if ! rpm -qa | grep vagrant; then
271 if ! rpm -Uvh https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.rpm; then
272 printf '%s\n' 'deploy.sh: Unable to install vagrant package' >&2
276 printf '%s\n' 'deploy.sh: Skipping Vagrant install as it is already installed.'
279 ##add centos 7 box to vagrant
280 if ! vagrant box list | grep chef/centos-7.0; then
281 if ! vagrant box add chef/centos-7.0 --provider virtualbox; then
282 printf '%s\n' 'deploy.sh: Unable to download centos7 box for Vagrant' >&2
286 printf '%s\n' 'deploy.sh: Skipping Vagrant box add as centos-7.0 is already installed.'
289 ##install workaround for centos7
290 if ! vagrant plugin list | grep vagrant-centos7_fix; then
291 if ! vagrant plugin install vagrant-centos7_fix; then
292 printf '%s\n' 'deploy.sh: Warning: unable to install vagrant centos7 workaround' >&2
295 printf '%s\n' 'deploy.sh: Skipping Vagrant plugin as centos7 workaround is already installed.'
300 ##remove bgs vagrant incase it wasn't cleaned up
304 rm -rf /tmp/bgs_vagrant
307 ##clone bgs vagrant version 1.0 using git
313 ##will change this to be opnfv repo when commit is done
314 if ! git clone -b v1.0 https://github.com/trozet/bgs_vagrant.git; then
315 printf '%s\n' 'deploy.sh: Unable to clone vagrant repo' >&2
320 ##validates the netork settings and update VagrantFile with network settings
322 ##usage: configure_network()
323 configure_network() {
326 echo "${blue}Detecting network configuration...${reset}"
327 ##detect host 1 or 3 interface configuration
328 #output=`ip link show | grep -E "^[0-9]" | grep -Ev ": lo|tun|virbr|vboxnet" | awk '{print $2}' | sed 's/://'`
329 output=`ifconfig | grep -E "^[a-zA-Z0-9]+:"| grep -Ev "lo|tun|virbr|vboxnet" | awk '{print $1}' | sed 's/://'`
331 if [ ! "$output" ]; then
332 printf '%s\n' 'deploy.sh: Unable to detect interfaces to bridge to' >&2
336 ##find number of interfaces with ip and substitute in VagrantFile
338 for interface in ${output}; do
340 if [ "$if_counter" -ge 4 ]; then
343 interface_ip=$(find_ip $interface)
344 if [ ! "$interface_ip" ]; then
347 new_ip=$(next_usable_ip $interface_ip)
348 if [ ! "$new_ip" ]; then
351 interface_arr[$interface]=$if_counter
352 interface_ip_arr[$if_counter]=$new_ip
353 subnet_mask=$(find_netmask $interface)
354 if [ "$if_counter" -eq 1 ]; then
355 private_subnet_mask=$subnet_mask
356 private_short_subnet_mask=$(find_short_netmask $interface)
358 if [ "$if_counter" -eq 2 ]; then
359 public_subnet_mask=$subnet_mask
360 public_short_subnet_mask=$(find_short_netmask $interface)
362 if [ "$if_counter" -eq 3 ]; then
363 storage_subnet_mask=$subnet_mask
365 sed -i 's/^.*eth_replace'"$if_counter"'.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$interface"\'', netmask: '\""$subnet_mask"\"'/' Vagrantfile
369 ##now remove interface config in Vagrantfile for 1 node
370 ##if 1, 3, or 4 interfaces set deployment type
371 ##if 2 interfaces remove 2nd interface and set deployment type
372 if [ "$if_counter" == 1 ]; then
373 deployment_type="single_network"
374 remove_vagrant_network eth_replace1
375 remove_vagrant_network eth_replace2
376 remove_vagrant_network eth_replace3
377 elif [ "$if_counter" == 2 ]; then
378 deployment_type="single_network"
379 second_interface=`echo $output | awk '{print $2}'`
380 remove_vagrant_network $second_interface
381 remove_vagrant_network eth_replace2
382 elif [ "$if_counter" == 3 ]; then
383 deployment_type="three_network"
384 remove_vagrant_network eth_replace3
386 deployment_type="multi_network"
389 echo "${blue}Network detected: ${deployment_type}! ${reset}"
391 if route | grep default; then
392 echo "${blue}Default Gateway Detected ${reset}"
393 host_default_gw=$(ip route | grep default | awk '{print $3}')
394 echo "${blue}Default Gateway: $host_default_gw ${reset}"
395 default_gw_interface=$(ip route get $host_default_gw | awk '{print $3}')
396 case "${interface_arr[$default_gw_interface]}" in
398 echo "${blue}Default Gateway Detected on Admin Interface!${reset}"
399 sed -i 's/^.*default_gw =.*$/ default_gw = '\""$host_default_gw"\"'/' Vagrantfile
400 node_default_gw=$host_default_gw
403 echo "${red}Default Gateway Detected on Private Interface!${reset}"
404 echo "${red}Private subnet should be private and not have Internet access!${reset}"
408 echo "${blue}Default Gateway Detected on Public Interface!${reset}"
409 sed -i 's/^.*default_gw =.*$/ default_gw = '\""$host_default_gw"\"'/' Vagrantfile
410 echo "${blue}Will setup NAT from Admin -> Public Network on VM!${reset}"
411 sed -i 's/^.*nat_flag =.*$/ nat_flag = true/' Vagrantfile
412 echo "${blue}Setting node gateway to be VM Admin IP${reset}"
413 node_default_gw=${interface_ip_arr[0]}
414 public_gateway=$default_gw
417 echo "${red}Default Gateway Detected on Storage Interface!${reset}"
418 echo "${red}Storage subnet should be private and not have Internet access!${reset}"
422 echo "${red}Unable to determine which interface default gateway is on..Exiting!${reset}"
428 defaultgw=`echo ${interface_ip_arr[0]} | cut -d. -f1-3`
430 defaultgw=$defaultgw$firstip
431 echo "${blue}Unable to find default gateway. Assuming it is $defaultgw ${reset}"
432 sed -i 's/^.*default_gw =.*$/ default_gw = '\""$defaultgw"\"'/' Vagrantfile
433 node_default_gw=$defaultgw
436 if [ $base_config ]; then
437 if ! cp -f $base_config opnfv_ksgen_settings.yml; then
438 echo "{red}ERROR: Unable to copy $base_config to opnfv_ksgen_settings.yml${reset}"
443 if [ $no_parse ]; then
444 echo "${blue}Skipping parsing variables into settings file as no_parse flag is set${reset}"
448 echo "${blue}Gathering network parameters for Target System...this may take a few minutes${reset}"
449 ##Edit the ksgen settings appropriately
450 ##ksgen settings will be stored in /vagrant on the vagrant machine
451 ##if single node deployment all the variables will have the same ip
452 ##interface names will be enp0s3, enp0s8, enp0s9 in chef/centos7
454 sed -i 's/^.*default_gw:.*$/default_gw:'" $node_default_gw"'/' opnfv_ksgen_settings.yml
456 ##replace private interface parameter
457 ##private interface will be of hosts, so we need to know the provisioned host interface name
458 ##we add biosdevname=0, net.ifnames=0 to the kickstart to use regular interface naming convention on hosts
459 ##replace IP for parameters with next IP that will be given to controller
460 if [ "$deployment_type" == "single_network" ]; then
461 ##we also need to assign IP addresses to nodes
462 ##for single node, foreman is managing the single network, so we can't reserve them
463 ##not supporting single network anymore for now
464 echo "{blue}Single Network type is unsupported right now. Please check your interface configuration. Exiting. ${reset}"
467 elif [[ "$deployment_type" == "multi_network" || "$deployment_type" == "three_network" ]]; then
469 if [ "$deployment_type" == "three_network" ]; then
470 sed -i 's/^.*network_type:.*$/network_type: three_network/' opnfv_ksgen_settings.yml
473 sed -i 's/^.*deployment_type:.*$/ deployment_type: '"$deployment_type"'/' opnfv_ksgen_settings.yml
475 ##get ip addresses for private network on controllers to make dhcp entries
476 ##required for controllers_ip_array global param
477 next_private_ip=${interface_ip_arr[1]}
479 for node in controller1 controller2 controller3; do
480 next_private_ip=$(next_usable_ip $next_private_ip)
481 if [ ! "$next_private_ip" ]; then
482 printf '%s\n' 'deploy.sh: Unable to find next ip for private network for control nodes' >&2
485 sed -i 's/'"$node$type"'/'"$next_private_ip"'/g' opnfv_ksgen_settings.yml
486 controller_ip_array=$controller_ip_array$next_private_ip,
489 ##replace global param for contollers_ip_array
490 controller_ip_array=${controller_ip_array%?}
491 sed -i 's/^.*controllers_ip_array:.*$/ controllers_ip_array: '"$controller_ip_array"'/' opnfv_ksgen_settings.yml
493 ##now replace all the VIP variables. admin//private can be the same IP
494 ##we have to use IP's here that won't be allocated to hosts at provisioning time
495 ##therefore we increment the ip by 10 to make sure we have a safe buffer
496 next_private_ip=$(increment_ip $next_private_ip 10)
498 grep -E '*private_vip|loadbalancer_vip|db_vip|amqp_vip|*admin_vip' opnfv_ksgen_settings.yml | while read -r line ; do
499 sed -i 's/^.*'"$line"'.*$/ '"$line $next_private_ip"'/' opnfv_ksgen_settings.yml
500 next_private_ip=$(next_usable_ip $next_private_ip)
501 if [ ! "$next_private_ip" ]; then
502 printf '%s\n' 'deploy.sh: Unable to find next ip for private network for vip replacement' >&2
507 ##replace foreman site
508 next_public_ip=${interface_ip_arr[2]}
509 sed -i 's/^.*foreman_url:.*$/ foreman_url:'" https:\/\/$next_public_ip"'\/api\/v2\//' opnfv_ksgen_settings.yml
510 ##replace public vips
511 next_public_ip=$(increment_ip $next_public_ip 10)
512 grep -E '*public_vip' opnfv_ksgen_settings.yml | while read -r line ; do
513 sed -i 's/^.*'"$line"'.*$/ '"$line $next_public_ip"'/' opnfv_ksgen_settings.yml
514 next_public_ip=$(next_usable_ip $next_public_ip)
515 if [ ! "$next_public_ip" ]; then
516 printf '%s\n' 'deploy.sh: Unable to find next ip for public network for vip replcement' >&2
521 ##replace public_network param
522 public_subnet=$(find_subnet $next_public_ip $public_subnet_mask)
523 sed -i 's/^.*public_network:.*$/ public_network:'" $public_subnet"'/' opnfv_ksgen_settings.yml
524 ##replace private_network param
525 private_subnet=$(find_subnet $next_private_ip $private_subnet_mask)
526 sed -i 's/^.*private_network:.*$/ private_network:'" $private_subnet"'/' opnfv_ksgen_settings.yml
527 ##replace storage_network
528 if [ "$deployment_type" == "three_network" ]; then
529 sed -i 's/^.*storage_network:.*$/ storage_network:'" $private_subnet"'/' opnfv_ksgen_settings.yml
531 next_storage_ip=${interface_ip_arr[3]}
532 storage_subnet=$(find_subnet $next_storage_ip $storage_subnet_mask)
533 sed -i 's/^.*storage_network:.*$/ storage_network:'" $storage_subnet"'/' opnfv_ksgen_settings.yml
536 ##replace public_subnet param
537 public_subnet=$public_subnet'\'$public_short_subnet_mask
538 sed -i 's/^.*public_subnet:.*$/ public_subnet:'" $public_subnet"'/' opnfv_ksgen_settings.yml
539 ##replace private_subnet param
540 private_subnet=$private_subnet'\'$private_short_subnet_mask
541 sed -i 's/^.*private_subnet:.*$/ private_subnet:'" $private_subnet"'/' opnfv_ksgen_settings.yml
543 ##replace public_dns param to be foreman server
544 sed -i 's/^.*public_dns:.*$/ public_dns: '${interface_ip_arr[2]}'/' opnfv_ksgen_settings.yml
546 ##replace public_gateway
547 if [ -z "$public_gateway" ]; then
548 ##if unset then we assume its the first IP in the public subnet
549 public_subnet=$(find_subnet $next_public_ip $public_subnet_mask)
550 public_gateway=$(increment_subnet $public_subnet 1)
552 sed -i 's/^.*public_gateway:.*$/ public_gateway:'" $public_gateway"'/' opnfv_ksgen_settings.yml
554 ##we have to define an allocation range of the public subnet to give
555 ##to neutron to use as floating IPs
556 ##we should control this subnet, so this range should work .150-200
557 ##but generally this is a bad idea and we are assuming at least a /24 subnet here
558 public_subnet=$(find_subnet $next_public_ip $public_subnet_mask)
559 public_allocation_start=$(increment_subnet $public_subnet 150)
560 public_allocation_end=$(increment_subnet $public_subnet 200)
562 sed -i 's/^.*public_allocation_start:.*$/ public_allocation_start:'" $public_allocation_start"'/' opnfv_ksgen_settings.yml
563 sed -i 's/^.*public_allocation_end:.*$/ public_allocation_end:'" $public_allocation_end"'/' opnfv_ksgen_settings.yml
566 printf '%s\n' 'deploy.sh: Unknown network type: $deployment_type' >&2
570 echo "${blue}Parameters Complete. Settings have been set for Foreman. ${reset}"
575 ##Configure bootstrap.sh to use the virtual Khaleesi playbook
577 ##usage: configure_virtual()
578 configure_virtual() {
579 if [ $virtual ]; then
580 echo "${blue} Virtual flag detected, setting Khaleesi playbook to be opnfv-vm.yml ${reset}"
581 sed -i 's/opnfv.yml/opnfv-vm.yml/' bootstrap.sh
585 ##Starts for forement VM with Vagrant
587 ##usage: start_vagrant()
589 echo "${blue}Starting Vagrant! ${reset}"
592 if ! vagrant up; then
593 printf '%s\n' 'deploy.sh: Unable to start vagrant' >&2
596 echo "${blue}Foreman VM is up! ${reset}"
600 ##start the VM if this is a virtual installaion
601 ##this function does nothing if baremetal servers are being used
603 ##usage: start_virtual_nodes()
604 start_virutal_nodes() {
605 if [ $virtual ]; then
608 echo "${blue}Setting VMs up... ${reset}"
609 nodes=`sed -nr '/nodes:/{:start /workaround/!{N;b start};//p}' opnfv_ksgen_settings.yml | sed -n '/^ [A-Za-z0-9]\+:$/p' | sed 's/\s*//g' | sed 's/://g'`
610 ##due to ODL Helium bug of OVS connecting to ODL too early, we need controllers to install first
611 ##this is fix kind of assumes more than I would like to, but for now it should be OK as we always have
612 ##3 static controllers
613 compute_nodes=`echo $nodes | tr " " "\n" | grep -v controller | tr "\n" " "`
614 controller_nodes=`echo $nodes | tr " " "\n" | grep controller | tr "\n" " "`
615 nodes=${controller_nodes}${compute_nodes}
617 for node in ${nodes}; do
620 ##remove VM nodes incase it wasn't cleaned up
624 ##will change this to be opnfv repo when commit is done
625 if ! git clone -b v1.0 https://github.com/trozet/bgs_vagrant.git $node; then
626 printf '%s\n' 'deploy.sh: Unable to clone vagrant repo' >&2
632 if [ $base_config ]; then
633 if ! cp -f $base_config opnfv_ksgen_settings.yml; then
634 echo "{red}ERROR: Unable to copy $base_config to opnfv_ksgen_settings.yml${reset}"
639 ##parse yaml into variables
640 eval $(parse_yaml opnfv_ksgen_settings.yml "config_")
642 node_type=config_nodes_${node}_type
643 node_type=$(eval echo \$$node_type)
645 ##find number of interfaces with ip and substitute in VagrantFile
646 output=`ifconfig | grep -E "^[a-zA-Z0-9]+:"| grep -Ev "lo|tun|virbr|vboxnet" | awk '{print $1}' | sed 's/://'`
648 if [ ! "$output" ]; then
649 printf '%s\n' 'deploy.sh: Unable to detect interfaces to bridge to' >&2
655 for interface in ${output}; do
657 if [ "$if_counter" -ge 4 ]; then
660 interface_ip=$(find_ip $interface)
661 if [ ! "$interface_ip" ]; then
664 case "${if_counter}" in
666 mac_string=config_nodes_${node}_mac_address
667 mac_addr=$(eval echo \$$mac_string)
668 mac_addr=$(echo $mac_addr | sed 's/:\|-//g')
669 if [ $mac_addr == "" ]; then
670 echo "${red} Unable to find mac_address for $node! ${reset}"
675 if [ "$node_type" == "controller" ]; then
676 mac_string=config_nodes_${node}_private_mac
677 mac_addr=$(eval echo \$$mac_string)
678 if [ $mac_addr == "" ]; then
679 echo "${red} Unable to find private_mac for $node! ${reset}"
683 ##generate random mac
684 mac_addr=$(echo -n 00-60-2F; dd bs=1 count=3 if=/dev/random 2>/dev/null |hexdump -v -e '/1 "-%02X"')
686 mac_addr=$(echo $mac_addr | sed 's/:\|-//g')
689 mac_addr=$(echo -n 00-60-2F; dd bs=1 count=3 if=/dev/random 2>/dev/null |hexdump -v -e '/1 "-%02X"')
690 mac_addr=$(echo $mac_addr | sed 's/:\|-//g')
693 sed -i 's/^.*eth_replace'"$if_counter"'.*$/ config.vm.network "public_network", bridge: '\'"$interface"\'', :mac => '\""$mac_addr"\"'/' Vagrantfile
697 ##now remove interface config in Vagrantfile for 1 node
698 ##if 1, 3, or 4 interfaces set deployment type
699 ##if 2 interfaces remove 2nd interface and set deployment type
700 if [ "$if_counter" == 1 ]; then
701 deployment_type="single_network"
702 remove_vagrant_network eth_replace1
703 remove_vagrant_network eth_replace2
704 remove_vagrant_network eth_replace3
705 elif [ "$if_counter" == 2 ]; then
706 deployment_type="single_network"
707 second_interface=`echo $output | awk '{print $2}'`
708 remove_vagrant_network $second_interface
709 remove_vagrant_network eth_replace2
710 elif [ "$if_counter" == 3 ]; then
711 deployment_type="three_network"
712 remove_vagrant_network eth_replace3
714 deployment_type="multi_network"
717 ##modify provisioning to do puppet install, config, and foreman check-in
718 ##substitute host_name and dns_server in the provisioning script
719 host_string=config_nodes_${node}_hostname
720 host_name=$(eval echo \$$host_string)
721 sed -i 's/^host_name=REPLACE/host_name='$host_name'/' vm_nodes_provision.sh
722 ##dns server should be the foreman server
723 sed -i 's/^dns_server=REPLACE/dns_server='${interface_ip_arr[0]}'/' vm_nodes_provision.sh
725 ## remove bootstrap and NAT provisioning
726 sed -i '/nat_setup.sh/d' Vagrantfile
727 sed -i 's/bootstrap.sh/vm_nodes_provision.sh/' Vagrantfile
729 ## modify default_gw to be node_default_gw
730 sed -i 's/^.*default_gw =.*$/ default_gw = '\""$node_default_gw"\"'/' Vagrantfile
732 ## modify VM memory to be 4gig
733 sed -i 's/^.*vb.memory =.*$/ vb.memory = 4096/' Vagrantfile
735 echo "${blue}Starting Vagrant Node $node! ${reset}"
738 if ! vagrant up; then
739 echo "${red} Unable to start $node ${reset}"
742 echo "${blue} $node VM is up! ${reset}"
747 echo "${blue} All VMs are UP! ${reset}"