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=${installdrive:-undefined}
101 forceformat=${forceformat:-no}
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 45GB
225 tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
226 if [ $tgtdrivesize -lt 46080 ]; then
227 exec < /dev/tty3 > /dev/tty3 2>&1
231 echo '********************************************************************'
234 echo '* Your disk is under 45GB 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=25000 --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 --grow --percent 40 --name=var --fstype=ext4
287 logvol /var/log --vgname=os --grow --percent 60 --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
349 # Add self entry to /etc/hosts
350 ipaddr=$(echo $ip | cut -d: -f1)
351 hostname=$(echo $ip | cut -d: -f5)
352 # Use default hostname if missing from parameters
353 [ -z "$hostname" ] && hostname="fuel.domain.tld"
354 short=$(echo $hostname | cut -d. -f1)
355 echo -e "${ipaddr} ${hostname} ${short}" >> /etc/hosts
362 # Mount installation media in chroot
363 %post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log
367 source "/mnt/sysimage/root/anaconda.cmdline.vars"
369 SOURCE="/mnt/sysimage/tmp/source"
375 nfs_url="${repo#nfs:}"
376 mount -t nfs "${nfs_url}" "${SOURCE}"
379 if [ -d "/mnt/source" ]; then
380 mount -o bind "/mnt/source" "${SOURCE}"
386 # If not mounted, try to bind /run/install/repo since
387 # anaconda shoud mount installation repo to that folder.
388 if ! mountpoint -q "${SOURCE}"; then
389 if [ -d '/run/install/repo' ] && mountpoint -q '/run/install/repo'; then
390 mount -o bind '/run/install/repo' "${SOURCE}"
395 # If still not mounted, try to mount from LABEL / UUID.
396 # It was moved from next phase here to keep all mounting stuff
397 # in one place. All other scripts should use SOURCE variable
398 # for access to dist files.
400 iso_volume_id=OpenStack_Fuel
401 iso_disk_uuid=will_be_substituted_with_actual_uuid
402 FS="/mnt/sysimage/tmp/fs"
404 if ! mountpoint -q "${SOURCE}"; then
405 if [ -e "/dev/disk/by-label/${iso_volume_id}" ]; then
406 mount "/dev/disk/by-label/${iso_volume_id}" "${SOURCE}"
407 elif [ -e "/dev/disk/by-uuid/${iso_disk_uuid}" ]; then
409 mount "/dev/disk/by-uuid/${iso_disk_uuid}" "${FS}"
410 mount -o loop "${FS}/nailgun.iso" "${SOURCE}"
414 # Sleep to capture full log
422 %post --log=/root/anaconda-post-configure-repos.log
428 # this file is provided by fuel-openstack-metadata package
429 OPENSTACK_VERSION=`cat /etc/fuel_openstack_version`
431 # ----------------------
432 # UNPACKING REPOSITORIES
433 # ----------------------
435 wwwdir="/var/www/nailgun"
436 repodir="${wwwdir}/${OPENSTACK_VERSION}"
438 # Copying Centos files
439 mkdir -p ${repodir}/centos/x86_64
440 mkdir -p ${repodir}/mos-centos/x86_64
441 cp -r ${SOURCE}/images ${repodir}/centos/x86_64
442 cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64
443 cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64
444 cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64
445 cp -r ${SOURCE}/mos-centos/repodata ${repodir}/mos-centos/x86_64
446 cp -r ${SOURCE}/mos-centos/Packages ${repodir}/mos-centos/x86_64
447 cp -r ${SOURCE}/extra-repos ${repodir}/
448 cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64
450 # Copying Ubuntu files
451 mkdir -p ${repodir}/ubuntu/x86_64/images
452 cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64
453 cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64
455 # We do not ship debian-installer kernel and initrd on ISO.
456 # But we still need to be able to create ubuntu cobbler distro
457 # which requires kernel and initrd to be available. So, we
458 # just touch these files to work around cobbler's limitation.
459 touch ${repodir}/ubuntu/x86_64/images/linux
460 touch ${repodir}/ubuntu/x86_64/images/initrd.gz
462 # make links for backward compatibility
463 ln -s ${repodir}/centos ${wwwdir}/centos
464 ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu
465 #Make a symlink for mos-centos in /var/www/nailgun in iso/ks.template
466 ln -s ${repodir}/mos-centos ${wwwdir}/mos-centos
467 ln -s ${repodir}/extra-repos ${wwwdir}/extra-repos
469 mkdir -p ${wwwdir}/targetimages
471 cp ${SOURCE}/send2syslog.py /bin/send2syslog.py
472 mkdir -p /var/lib/hiera
473 touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml
475 # Prepare local repository specification
476 rm /etc/yum.repos.d/CentOS*.repo
477 cp ${SOURCE}/extra-repos/extra.repo /etc/yum.repos.d/
478 cat > /etc/yum.repos.d/nailgun.repo << EOF
480 name=Nailgun Local Repo
481 baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/centos/x86_64
485 baseurl=file:/var/www/nailgun/${OPENSTACK_VERSION}/mos-centos/x86_64
494 %post --log=/root/anaconda-post-configure-sysconfig.log
498 source "/root/anaconda.cmdline.vars"
501 # Set correct docker volume group
502 echo "VG=docker" >> /etc/sysconfig/docker-storage-setup
504 # Disable create iptables rules by docker
505 echo "DOCKER_NETWORK_OPTIONS=--iptables=false" > /etc/sysconfig/docker-network
507 # Disable subscription-manager plugins
508 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || :
509 sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || :
511 # Disable GSSAPI in ssh server config
512 sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config
514 # Enable MOTD banner in sshd
515 sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config
517 # Add note regarding local repos creation to MOTD
518 cat >> /etc/motd << EOF
520 All environments use online repositories by default.
521 Use the following commands to create local repositories
522 on master node and change default repository settings:
524 * CentOS: fuel-mirror (see --help for options)
525 * Ubuntu: fuel-mirror (see --help for options)
527 Please refer to the following guide for more information:
528 https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror
532 # Install bootstrap_admin_node.sh and enabling it
533 install -m 0777 -D ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh
534 echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node
536 # Copying version.yaml file. It contains COMMIT_SHA of last commit.
537 RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml)
538 mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions
539 cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml
540 cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml
541 ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml
542 cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml
545 uuidgen > /etc/fuel/fuel-uuid
547 # Prepare bootstrap_admin_node config
548 cat > /etc/fuel/bootstrap_admin_node.conf << EOF
549 #Set to yes to run Fuel Setup
550 #Set to no to accept default settings
551 ADMIN_INTERFACE=${adminif}
552 showmenu=${showmenu:-no}
553 wait_for_external_config=${wait_for_external_config:-no}
556 # Prepare custom /etc/issue logon banner and script for changing IP in it
557 # We can have several interface naming schemes applied and several interface
561 for ip in `ip -o -4 a | grep -e "e[nt][hopsx].*" | awk '{print \$4 }' | cut -d/ -f1`; do
562 ipstr="${ipstr}https://${ip}:8443${NL}"
564 cat > /etc/issue <<EOF
565 #########################################
566 # Welcome to the Fuel server #
567 #########################################
568 Server is running on \m platform
570 Fuel UI is available on:
572 Default administrator login: root
573 Default administrator password: r00tme
575 Default Fuel UI login: admin
576 Default Fuel UI password: admin
578 Please change root password on first login.
582 ######### OPNFV addition BEGIN ############
583 # Copy data into /opt/opnfv
584 # TODO: This ought to be a package instead!
586 cp -r ${SOURCE}/opnfv /opt
587 cp ${SOURCE}/gitinfo.txt /
588 ######### OPNFV addition END ############
594 umount -f ${FS} || true
597 echo "tos orphan 7" >> /etc/ntp.conf
600 sed -i --follow-symlinks -e '/^\slinux16/ s/rhgb/debug/' /boot/grub2/grub.cfg
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 | fgrep -q "virtualbox") && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf
608 # Blacklist intel_rapl module for VirtualBox so it does not create kernel errors
609 (virt-what | fgrep -q "virtualbox") && echo "blacklist intel_rapl" > /etc/modprobe.d/blacklist-intel-rapl.conf
611 # Disable sshd until after Fuel Setup if not running on VirtualBox
612 # TODO(mattymo): Remove VBox exception after LP#1487047 is fixed
613 (virt-what | fgrep -q "virtualbox") || systemctl disable sshd
621 %post --log=/root/anaconda-post-configure-autologon.log
625 # Enable once root autologin for initial setup
626 mkdir -p /etc/systemd/system/getty@tty1.service.d/
627 cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << 'EOF'
630 ExecStart=-/sbin/agetty --autologin root --noclear %I 115200 linux
633 # Exec bootstrap_admin_node.sh if autologin enabled
634 cat >> /root/.bashrc << 'EOF'
635 if [[ "$(tty)" == "/dev/tty1" && -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]]; then
636 rm -Rf "/etc/systemd/system/getty@tty1.service.d"
637 /bin/systemctl daemon-reload
638 if [ -x /usr/local/sbin/bootstrap_admin_node.sh ]; then
639 exec /usr/local/sbin/bootstrap_admin_node.sh
646 %post --nochroot --log=/mnt/sysimage/root/anaconda-post-interface-settings.log
650 source "/mnt/sysimage/root/anaconda.cmdline.vars"
652 if [[ ! -z $adminif ]]; then
653 rm -f /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${ifname%%:*}
654 sed "s/${ifname%%:*}/${adminif}/g" \
655 /etc/sysconfig/network-scripts/ifcfg-${ifname%%:*} > \
656 /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${adminif}