Browse Source

VirtualBox network fixes and the dockerless mode support

This commit include changes:

 * using the VirtualBox scripts the Fuel master node now always
   booted with kernel option 'wait_for_external_config=yes' to
   provide the same deployment functionality as in the 'fuel-qa'.

 * settings for the kernel command line moved to the top config
   file, because the settings wich could be edited should be placed
   there.

 * because of configuration task moved to the correct place there
   is no need to parse 'bootstrap_admin_node.log' and always follow
   the changes in the 'fuel-library', so all parsing logic removed
   from the scripts. This also simplifies networking changes and
   there is no need to patch the files on the fly and restart
   docker containers if they used.

 * variable 'vm_master_nat_gateway' removed from the 'config.sh'
   and from the 'enable_outbound_network_for_product_vm' because
   gateway should be set from the DHCP lease.

 * the sysconfig configuration files on the fuel master node now
   configured the right way. the backup files for configuration
   files are created. also added some comments for changes in the
   scripts.

 * now the default routing on the fuel master node correctly
   configured without creating the second default route. also
   ZeroConf route creation and NetworkManager now switched off
   to correct work of the network service.

 * the 'resolv.conf', 'dnsmasq.upstream' and 'astute.yaml' now
   correctly modified and could contain up to three DNS nameservers.

 * added support for the new dockerless 9.0 Fuel.

Implements blueprint: get-rid-docker-containers

Change-Id: I8f32fb8105d0781938757fa13d5dcbbacbf9c845
Closes-Bug: #1544241
Partial-Bug: #1323365
Maksim Malchuk 3 years ago
parent
commit
b48c7f5293

+ 5
- 4
actions/master-node-create-and-install.sh View File

@@ -50,20 +50,21 @@ if [ ${headless} -eq 1 ]; then
50 50
 fi
51 51
 
52 52
 if [ "${skipfuelmenu}" = "yes" ]; then
53
-  cmdline="$(grep 'append initrd' ../iso/isolinux/isolinux.cfg -m1 2>/dev/null | sed -e 's/^[ ]*append[ ]*//')"
54
-  cmdline="${cmdline:-initrd=initrd.img net.ifnames=0 biosdevname=0 ks=hd:sr0:/ks.cfg ip=10.20.0.2::10.20.0.1:255.255.255.0:fuel.domain.tld:eth0:off::: dns1=10.20.0.1 selinux=0}"
55
-  boot_line="$(translate " vmlinuz $cmdline showmenu=no"$'\n')"
53
+    boot_line="$(translate " vmlinuz $cmdline wait_for_external_config=yes showmenu=no"$'\n')"
54
+else
55
+    boot_line="$(translate " vmlinuz $cmdline wait_for_external_config=yes"$'\n')"
56 56
 fi
57 57
 
58 58
 # Start virtual machine with the master node
59 59
 echo
60 60
 start_vm $name
61
+echo
61 62
 
62 63
 # Wait until product VM needs outbound network/internet access
63 64
 wait_for_product_vm_to_download $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
64 65
 
65 66
 # Enable outbound network/internet access for the machine
66
-enable_outbound_network_for_product_vm $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt" 3 $vm_master_nat_gateway
67
+enable_outbound_network_for_product_vm $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
67 68
 
68 69
 # Wait until the machine gets installed and Puppet completes its run
69 70
 wait_for_product_vm_to_install $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"

+ 1
- 1
actions/master-node-enable-internet.sh View File

@@ -30,5 +30,5 @@ source ./functions/product.sh
30 30
 name="${vm_name_prefix}master"
31 31
 
32 32
 # Enable outbound network/internet access for the machine
33
-enable_outbound_network_for_product_vm $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt" 3 $vm_master_nat_gateway
33
+enable_outbound_network_for_product_vm $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
34 34
 

+ 8
- 1
config.sh View File

@@ -84,7 +84,6 @@ vm_master_disk_mb=65535
84 84
 
85 85
 # Master node access to the internet through the host system, using VirtualBox NAT adapter
86 86
 vm_master_nat_network=192.168.200.0/24
87
-vm_master_nat_gateway=192.168.200.2
88 87
 
89 88
 # These settings will be used to check if master node has installed or not.
90 89
 # If you modify networking params for master node during the boot time
@@ -185,4 +184,12 @@ vm_slave_third_disk_mb=65535
185 184
 # Set to 1 to run VirtualBox in headless mode
186 185
 headless=0
187 186
 RDPport=5000
187
+
188
+# set to "yes" if you want to boot the Fuel master node without the Fuel Menu. (enabling this will add an option "showmenu=no" to the kernel comdline so don't need to provide it below)
188 189
 skipfuelmenu="no"
190
+
191
+# use defaults from the isolinux.cfg if script started from the GitHub cloned repositoy files. otherwise use same defaults defined here.
192
+cmdline="$(grep 'append initrd' ../iso/isolinux/isolinux.cfg -m1 2>/dev/null | sed -e 's/^[ ]*append[ ]*//')"
193
+cmdline="${cmdline:-initrd=initrd.img net.ifnames=0 biosdevname=0 ks=hd:sr0:/ks.cfg ip=10.20.0.2::10.20.0.1:255.255.255.0:fuel.domain.tld:eth0:off::: dns1=10.20.0.1 selinux=0}"
194
+# if you want to override the defaults feel free to uncomment and edit the line below
195
+# cmdline="initrd=initrd.img net.ifnames=0 biosdevname=0 ks=hd:sr0:/ks.cfg ip=10.20.0.2::10.20.0.1:255.255.255.0:fuel.domain.tld:eth0:off::: dns1=10.20.0.1 selinux=0"

+ 61
- 65
functions/product.sh View File

@@ -22,15 +22,14 @@ source ./functions/shell.sh
22 22
 
23 23
 ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no -oPubkeyAuthentication=no'
24 24
 
25
-wait_for_line_in_puppet_bootstrap() {
25
+wait_for_exec_in_bootstrap() {
26 26
     ip=$1
27 27
     username=$2
28 28
     password=$3
29 29
     prompt=$4
30
-    goodline=$5
31
-    badline=$6
30
+    cmd=$5
32 31
 
33
-    # Log in into the VM, see if Puppet has completed its run
32
+    # Log in into the VM, exec cmd and print exitcode
34 33
     # Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
35 34
     result=$(
36 35
         execute expect << ENDOFEXPECT
@@ -39,40 +38,38 @@ wait_for_line_in_puppet_bootstrap() {
39 38
         expect "*?assword:*"
40 39
         send "$password\r"
41 40
         expect "$prompt"
42
-        send "egrep --color=none -e '${goodline}' -e '${badline}' /var/log/puppet/bootstrap_admin_node.log\r"
41
+        send "$cmd\r"
42
+        expect "$prompt"
43
+        send "echo \"rc=\$?\"\r"
43 44
         expect "$prompt"
44 45
         send "logout\r"
45 46
         expect "$prompt"
46 47
 ENDOFEXPECT
47 48
     )
48
-
49
-    echo "$result" | grep -v grep | egrep -q "$badline" >&2 && return 1
50
-    echo "$result" | grep -v grep | egrep -q "$goodline" >&2 && return 0
49
+    echo "$result" | grep -q "[r]c=0" >&2 && return 0
51 50
     return 1
52 51
 }
53 52
 
54
-is_product_vm_operational() {
55
-    wait_for_line_in_puppet_bootstrap "$@" "^Fuel.*complete" "^Fuel.*FAILED"
56
-}
57
-
58 53
 wait_for_product_vm_to_download() {
59 54
     ip=$1
60 55
     username=$2
61 56
     password=$3
62 57
     prompt=$4
63 58
 
64
-    echo "Waiting for product VM to download files. Please do NOT abort the script..."
59
+    echo -n "Waiting for product VM to download files. Please do NOT abort the script... "
65 60
 
66
-    # Loop until master node gets successfully installed
61
+    # Loop until master node booted and wait_for_external_config started
67 62
     maxdelay=3000
68
-    while ! wait_for_line_in_puppet_bootstrap $ip $username $password "$prompt" "build docker containers finished.|^Fuel.*complete" "^Fuel.*FAILED"; do
63
+    while ! wait_for_exec_in_bootstrap $ip $username $password "$prompt" "ps xa | grep '\[w\]ait_for_external_config'"; do
69 64
         sleep 5
70 65
         ((waited += 5))
71 66
         if (( waited >= maxdelay )); then
72
-          echo "Installation timed out! ($maxdelay seconds)" 1>&2
73
-          exit 1
67
+            echo "Installation timed out! ($maxdelay seconds)" 1>&2
68
+            exit 1
74 69
         fi
75 70
     done
71
+
72
+    echo "OK"
76 73
 }
77 74
 
78 75
 wait_for_product_vm_to_install() {
@@ -81,18 +78,20 @@ wait_for_product_vm_to_install() {
81 78
     password=$3
82 79
     prompt=$4
83 80
 
84
-    echo "Waiting for product VM to install. Please do NOT abort the script..."
81
+    echo -n "Waiting for product VM to install. Please do NOT abort the script... "
85 82
 
86 83
     # Loop until master node gets successfully installed
87 84
     maxdelay=3000
88
-    while ! is_product_vm_operational $ip $username $password "$prompt"; do
85
+    while wait_for_exec_in_bootstrap $ip $username $password "$prompt" "ps xa | grep '\[b\]ootstrap_admin_node.sh'"; do
89 86
         sleep 5
90 87
         ((waited += 5))
91 88
         if (( waited >= maxdelay )); then
92
-          echo "Installation timed out! ($maxdelay seconds)" 1>&2
93
-          exit 1
89
+            echo "Installation timed out! ($maxdelay seconds)" 1>&2
90
+            exit 1
94 91
         fi
95 92
     done
93
+
94
+    echo "OK"
96 95
 }
97 96
 
98 97
 check_internet_connection() {
@@ -114,8 +113,6 @@ enable_outbound_network_for_product_vm() {
114 113
     username=$2
115 114
     password=$3
116 115
     prompt=$4
117
-    interface_id=$(($5-1))   # Subtract one to get ethX index (0-based) from the VirtualBox index (from 1 to 4)
118
-    gateway_ip=$6
119 116
 
120 117
     # Check for internet access on the host system
121 118
     echo -n "Checking for internet connectivity on the host system... "
@@ -180,6 +177,9 @@ enable_outbound_network_for_product_vm() {
180 177
     master_ip_pub_net="${master_ip_pub_net%.*}"".1"
181 178
     local master_pub_net="${master_ip_pub_net%.*}"".0"
182 179
 
180
+    # Convert nameservers list into the one line separated by the comma
181
+    dns_upstream="$(echo -e $nameserver | cut -d ' ' -f2 | sed -e':a;N;$!ba;s/\n/,/g')"
182
+
183 183
     # Log in into the VM, configure and bring up the NAT interface, set default gateway, check internet connectivity
184 184
     # Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
185 185
     result=$(
@@ -189,30 +189,34 @@ enable_outbound_network_for_product_vm() {
189 189
         expect "*?assword:*"
190 190
         send "$password\r"
191 191
         expect "$prompt"
192
-        send "file=/etc/sysconfig/network-scripts/ifcfg-eth$interface_id\r"
193
-        expect "$prompt"
194
-        send "hwaddr=\\\$(grep HWADDR \\\$file)\r"
195
-        expect "$prompt"
196
-        send "uuid=\\\$(grep UUID \\\$file)\r"
192
+        # make backups, remove network manager options, disable defaults, enable boot and disable network manager
193
+        send "sed -i.orig '/^UUID=\\\|^NM_CONTROLLED=/d;s/^\\\(.*\\\)=yes/\\\1=no/g;s/^ONBOOT=.*/ONBOOT=yes/;/^ONBOOT=/iNM_CONTROLLED=no' /etc/sysconfig/network-scripts/ifcfg-eth{0,1,2}\r"
197 194
         expect "$prompt"
198
-        send "echo -e \"\\\$hwaddr\\n\\\$uuid\\nDEVICE=eth$interface_id\\nTYPE=Ethernet\\nONBOOT=yes\\nNM_CONTROLLED=no\\nBOOTPROTO=dhcp\\nPEERDNS=no\" > \\\$file\r"
195
+        # eth1 should be static with private ip address and provided netmask
196
+        send "sed -i 's/^BOOTPROTO=.*/BOOTPROTO=static/;/^BOOTPROTO/aIPADDR=${master_ip_pub_net}\\\nNETMASK=${mask}' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
199 197
         expect "$prompt"
200
-        send "sed \"s/GATEWAY=.*/GATEWAY=\"$gateway_ip\"/g\" -i /etc/sysconfig/network\r"
198
+        # eth2 should get ip address via dhcp and used default route
199
+        send "sed -i 's/^BOOTPROTO=.*/BOOTPROTO=dhcp/;s/^DEFROUTE=.*/DEFROUTE=yes/;/^BOOTPROTO/aPERSISTENT_DHCLIENT=yes' /etc/sysconfig/network-scripts/ifcfg-eth2\r"
201 200
         expect "$prompt"
202
-        send "echo -e \"$nameserver\" > /etc/dnsmasq.upstream\r"
201
+        # make backup and disable zeroconf at all because we should use only DHCP on eth2
202
+        send "sed -i.orig '/NOZEROCONF/d;aNOZEROCONF=yes' /etc/sysconfig/network\r"
203 203
         expect "$prompt"
204
-        send "sed \"s/DNS_UPSTREAM:.*/DNS_UPSTREAM: \\\$(grep \'^nameserver\' /etc/dnsmasq.upstream | cut -d \' \' -f2)/g\" -i /etc/fuel/astute.yaml\r"
204
+        # remove default route from eth0 and system wide settings if exists
205
+        send "sed -i '/^GATEWAY=/d' /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0\r"
205 206
         expect "$prompt"
206
-        send "sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
207
+        # fix bug https://bugs.centos.org/view.php?id=7351
208
+        send "sed -i.orig '/^DEVICE=lo/aTYPE=Loopback' /etc/sysconfig/network-scripts/ifcfg-lo\r"
207 209
         expect "$prompt"
208
-        send "sed -i 's/NM_CONTROLLED=yes/NM_CONTROLLED=no/g' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
210
+        # remove old settings from the resolv.conf and dnsmasq.upstream if exists
211
+        send "sed -i.orig '/^nameserver/d' /etc/resolv.conf /etc/dnsmasq.upstream &>/dev/null\r"
209 212
         expect "$prompt"
210
-        send "sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=static/g' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
213
+        # update the resolv.conf and dnsmasq.upstream with the new settings
214
+        send "echo -e '$nameserver' | tee -a /etc/dnsmasq.upstream >>/etc/resolv.conf\r"
211 215
         expect "$prompt"
212
-        send " echo \"IPADDR=$master_ip_pub_net\" >> /etc/sysconfig/network-scripts/ifcfg-eth1\r"
213
-        expect "$prompt"
214
-        send " echo \"NETMASK=$mask\" >> /etc/sysconfig/network-scripts/ifcfg-eth1\r"
216
+        # update the astute.yaml with the new settings
217
+        send "sed -i.orig '/DNS_UPSTREAM/c\\"DNS_UPSTREAM\\": \\"${dns_upstream}\\"' /etc/fuel/astute.yaml\r"
215 218
         expect "$prompt"
219
+        # enable NAT (MASQUERADE) and forwarding for the public network
216 220
         send "/sbin/iptables -t nat -A POSTROUTING -s $master_pub_net/24 \! -d $master_pub_net/24 -j MASQUERADE\r"
217 221
         expect "$prompt"
218 222
         send "/sbin/iptables -I FORWARD 1 --dst $master_pub_net/24 -j ACCEPT\r"
@@ -221,41 +225,33 @@ enable_outbound_network_for_product_vm() {
221 225
         expect "$prompt"
222 226
         send "service iptables save &>/dev/null\r"
223 227
         expect "$prompt"
224
-        send "dockerctl restart cobbler &>/dev/null\r"
225
-        set timeout 300
226
-        expect "$prompt"
227
-        send "service network restart &>/dev/null\r"
228
-        expect "*OK*"
229
-        expect "$prompt"
230
-        send "dockerctl restart cobbler &>/dev/null\r"
231
-        set timeout 300
232
-        expect "$prompt"
233
-        send "dockerctl check cobbler &>/dev/null\r"
234
-        expect "*ready*"
228
+        # disable NetworkManager and apply the network changes
229
+        send "nmcli networking off &>/dev/null ; service network restart &>/dev/null\r"
235 230
         expect "$prompt"
236 231
         send "logout\r"
237 232
         expect "$prompt"
238 233
 ENDOFEXPECT
239 234
     )
235
+    echo "OK"
240 236
 
241 237
     # Waiting until the network services are restarted.
242 238
     # 5 seconds is optimal time for different operating systems.
243
-    echo -e "\nWaiting until the network services are restarted..."
239
+    echo -n "Waiting until the network services are restarted... "
244 240
     sleep 5s
245
-       result_inet=$(
246
-            execute expect << ENDOFEXPECT
247
-            spawn ssh $ssh_options $username@$ip
248
-            expect "connect to host" exit
249
-            expect "*?assword:*"
250
-            send "$password\r"
251
-            expect "$prompt"
252
-            send "for i in {1..5}; do ping -c 2 google.com || ping -c 2 wikipedia.com || sleep 2; done\r"
253
-            expect "*icmp*"
254
-            expect "$prompt"
255
-            send "logout\r"
256
-            expect "$prompt"
241
+    result_inet=$(
242
+        execute expect << ENDOFEXPECT
243
+        spawn ssh $ssh_options $username@$ip
244
+        expect "connect to host" exit
245
+        expect "*?assword:*"
246
+        send "$password\r"
247
+        expect "$prompt"
248
+        send "for i in {1..5}; do ping -c 2 google.com || ping -c 2 wikipedia.com || sleep 2; done\r"
249
+        expect "*icmp*"
250
+        expect "$prompt"
251
+        send "logout\r"
252
+        expect "$prompt"
257 253
 ENDOFEXPECT
258
-        )
254
+    )
259 255
 
260 256
     # When you are launching command in a sub-shell, there are issues with IFS (internal field separator)
261 257
     # and parsing output as a set of strings. So, we are saving original IFS, replacing it, iterating over lines,
@@ -271,7 +267,8 @@ ENDOFEXPECT
271 267
         if [[ $line == *icmp_seq* ]]; then
272 268
         IFS="${NIFS}"
273 269
             echo "OK"
274
-        return 0;
270
+            wait_for_exec_in_bootstrap $ip $username $password "$prompt" "pkill -f ^wait_for_external_config"
271
+            return 0;
275 272
         fi
276 273
         IFS="${NIFS}"
277 274
     done
@@ -286,4 +283,3 @@ print_no_internet_connectivity_banner() {
286 283
     echo "#          because there is no Internet connectivity       #"
287 284
     echo "############################################################"
288 285
 }
289
-

Loading…
Cancel
Save