3 %include /tmp/source.ks
11 # ignore unsupported hardware warning
15 # NEVER ever place zerombr here, it breaks automated installation
16 %include /tmp/bootloader.ks
17 %include /tmp/partition.ks
20 # HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE
21 # INSTALLATION PROCESS ITSELF
28 for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do
29 if !(blkid | grep -q "${drv}.*Fuel"); then
30 if (grep -q 0 /sys/block/${drv}/removable); then
31 drives="${drives} ${drv}"
33 removable_drives="${removable_drives} ${drv}"
37 default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'`
39 installdrive=${installdrive:-undefined}
40 forceformat=${forceformat:-no}
41 for I in $(cat /proc/cmdline); do
44 if ! [[ "${I}" =~ "." ]]; then eval "$I"; fi
49 set ${drives} ${removable_drives}
52 tgtdrive="${installdrive}"
54 function confirm_format {
56 local confirm_format="no"
58 if [[ "$forceformat" == "yes" ]] ; then
62 if parted -s /dev/$check_drive print &>/dev/null ; then
64 echo "$check_drive drive contains partition table:"
65 parted -s /dev/$check_drive print
67 read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format
68 if [[ "$confirm_format" == "y" ]] || [[ "$confirm_format" == "Y" ]] || [[ "$forceformat" == "yes" ]]; then
80 if [ $numdrives -lt 1 ]; then
81 exec < /dev/tty3 > /dev/tty3 2>&1
85 echo '********************************************************************'
88 echo '* There is no suitable media available for installation. *'
89 echo '* Please attach a drive and try again. *'
91 echo '********************************************************************'
93 read -p "Press Enter to shut down the system: " _
97 if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then
98 exec < /dev/tty3 > /dev/tty3 2>&1
100 while [ "${tgtdrive}" = "undefined" ]; do
103 echo '********************************************************************************'
104 echo '* W A R N I N G *'
106 echo '* Which of the detected hard drives do you want to be used as *'
107 echo '* the installation target? *'
109 echo '********************************************************************************'
111 echo "Possible choices"
112 echo "Persistent drives: ${drives}"
113 echo "Removable drives: ${removable_drives}"
115 if [ `echo ${drives} | wc -w` -eq 1 ] ; then
116 read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive
118 read -p "Choose hard drive: " tgtdrive
121 for drive in ${drives[@]} ${removable_drives[@]}; do
122 if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then
123 if confirm_format $tgtdrive ; then
124 format_confirmed="yes"
128 read -p "You may select another disk. Press Enter to continue." _
132 if [[ "$match" == "no" ]]; then
134 read -p "Invalid choice. Press Enter to continue." _
140 tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"`
143 if [ "$format_confirmed" != "yes" ] ; then
144 exec < /dev/tty3 > /dev/tty3 2>&1
146 if ! confirm_format $tgtdrive ; then
149 echo '********************************************************************'
152 echo '* Disk $tgtdrive contains active partition(s). *'
153 echo '* Installation cannot continue without confirmation. *'
155 echo '********************************************************************'
157 read -p "Press Enter to restart: " _
163 # verify tgtdrive is at least 41GB
164 tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
165 if [ $tgtdrivesize -lt 41984 ]; then
166 exec < /dev/tty3 > /dev/tty3 2>&1
170 echo '********************************************************************'
173 echo '* Your disk is under 41GB in size. Installation cannot continue. *'
174 echo '* Restart installation with a larger disk. *'
176 echo '********************************************************************'
178 read -p "Press Enter to restart: " _
182 # paths in /dev have "/" instead of "!" for cciss devices
183 tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//')
186 if test -e /dev/disk/by-label/"OpenStack_Fuel"; then
187 echo "harddrive --partition=LABEL="OpenStack_Fuel" --dir=/" > /tmp/source.ks
188 elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
189 echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks
191 echo "cdrom" > /tmp/source.ks
195 dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10
197 hdparm -z /dev/${tgtdrive}
198 parted -s /dev/${tgtdrive} mklabel gpt
199 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24
200 parted -s /dev/${tgtdrive} set 1 bios_grub on
201 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224
202 parted -s /dev/${tgtdrive} set 2 boot on
203 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424
205 hdparm -z /dev/${tgtdrive}
209 # This adds support for the p seperator required for cciss devices
210 if echo ${tgtdrive} | grep -q -e cciss ; then
215 echo > /tmp/partition.ks
216 echo "partition /boot --onpart=/dev/${bootdev}3" >> /tmp/partition.ks
217 echo "partition /boot/efi --onpart=/dev/${bootdev}2" >> /tmp/partition.ks
218 echo "partition pv.001 --ondisk=${tgtdrive} --size=41000 --grow" >> /tmp/partition.ks
219 echo "volgroup os pv.001" >> /tmp/partition.ks
220 echo "logvol swap --vgname=os --recommended --name=swap" >> /tmp/partition.ks
221 echo "logvol / --vgname=os --size=10000 --name=root --fstype=ext4" >> /tmp/partition.ks
222 echo "logvol /var --vgname=os --size=10000 --percent 30 --grow --name=var --fstype=ext4" >> /tmp/partition.ks
223 echo "logvol /var/lib/docker --vgname=os --size=17000 --percent 20 --grow --name=varlibdocker --fstype=ext4" >> /tmp/partition.ks
224 echo "logvol /var/log --vgname=os --size=4096 --percent 50 --grow --name=varlog --fstype=ext4" >> /tmp/partition.ks
228 echo "bootloader --location=partition --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks
230 # Anaconda can not install grub 0.97 on disks which are >4T.
231 # The reason is that grub does not support such large geometries
232 # and it simply thinks that the cylinder number has negative value.
233 # Here we just set geometry manually so that grub thinks that disk
234 # size is equal to 1G.
235 # 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G
236 echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks
237 echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks
238 echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks
239 echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks
240 echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks
241 echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks
242 echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks
246 %packages --nobase --excludedocs
260 fuel-bootstrap-image-builder
262 fuel-target-centos-images6.6
279 ruby21-rubygem-netaddr
280 ruby21-rubygem-openstack
281 selinux-policy-targeted
285 system-config-firewall-base
292 yum-plugin-priorities
294 %include /tmp/post_partition.ks
296 # POSTINSTALL SECTION
297 # HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER
298 # INSTALLATION ITSELF COMPLETED
300 echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules
301 chmod +x /etc/rc.modules
302 echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf
303 mkdir -p /var/log/coredump
304 echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf
305 chmod 777 /var/log/coredump
306 echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf
308 # Mount installation media in chroot
309 %post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log
314 SOURCE="/mnt/sysimage/tmp/source"
316 for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
322 nfs_url="${repo#nfs:}"
323 mount -t nfs "${nfs_url}" "${SOURCE}"
326 if [ -d "/mnt/source" ]; then
327 mount -o bind "/mnt/source" "${SOURCE}"
332 %post --log=/root/anaconda-post-after-chroot.log
338 scrFile="/etc/sysconfig/network-scripts/ifcfg-$admin_interface"
339 search="domain $domain\nsearch $domain"
340 sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network
341 grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts
342 echo "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf
343 [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf
344 [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream
345 [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf
346 [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream
348 echo DEVICE=$admin_interface > $scrFile
349 echo ONBOOT=yes >> $scrFile
350 echo NM_CONTROLLED=no >> $scrFile
351 echo HWADDR=$hwaddr >> $scrFile
352 echo USERCTL=no >> $scrFile
353 echo PEERDNS=no >> $scrFile
355 echo BOOTPROTO=static >> $scrFile
356 echo IPADDR=$ip >> $scrFile
357 echo NETMASK=$netmask >> $scrFile
359 echo BOOTPROTO=dhcp >> $scrFile
361 scrDHCPFile="/etc/sysconfig/network-scripts/ifcfg-$dhcp_interface"
362 #Ignore gateway and set up DHCP if it is used, otherwise apply it
363 if [ $dhcp_interface ] && [ "$dhcp_interface" != "$admin_interface" ]; then
364 echo "DEVICE=$dhcp_interface" > $scrDHCPFile
365 echo "BOOTPROTO=dhcp" >> $scrDHCPFile
366 echo "ONBOOT=yes" >> $scrDHCPFile
367 echo "USERCTL=no" >> $scrDHCPFile
369 echo GATEWAY=$gw >> /etc/sysconfig/network
371 [ -n "$build_images" -a "$build_images" != "0" ] && echo -e "$build_images" > /root/.build_images
375 hostname="nailgun.mirantis.com"
377 for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
379 domain=${hostname#*.}
383 admin_interface=${admin_interface:-"eth0"}
384 hwaddr=`ifconfig $admin_interface | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
385 dhcp_interface=$dhcp_interface
386 build_images=$build_images
387 wait_for_external_config=$wait_for_external_config
390 # Mounting installation source
398 if test -e /dev/disk/by-label/"OpenStack_Fuel"; then
399 mount /dev/disk/by-label/"OpenStack_Fuel" ${SOURCE}
400 elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
401 mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
402 mount -o loop ${FS}/nailgun.iso ${SOURCE}
405 OPENSTACK_VERSION=`cat ${SOURCE}/openstack_version`
407 # ----------------------
408 # UNPACKING REPOSITORIES
409 # ----------------------
411 wwwdir="/var/www/nailgun"
412 repodir="${wwwdir}/${OPENSTACK_VERSION}"
414 # Copying Centos files
415 mkdir -p ${repodir}/centos/x86_64
416 cp -r ${SOURCE}/images ${repodir}/centos/x86_64
417 cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64
418 cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64
419 cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64
420 cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64
422 # Copying Ubuntu files
423 mkdir -p ${repodir}/ubuntu/x86_64/images
424 cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64
425 cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64
427 # We do not ship debian-installer kernel and initrd on ISO.
428 # But we still need to be able to create ubuntu cobbler distro
429 # which requires kernel and initrd to be available. So, we
430 # just touch these files to work around cobbler's limitation.
431 touch ${repodir}/ubuntu/x86_64/images/linux
432 touch ${repodir}/ubuntu/x86_64/images/initrd.gz
434 # make links for backward compatibility
435 ln -s ${repodir}/centos ${wwwdir}/centos
436 ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu
438 # --------------------------
439 # UNPACKING PUPPET MANIFESTS
440 # --------------------------
443 #mkdir -p /etc/puppet/${OPENSTACK_VERSION}/manifests/
444 #mkdir -p /etc/puppet/${OPENSTACK_VERSION}/modules/
445 #rm -rf /etc/puppet/modules/
447 # TODO(ikalnitsky): investigate why we need this
448 #cp ${SOURCE}/puppet-slave.tgz ${wwwdir}/
450 # place modules and manifests
451 #tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/${OPENSTACK_VERSION}/modules
452 #cp /etc/puppet/${OPENSTACK_VERSION}/modules/osnailyfacter/examples/site.pp /etc/puppet/${OPENSTACK_VERSION}/manifests/site.pp
453 cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/${OPENSTACK_VERSION}/manifests/
455 # make links for backward compatibility
457 #ln -s ${OPENSTACK_VERSION}/manifests/ /etc/puppet/manifests
458 #ln -s ${OPENSTACK_VERSION}/modules/ /etc/puppet/modules
461 cp ${SOURCE}/send2syslog.py /bin/send2syslog.py
462 mkdir -p /var/lib/hiera
463 touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml
465 # Prepare local repository specification
466 rm /etc/yum.repos.d/CentOS*.repo
467 cat > /etc/yum.repos.d/nailgun.repo << EOF
469 name=Nailgun Local Repo
470 baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/centos/x86_64
474 # Disable subscription-manager plugins
475 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || :
476 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || :
478 # Disable GSSAPI in ssh server config
479 sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config
481 # Enable MOTD banner in sshd
482 sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config
484 # Add note regarding local repos creation to MOTD
485 cat >> /etc/motd << EOF
487 All environments use online repositories by default.
488 Use the following commands to create local repositories
489 on master node and change default repository settings:
491 * CentOS: fuel-package-updates (see --help for options)
492 * Ubuntu: fuel-createmirror (see --help for options)
494 Please refer to the following guide for more information:
495 https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror
499 # Copying bootstrap_admin_node.sh, chmod it and
500 # adding /etc/init/bootstrap_admin_node.conf
501 cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh
502 chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh
503 cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf
504 echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node
506 # Copying version.yaml file. It contains COMMIT_SHA of last commit.
507 RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml)
508 mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions
509 cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml
510 cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml
511 ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml
512 cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml
515 uuidgen > /etc/fuel/fuel-uuid
518 [ -z "$showmenu" ] && showmenu="no"
520 # Pause during bootstrap_admin_node to wait for external config
521 [ -z "$wait_for_external_config" ] && wait_for_external_config="no"
524 # Prepare bootstrap_admin_node config
525 cat > /etc/fuel/bootstrap_admin_node.conf << EOF
526 #Set to yes to run Fuel Setup
527 #Set to no to accept default settings
528 ADMIN_INTERFACE=${admin_interface}
530 wait_for_external_config=${wait_for_external_config}
533 # Prepare custom /etc/issue logon banner and script for changing IP in it
534 cat > /etc/issue << EOF
535 #########################################
536 # Welcome to the Fuel server #
537 #########################################
538 Server is running on \m platform
540 Fuel UI is available on:
543 Default administrator login: root
544 Default administrator password: r00tme
546 Default Fuel UI login: admin
547 Default Fuel UI password: admin
549 Please change root password on first login.
554 cat >> '/etc/rc.local' << EOF
556 for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do
557 if [ "\$first" = "yes" ]; then
558 ipstr="Fuel UI is available on: https://\$ip:8443"
561 ipstr=\$(printf "%s\n%25s%s" "\$ipstr" " " "https://\$ip:8443")
565 while read -r line; do
566 if [[ "\$line" =~ "Fuel UI is available on" ]]; then
567 echo -e "\$ipstr" >> \$tmpissue
568 elif [[ "\$line" =~ :8443$ ]]; then
571 echo -e "\$line" >> \$tmpissue
574 mv "\$tmpissue" /etc/issue
583 umount -f ${FS} || true
586 echo "tos orphan 7" >> /etc/ntp.conf
588 # Do not show error message on ntpdate failure. Customers should not be confused
589 # if admin node does not have access to the internet time servers.
590 sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/'
593 sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf
594 sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf
596 # Disabling console clearing
597 sed -i 's/getty/getty --noclear/' /etc/init/tty.conf
599 # Disabling starting first console from start-ttys service
600 sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init
602 # Copying default bash settings to the root directory
603 cp -f /etc/skel/.bash* /root/
605 # Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors
606 [[ $(virt-what) = "virtualbox" ]] && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf