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="undefined"
41 for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
43 set ${drives} ${removable_drives}
46 tgtdrive="${installdrive}"
48 function confirm_format {
50 local confirm_format="no"
52 if [[ "$forceformat" == "yes" ]] ; then
56 if parted -s /dev/$check_drive print &>/dev/null ; then
58 echo "$check_drive drive contains partition table:"
59 parted -s /dev/$check_drive print
61 read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format
62 if [[ "$confirm_format" == "y" ]] || [[ "$confirm_format" == "Y" ]] || [[ "$forceformat" == "yes" ]]; then
74 if [ $numdrives -lt 1 ]; then
75 exec < /dev/tty3 > /dev/tty3 2>&1
79 echo '********************************************************************'
82 echo '* There is no suitable media available for installation. *'
83 echo '* Please attach a drive and try again. *'
85 echo '********************************************************************'
87 read -p "Press Enter to shut down the system: " _
91 if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then
92 exec < /dev/tty3 > /dev/tty3 2>&1
94 while [ "${tgtdrive}" = "undefined" ]; do
97 echo '********************************************************************************'
98 echo '* W A R N I N G *'
100 echo '* Which of the detected hard drives do you want to be used as *'
101 echo '* the installation target? *'
103 echo '********************************************************************************'
105 echo "Possible choices"
106 echo "Persistent drives: ${drives}"
107 echo "Removable drives: ${removable_drives}"
109 if [ `echo ${drives} | wc -w` -eq 1 ] ; then
110 read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive
112 read -p "Choose hard drive: " tgtdrive
115 for drive in ${drives[@]} ${removable_drives[@]}; do
116 if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then
117 if confirm_format $tgtdrive ; then
118 format_confirmed="yes"
122 read -p "You may select another disk. Press Enter to continue." _
126 if [[ "$match" == "no" ]]; then
128 read -p "Invalid choice. Press Enter to continue." _
134 tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"`
137 if [ "$format_confirmed" != "yes" ] ; then
138 exec < /dev/tty3 > /dev/tty3 2>&1
140 if ! confirm_format $tgtdrive ; then
143 echo '********************************************************************'
146 echo '* Disk $tgtdrive contains active partition(s). *'
147 echo '* Installation cannot continue without confirmation. *'
149 echo '********************************************************************'
151 read -p "Press Enter to restart: " _
157 # verify tgtdrive is at least 41GB
158 tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
159 if [ $tgtdrivesize -lt 41984 ]; then
160 exec < /dev/tty3 > /dev/tty3 2>&1
164 echo '********************************************************************'
167 echo '* Your disk is under 41GB in size. Installation cannot continue. *'
168 echo '* Restart installation with a larger disk. *'
170 echo '********************************************************************'
172 read -p "Press Enter to restart: " _
176 # paths in /dev have "/" instead of "!" for cciss devices
177 tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//')
180 if test -e /dev/disk/by-label/"OpenStack_Fuel"; then
181 echo "harddrive --partition=LABEL="OpenStack_Fuel" --dir=/" > /tmp/source.ks
182 elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
183 echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks
185 echo "cdrom" > /tmp/source.ks
189 dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10
191 hdparm -z /dev/${tgtdrive}
192 parted -s /dev/${tgtdrive} mklabel gpt
193 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24
194 parted -s /dev/${tgtdrive} set 1 bios_grub on
195 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224
196 parted -s /dev/${tgtdrive} set 2 boot on
197 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424
199 hdparm -z /dev/${tgtdrive}
203 # This adds support for the p seperator required for cciss devices
204 if echo ${tgtdrive} | grep -q -e cciss ; then
209 echo > /tmp/partition.ks
210 echo "partition /boot --onpart=/dev/${bootdev}3" >> /tmp/partition.ks
211 echo "partition /boot/efi --onpart=/dev/${bootdev}2" >> /tmp/partition.ks
212 echo "partition pv.001 --ondisk=${tgtdrive} --size=41000 --grow" >> /tmp/partition.ks
213 echo "volgroup os pv.001" >> /tmp/partition.ks
214 echo "logvol swap --vgname=os --recommended --name=swap" >> /tmp/partition.ks
215 echo "logvol / --vgname=os --size=10000 --name=root --fstype=ext4" >> /tmp/partition.ks
216 echo "logvol /var --vgname=os --size=10000 --percent 30 --grow --name=var --fstype=ext4" >> /tmp/partition.ks
217 echo "logvol /var/lib/docker --vgname=os --size=17000 --percent 20 --grow --name=varlibdocker --fstype=ext4" >> /tmp/partition.ks
218 echo "logvol /var/log --vgname=os --size=4096 --percent 50 --grow --name=varlog --fstype=ext4" >> /tmp/partition.ks
222 echo "bootloader --location=partition --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks
224 # Anaconda can not install grub 0.97 on disks which are >4T.
225 # The reason is that grub does not support such large geometries
226 # and it simply thinks that the cylinder number has negative value.
227 # Here we just set geometry manually so that grub thinks that disk
228 # size is equal to 1G.
229 # 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G
230 echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks
231 echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks
232 echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks
233 echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks
234 echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks
235 echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks
236 echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks
240 %packages --nobase --excludedocs
254 fuel-bootstrap-image-builder
256 fuel-target-centos-images6.6
273 ruby21-rubygem-netaddr
274 ruby21-rubygem-openstack
275 selinux-policy-targeted
279 system-config-firewall-base
286 yum-plugin-priorities
288 %include /tmp/post_partition.ks
290 # POSTINSTALL SECTION
291 # HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER
292 # INSTALLATION ITSELF COMPLETED
294 echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules
295 chmod +x /etc/rc.modules
296 echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf
297 mkdir -p /var/log/coredump
298 echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf
299 chmod 777 /var/log/coredump
300 echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf
302 # Mount installation media in chroot
303 %post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log
308 SOURCE="/mnt/sysimage/tmp/source"
310 for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
316 nfs_url="${repo#nfs:}"
317 mount -t nfs "${nfs_url}" "${SOURCE}"
320 if [ -d "/mnt/source" ]; then
321 mount -o bind "/mnt/source" "${SOURCE}"
326 %post --log=/root/anaconda-post-after-chroot.log
332 scrFile="/etc/sysconfig/network-scripts/ifcfg-$admin_interface"
333 search="domain $domain\nsearch $domain"
334 sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network
335 grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts
336 echo "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf
337 [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf
338 [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream
339 [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf
340 [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream
342 echo DEVICE=$admin_interface > $scrFile
343 echo ONBOOT=yes >> $scrFile
344 echo NM_CONTROLLED=no >> $scrFile
345 echo HWADDR=$hwaddr >> $scrFile
346 echo USERCTL=no >> $scrFile
347 echo PEERDNS=no >> $scrFile
349 echo BOOTPROTO=static >> $scrFile
350 echo IPADDR=$ip >> $scrFile
351 echo NETMASK=$netmask >> $scrFile
353 echo BOOTPROTO=dhcp >> $scrFile
355 scrDHCPFile="/etc/sysconfig/network-scripts/ifcfg-$dhcp_interface"
356 #Ignore gateway and set up DHCP if it is used, otherwise apply it
357 if [ $dhcp_interface ] && [ "$dhcp_interface" != "$admin_interface" ]; then
358 echo "DEVICE=$dhcp_interface" > $scrDHCPFile
359 echo "BOOTPROTO=dhcp" >> $scrDHCPFile
360 echo "ONBOOT=yes" >> $scrDHCPFile
361 echo "USERCTL=no" >> $scrDHCPFile
363 echo GATEWAY=$gw >> /etc/sysconfig/network
365 [ -n "$build_images" -a "$build_images" != "0" ] && echo -e "$build_images" > /root/.build_images
369 hostname="nailgun.mirantis.com"
371 for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
373 domain=${hostname#*.}
377 admin_interface=${admin_interface:-"eth0"}
378 hwaddr=`ifconfig $admin_interface | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
379 dhcp_interface=$dhcp_interface
380 build_images=$build_images
381 wait_for_external_config=$wait_for_external_config
384 # Mounting installation source
392 if test -e /dev/disk/by-label/"OpenStack_Fuel"; then
393 mount /dev/disk/by-label/"OpenStack_Fuel" ${SOURCE}
394 elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
395 mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
396 mount -o loop ${FS}/nailgun.iso ${SOURCE}
399 OPENSTACK_VERSION=`cat ${SOURCE}/openstack_version`
401 # ----------------------
402 # UNPACKING REPOSITORIES
403 # ----------------------
405 wwwdir="/var/www/nailgun"
406 repodir="${wwwdir}/${OPENSTACK_VERSION}"
408 # Copying Centos files
409 mkdir -p ${repodir}/centos/x86_64
410 cp -r ${SOURCE}/images ${repodir}/centos/x86_64
411 cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64
412 cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64
413 cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64
414 cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64
416 # Copying Ubuntu files
417 mkdir -p ${repodir}/ubuntu/x86_64/images
418 cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64
419 cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64
421 # We do not ship debian-installer kernel and initrd on ISO.
422 # But we still need to be able to create ubuntu cobbler distro
423 # which requires kernel and initrd to be available. So, we
424 # just touch these files to work around cobbler's limitation.
425 touch ${repodir}/ubuntu/x86_64/images/linux
426 touch ${repodir}/ubuntu/x86_64/images/initrd.gz
428 # make links for backward compatibility
429 ln -s ${repodir}/centos ${wwwdir}/centos
430 ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu
432 # --------------------------
433 # UNPACKING PUPPET MANIFESTS
434 # --------------------------
437 #mkdir -p /etc/puppet/${OPENSTACK_VERSION}/manifests/
438 #mkdir -p /etc/puppet/${OPENSTACK_VERSION}/modules/
439 #rm -rf /etc/puppet/modules/
441 # TODO(ikalnitsky): investigate why we need this
442 #cp ${SOURCE}/puppet-slave.tgz ${wwwdir}/
444 # place modules and manifests
445 #tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/${OPENSTACK_VERSION}/modules
446 #cp /etc/puppet/${OPENSTACK_VERSION}/modules/osnailyfacter/examples/site.pp /etc/puppet/${OPENSTACK_VERSION}/manifests/site.pp
447 cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/${OPENSTACK_VERSION}/manifests/
449 # make links for backward compatibility
451 #ln -s ${OPENSTACK_VERSION}/manifests/ /etc/puppet/manifests
452 #ln -s ${OPENSTACK_VERSION}/modules/ /etc/puppet/modules
455 cp ${SOURCE}/send2syslog.py /bin/send2syslog.py
456 mkdir -p /var/lib/hiera
457 touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml
459 # Prepare local repository specification
460 rm /etc/yum.repos.d/CentOS*.repo
461 cat > /etc/yum.repos.d/nailgun.repo << EOF
463 name=Nailgun Local Repo
464 baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/centos/x86_64
468 # Disable subscription-manager plugins
469 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || :
470 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || :
472 # Disable GSSAPI in ssh server config
473 sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config
475 # Enable MOTD banner in sshd
476 sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config
478 # Add note regarding local repos creation to MOTD
479 cat >> /etc/motd << EOF
481 All environments use online repositories by default.
482 Use the following commands to create local repositories
483 on master node and change default repository settings:
485 * CentOS: fuel-package-updates (see --help for options)
486 * Ubuntu: fuel-createmirror (see --help for options)
488 Please refer to the following guide for more information:
489 https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror
493 # Copying bootstrap_admin_node.sh, chmod it and
494 # adding /etc/init/bootstrap_admin_node.conf
495 cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh
496 chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh
497 cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf
498 echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node
500 # Copying version.yaml file. It contains COMMIT_SHA of last commit.
501 RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml)
502 mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions
503 cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml
504 cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml
505 ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml
506 cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml
509 uuidgen > /etc/fuel/fuel-uuid
512 [ -z "$showmenu" ] && showmenu="no"
514 # Pause during bootstrap_admin_node to wait for external config
515 [ -z "$wait_for_external_config" ] && wait_for_external_config="no"
518 # Prepare bootstrap_admin_node config
519 cat > /etc/fuel/bootstrap_admin_node.conf << EOF
520 #Set to yes to run Fuel Setup
521 #Set to no to accept default settings
522 ADMIN_INTERFACE=${admin_interface}
524 wait_for_external_config=${wait_for_external_config}
527 # Prepare custom /etc/issue logon banner and script for changing IP in it
528 cat > /etc/issue << EOF
529 #########################################
530 # Welcome to the Fuel server #
531 #########################################
532 Server is running on \m platform
534 Fuel UI is available on:
537 Default administrator login: root
538 Default administrator password: r00tme
540 Default Fuel UI login: admin
541 Default Fuel UI password: admin
543 Please change root password on first login.
548 cat >> '/etc/rc.local' << EOF
550 for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do
551 if [ "\$first" = "yes" ]; then
552 ipstr="Fuel UI is available on: https://\$ip:8443"
555 ipstr=\$(printf "%s\n%25s%s" "\$ipstr" " " "https://\$ip:8443")
559 while read -r line; do
560 if [[ "\$line" =~ "Fuel UI is available on" ]]; then
561 echo -e "\$ipstr" >> \$tmpissue
562 elif [[ "\$line" =~ :8443$ ]]; then
565 echo -e "\$line" >> \$tmpissue
568 mv "\$tmpissue" /etc/issue
577 umount -f ${FS} || true
580 echo "tos orphan 7" >> /etc/ntp.conf
582 # Do not show error message on ntpdate failure. Customers should not be confused
583 # if admin node does not have access to the internet time servers.
584 sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/'
587 sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf
588 sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf
590 # Disabling console clearing
591 sed -i 's/getty/getty --noclear/' /etc/init/tty.conf
593 # Disabling starting first console from start-ttys service
594 sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init
596 # Copying default bash settings to the root directory
597 cp -f /etc/skel/.bash* /root/
599 # Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors
600 [[ $(virt-what) = "virtualbox" ]] && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf