3 #%include /tmp/source.ks
12 # ignore unsupported hardware warning
16 repo --name="mos-centos" --baseurl=file:///run/install/repo/mos-centos/ --cost=100
18 # NEVER ever place zerombr here, it breaks automated installation
19 %include /tmp/bootloader.ks
20 %include /tmp/partition.ks
21 %include /tmp/post_partition.ks
42 # NOTE(kozhukalov): We don't need target centos images in 8.0
43 # fuel-target-centos-images7.1.1503
47 fuel-openstack-metadata
63 selinux-policy-targeted
66 system-config-firewall-base
81 # HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE
82 # INSTALLATION PROCESS ITSELF
89 for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do
90 if !(blkid | grep -q "${drv}.*Fuel"); then
91 if (grep -q 0 /sys/block/${drv}/removable); then
92 drives="${drives} ${drv}"
94 removable_drives="${removable_drives} ${drv}"
98 default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'`
100 installdrive="undefined"
102 for I in $(cat /proc/cmdline); do
105 if ! [[ "${I}" =~ "." ]]; then eval "$I"; fi
110 set ${drives} ${removable_drives}
113 tgtdrive="${installdrive}"
115 function confirm_format {
117 local confirm_format="no"
119 if [[ "$forceformat" == "yes" ]] ; then
123 if parted -s /dev/$check_drive print &>/dev/null ; then
125 echo "$check_drive drive contains partition table:"
126 parted -s /dev/$check_drive print
128 read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format
129 if [[ "$confirm_format" == "y" ]] || [[ "$confirm_format" == "Y" ]] || [[ "$forceformat" == "yes" ]]; then
139 format_confirmed="no"
141 if [ $numdrives -lt 1 ]; then
142 exec < /dev/tty3 > /dev/tty3 2>&1
146 echo '********************************************************************'
149 echo '* There is no suitable media available for installation. *'
150 echo '* Please attach a drive and try again. *'
152 echo '********************************************************************'
154 read -p "Press Enter to shut down the system: " _
158 if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then
159 exec < /dev/tty3 > /dev/tty3 2>&1
161 while [ "${tgtdrive}" = "undefined" ]; do
164 echo '********************************************************************************'
165 echo '* W A R N I N G *'
167 echo '* Which of the detected hard drives do you want to be used as *'
168 echo '* the installation target? *'
170 echo '********************************************************************************'
172 echo "Possible choices"
173 echo "Persistent drives: ${drives}"
174 echo "Removable drives: ${removable_drives}"
176 if [ `echo ${drives} | wc -w` -eq 1 ] ; then
177 read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive
179 read -p "Choose hard drive: " tgtdrive
182 for drive in ${drives[@]} ${removable_drives[@]}; do
183 if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then
184 if confirm_format $tgtdrive ; then
185 format_confirmed="yes"
189 read -p "You may select another disk. Press Enter to continue." _
193 if [[ "$match" == "no" ]]; then
195 read -p "Invalid choice. Press Enter to continue." _
201 tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"`
204 if [ "$format_confirmed" != "yes" ] ; then
205 exec < /dev/tty3 > /dev/tty3 2>&1
207 if ! confirm_format $tgtdrive ; then
210 echo '********************************************************************'
213 echo '* Disk $tgtdrive contains active partition(s). *'
214 echo '* Installation cannot continue without confirmation. *'
216 echo '********************************************************************'
218 read -p "Press Enter to restart: " _
224 # verify tgtdrive is at least 41GB
225 tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
226 if [ $tgtdrivesize -lt 41984 ]; then
227 exec < /dev/tty3 > /dev/tty3 2>&1
231 echo '********************************************************************'
234 echo '* Your disk is under 41GB in size. Installation cannot continue. *'
235 echo '* Restart installation with a larger disk. *'
237 echo '********************************************************************'
239 read -p "Press Enter to restart: " _
243 # paths in /dev have "/" instead of "!" for cciss devices
244 tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//')
247 if test -e /dev/disk/by-label/OpenStack_Fuel; then
248 echo "harddrive --partition=LABEL=OpenStack_Fuel --dir=/" > /tmp/source.ks
249 elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
250 echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks
252 echo "cdrom" > /tmp/source.ks
255 vgdisplay -c | cut -d':' -f1 | xargs vgremove -ff
256 dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10
258 hdparm -z /dev/${tgtdrive}
259 parted -s /dev/${tgtdrive} mklabel gpt
260 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0% 24
261 parted -s /dev/${tgtdrive} set 1 bios_grub on
262 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224
263 parted -s /dev/${tgtdrive} set 2 boot on
264 parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424
266 hdparm -z /dev/${tgtdrive}
270 # This adds support for the p seperator required for cciss devices
271 if echo ${tgtdrive} | grep -q -e cciss ; then
277 cat << EOF > /tmp/partition.ks
278 part /boot --onpart=/dev/${bootdev}3
279 part /boot/efi --onpart=/dev/${bootdev}2
280 part pv.001 --ondisk=${tgtdrive} --size=1 --grow
281 part pv.002 --ondisk=${tgtdrive} --size=20000
283 volgroup docker pv.002
284 logvol swap --vgname=os --recommended --name=swap
285 logvol / --vgname=os --size=10000 --name=root --fstype=ext4
286 logvol /var --vgname=os --size=10000 --name=var --fstype=ext4
287 logvol /var/log --vgname=os --size=4000 --grow --name=varlog --fstype=ext4
293 echo "bootloader --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks
295 # Anaconda can not install grub 0.97 on disks which are >4T.
296 # The reason is that grub does not support such large geometries
297 # and it simply thinks that the cylinder number has negative value.
298 # Here we just set geometry manually so that grub thinks that disk
299 # size is equal to 1G.
300 # 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G
301 echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks
302 echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks
303 echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks
304 echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks
305 echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks
306 echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks
307 echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks
308 echo "%end" >> /tmp/post_partition.ks
315 # POSTINSTALL SECTIONS
316 # HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER
317 # INSTALLATION ITSELF COMPLETED
320 # Parse /proc/cmdline and save for next steps
321 %post --log=/root/anaconda-parse-cmdline.log
325 # Parse cmdline to alter keys which contains dot in their names
326 # Such keys can't be used as variables in bash,
327 # so every dot is replaced with double underscore.
328 # Double underscore needed to avoid possible naming collisions.
329 for item in $(cat /proc/cmdline); do
330 if [[ "${item}" =~ '=' ]]; then
338 value="${value:-'yes'}"
339 echo "${key}=${value}" >> /root/anaconda.cmdline.vars
342 source /root/anaconda.cmdline.vars
344 if [[ ! -z $ifname ]]; then
345 echo "adminif=$(udevadm info --query=property -p /sys/class/net/${ifname%%:*} | \
346 awk -F\= '$1 == "ID_NET_NAME_ONBOARD" {s=$2; exit}; $1 == "ID_NET_NAME_SLOT" {s=$2; exit}; $1 == "ID_NET_NAME_PATH" {s=$2; next}; END {print s}')" >> /root/anaconda.cmdline.vars
355 # Mount installation media in chroot
356 %post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log
360 source "/mnt/sysimage/root/anaconda.cmdline.vars"
362 SOURCE="/mnt/sysimage/tmp/source"
368 nfs_url="${repo#nfs:}"
369 mount -t nfs "${nfs_url}" "${SOURCE}"
372 if [ -d "/mnt/source" ]; then
373 mount -o bind "/mnt/source" "${SOURCE}"
383 %post --log=/root/anaconda-post-configure-repos.log
387 # Mounting installation source
394 if test -e /dev/disk/by-label/OpenStack_Fuel; then
395 mount /dev/disk/by-label/OpenStack_Fuel ${SOURCE}
396 elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
397 mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
398 mount -o loop ${FS}/nailgun.iso ${SOURCE}
401 # this file is provided by fuel-openstack-metadata package
402 OPENSTACK_VERSION=`cat /etc/fuel_openstack_version`
404 # ----------------------
405 # UNPACKING REPOSITORIES
406 # ----------------------
408 wwwdir="/var/www/nailgun"
409 repodir="${wwwdir}/${OPENSTACK_VERSION}"
411 # Copying Centos files
412 mkdir -p ${repodir}/centos/x86_64
413 mkdir -p ${repodir}/mos-centos/x86_64
414 cp -r ${SOURCE}/images ${repodir}/centos/x86_64
415 cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64
416 cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64
417 cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64
418 cp -r ${SOURCE}/mos-centos/repodata ${repodir}/mos-centos/x86_64
419 cp -r ${SOURCE}/mos-centos/Packages ${repodir}/mos-centos/x86_64
420 cp -r ${SOURCE}/extra-repos ${repodir}/
421 cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64
423 # Copying Ubuntu files
424 mkdir -p ${repodir}/ubuntu/x86_64/images
425 cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64
426 cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64
428 # We do not ship debian-installer kernel and initrd on ISO.
429 # But we still need to be able to create ubuntu cobbler distro
430 # which requires kernel and initrd to be available. So, we
431 # just touch these files to work around cobbler's limitation.
432 touch ${repodir}/ubuntu/x86_64/images/linux
433 touch ${repodir}/ubuntu/x86_64/images/initrd.gz
435 # make links for backward compatibility
436 ln -s ${repodir}/centos ${wwwdir}/centos
437 ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu
438 #Make a symlink for mos-centos in /var/www/nailgun in iso/ks.template
439 ln -s ${repodir}/mos-centos ${wwwdir}/mos-centos
440 ln -s ${repodir}/extra-repos ${wwwdir}/extra-repos
442 mkdir -p ${wwwdir}/targetimages
444 cp ${SOURCE}/send2syslog.py /bin/send2syslog.py
445 mkdir -p /var/lib/hiera
446 touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml
448 # Prepare local repository specification
449 rm /etc/yum.repos.d/CentOS*.repo
450 cp ${SOURCE}/extra-repos/extra.repo /etc/yum.repos.d/
451 cat > /etc/yum.repos.d/nailgun.repo << EOF
453 name=Nailgun Local Repo
454 baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/centos/x86_64
458 baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/mos-centos/x86_64
467 %post --log=/root/anaconda-post-configure-sysconfig.log
471 source "/root/anaconda.cmdline.vars"
474 # Set correct docker volume group
475 echo "VG=docker" >> /etc/sysconfig/docker-storage-setup
477 # Disable create iptables rules by docker
478 echo "DOCKER_NETWORK_OPTIONS=--iptables=false" > /etc/sysconfig/docker-network
480 # Disable subscription-manager plugins
481 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || :
482 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || :
484 # Disable GSSAPI in ssh server config
485 sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config
487 # Enable MOTD banner in sshd
488 sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config
490 # Add note regarding local repos creation to MOTD
491 cat >> /etc/motd << EOF
493 All environments use online repositories by default.
494 Use the following commands to create local repositories
495 on master node and change default repository settings:
497 * CentOS: fuel-mirror (see --help for options)
498 * Ubuntu: fuel-mirror (see --help for options)
500 Please refer to the following guide for more information:
501 https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror
505 # Install bootstrap_admin_node.sh and enabling it
506 install -m 0777 -D ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh
507 echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node
509 # Copying version.yaml file. It contains COMMIT_SHA of last commit.
510 RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml)
511 mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions
512 cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml
513 cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml
514 ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml
515 cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml
518 uuidgen > /etc/fuel/fuel-uuid
520 # Prepare bootstrap_admin_node config
521 cat > /etc/fuel/bootstrap_admin_node.conf << EOF
522 #Set to yes to run Fuel Setup
523 #Set to no to accept default settings
524 ADMIN_INTERFACE=${adminif}
525 showmenu=${showmenu:-no}
526 wait_for_external_config=${wait_for_external_config:-no}
529 # Prepare custom /etc/issue logon banner and script for changing IP in it
530 # We can have several interface naming schemes applied and several interface
534 for ip in `ip -o -4 a | grep -e "e[nt][hopsx].*" | awk '{print \$4 }' | cut -d/ -f1`; do
535 ipstr="${ipstr}https://${ip}:8443${NL}"
537 cat > /etc/issue <<EOF
538 #########################################
539 # Welcome to the Fuel server #
540 #########################################
541 Server is running on \m platform
543 Fuel UI is available on:
545 Default administrator login: root
546 Default administrator password: r00tme
548 Default Fuel UI login: admin
549 Default Fuel UI password: admin
551 Please change root password on first login.
555 ######### OPNFV addition BEGIN ############
556 # Copy data into /opt/opnfv
557 # TODO: This ought to be a package instead!
559 cp -r ${SOURCE}/opnfv /opt
560 cp ${SOURCE}/gitinfo.txt /
561 ######### OPNFV addition END ############
567 umount -f ${FS} || true
570 echo "tos orphan 7" >> /etc/ntp.conf
573 sed -i --follow-symlinks -e '/^\slinux16/ s/rhgb/debug/' /boot/grub2/grub.cfg
575 # Copying default bash settings to the root directory
576 cp -f /etc/skel/.bash* /root/
578 # Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors
579 (virt-what | fgrep -q "virtualbox") && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf
581 # Blacklist intel_rapl module for VirtualBox so it does not create kernel errors
582 (virt-what | fgrep -q "virtualbox") && echo "blacklist intel_rapl" > /etc/modprobe.d/blacklist-intel-rapl.conf
584 # Disable sshd until after Fuel Setup if not running on VirtualBox
585 # TODO(mattymo): Remove VBox exception after LP#1487047 is fixed
586 (virt-what | fgrep -q "virtualbox") || systemctl disable sshd
594 %post --log=/root/anaconda-post-configure-autologon.log
598 # Enable once root autologin for initial setup
599 mkdir -p /etc/systemd/system/getty@tty1.service.d/
600 cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << 'EOF'
603 ExecStart=-/sbin/agetty --autologin root --noclear %I 115200 linux
606 # Exec bootstrap_admin_node.sh if autologin enabled
607 cat >> /root/.bashrc << 'EOF'
608 if [[ "$(tty)" == "/dev/tty1" && -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]]; then
609 rm -Rf "/etc/systemd/system/getty@tty1.service.d"
610 /bin/systemctl daemon-reload
611 if [ -x /usr/local/sbin/bootstrap_admin_node.sh ]; then
612 exec /usr/local/sbin/bootstrap_admin_node.sh
619 %post --nochroot --log=/mnt/sysimage/root/anaconda-post-interface-settings.log
623 source "/mnt/sysimage/root/anaconda.cmdline.vars"
625 if [[ ! -z $adminif ]]; then
626 rm -f /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${ifname%%:*}
627 sed "s/${ifname%%:*}/${adminif}/g" \
628 /etc/sysconfig/network-scripts/ifcfg-${ifname%%:*} > \
629 /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${adminif}