Fix 2 for moving ips to be static
[genesis.git] / foreman / ci / vm_nodes_provision.sh
index 8b24aed..ef2b325 100755 (executable)
@@ -18,6 +18,8 @@ green=`tput setaf 2`
 
 host_name=REPLACE
 dns_server=REPLACE
+host_ip=REPLACE
+domain_name=REPLACE
 ##END VARS
 
 ##set hostname
@@ -31,7 +33,25 @@ if ! grep 'PEERDNS=no' /etc/sysconfig/network-scripts/ifcfg-enp0s3; then
   systemctl restart NetworkManager
 fi
 
-if ! ping www.google.com -c 5; then 
+##modify /etc/resolv.conf to point to foreman
+echo "${blue} Configuring resolv.conf with DNS: $dns_server ${reset}"
+cat > /etc/resolv.conf << EOF
+search $domain_name
+nameserver $dns_server
+nameserver 8.8.8.8
+
+EOF
+
+##modify /etc/hosts to add own IP for rabbitmq workaround
+host_short_name=`echo $host_name | cut -d . -f 1`
+echo "${blue} Configuring hosts with: $host_name $host_ip ${reset}"
+cat > /etc/hosts << EOF
+$host_ip  $host_short_name $host_name
+127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
+::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
+EOF
+
+if ! ping www.google.com -c 5; then
   echo "${red} No internet connection, check your route and DNS setup ${reset}"
   exit 1
 fi
@@ -75,10 +95,10 @@ pluginsync      = true
 report          = true
 ignoreschedules = true
 daemon          = false
-ca_server       = foreman-server.opnfv.com
+ca_server       = foreman-server.$domain_name
 certname        = $host_name
 environment     = production
-server          = foreman-server.opnfv.com
+server          = foreman-server.$domain_name
 runinterval     = 600
 
 EOF
@@ -86,13 +106,13 @@ EOF
 # Setup puppet to run on system reboot
 /sbin/chkconfig --level 345 puppet on
 
-/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.opnfv.com --no-daemonize
+/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.$domain_name --no-daemonize
 
 sync
 
 # Inform the build system that we are done.
 echo "Informing Foreman that we are built"
-wget -q -O /dev/null --no-check-certificate http://foreman-server.opnfv.com:80/unattended/built
+wget -q -O /dev/null --no-check-certificate http://foreman-server.$domain_name:80/unattended/built
 
 echo "Starting puppet"
 systemctl start puppet