2 # Copyright (c) 2019 Wind River Systems, Inc.
3 # SPDX-License-Identifier: Apache-2.0
7 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
8 # . /tmp/ks-functions.sh
11 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
13 # Copyright (c) 2019 Wind River Systems, Inc.
15 # SPDX-License-Identifier: Apache-2.0
18 function get_by_path()
20 local disk=\$(cd /dev ; readlink -f \$1)
21 for p in /dev/disk/by-path/*; do
22 if [ "\$disk" = "\$(readlink -f \$p)" ]; then
31 echo \$(cd /dev ; readlink -f \$1)
34 function report_pre_failure_with_msg()
37 echo -e '\n\nInstallation failed.\n'
43 function report_post_failure_with_msg()
46 cat <<EOF >> /etc/motd
52 echo "\$msg" >/etc/platform/installation_failed
54 echo -e '\n\nInstallation failed.\n'
60 function report_post_failure_with_logfile()
63 cat <<EOF >> /etc/motd
66 Please see \$logfile for details of failure
69 echo \$logfile >/etc/platform/installation_failed
71 echo -e '\n\nInstallation failed.\n'
77 function get_http_port()
79 echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
87 # This file defines functions that can be used in %pre and %post kickstart sections, by including:
88 # . /tmp/ks-functions.sh
91 cat <<END_FUNCTIONS >/tmp/ks-functions.sh
93 # Copyright (c) 2019 Wind River Systems, Inc.
95 # SPDX-License-Identifier: Apache-2.0
98 function get_by_path()
100 local disk=\$(cd /dev ; readlink -f \$1)
101 for p in /dev/disk/by-path/*; do
102 if [ "\$disk" = "\$(readlink -f \$p)" ]; then
111 echo \$(cd /dev ; readlink -f \$1)
114 function report_pre_failure_with_msg()
117 echo -e '\n\nInstallation failed.\n'
123 function report_post_failure_with_msg()
126 cat <<EOF >> /etc/motd
132 echo "\$msg" >/etc/platform/installation_failed
134 echo -e '\n\nInstallation failed.\n'
140 function report_post_failure_with_logfile()
143 cat <<EOF >> /etc/motd
146 Please see \$logfile for details of failure
149 echo \$logfile >/etc/platform/installation_failed
151 echo -e '\n\nInstallation failed.\n'
157 function get_http_port()
159 echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
167 # Template from: pre_common_head.cfg
170 # Source common functions
171 . /tmp/ks-functions.sh
173 # First, parse /proc/cmdline to find the boot args
174 set -- `cat /proc/cmdline`
175 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
178 if [ -n "$console" ] ; then
179 append="console=$console"
182 if [ -n "$security_profile" ]; then
183 append="$append security_profile=$security_profile"
186 #### SECURITY PROFILE HANDLING (Pre Installation) ####
187 if [ -n "$security_profile" ] && [ "$security_profile" == "extended" ]; then
188 # IMA specific boot options:
189 # Enable Kernel auditing
190 append="$append audit=1"
192 # we need to blacklist the IMA and Integrity Modules
193 # on standard security profile
194 append="$append module_blacklist=integrity,ima"
196 # Disable Kernel auditing in Standard Security Profile mode
197 append="$append audit=0"
200 if [ -n "$tboot" ]; then
201 append="$append tboot=$tboot"
203 append="$append tboot=false"
207 if [ -n "$boot_device" ] ; then
208 boot_device_arg="--boot-drive=$(get_by_path $boot_device)"
211 echo "bootloader --location=mbr $boot_device_arg --timeout=5 --append=\"$append\"" > /tmp/bootloader-include
213 echo "timezone --nontp --utc UTC" >/tmp/timezone-include
220 %include /tmp/timezone-include
221 # set to 'x' so we can use shadow password
224 authconfig --enableshadow --passalgo=sha512
225 firewall --service=ssh
227 # The following is the partition information you requested
228 # Note that any partitions you deleted are not expressed
229 # here so unless you clear all partitions first, this is
230 # not guaranteed to work
233 # Disk layout from %pre
234 %include /tmp/part-include
235 # Bootloader parms from %pre
236 %include /tmp/bootloader-include
241 # Template from: pre_net_common.cfg
244 # Setup ntp.conf and sync time
245 cat <<EOF >/etc/ntp_kickstart.conf
249 /usr/sbin/ntpd -g -q -n -c /etc/ntp_kickstart.conf
250 if [ $? -eq 0 ]; then
251 /sbin/hwclock --systohc --utc
257 # Template from: pre_pkglist.cfg
261 -kernel-module-igb-uio-rt
262 -kernel-module-wrs-avp-rt
266 -kernel-rt-tools-libs
274 -mlnx-ofa_kernel-rt-modules
276 @platform-controller-worker
277 @updates-controller-worker
281 # Template from: pre_disk_setup_common.cfg
284 # Source common functions
285 . /tmp/ks-functions.sh
287 # This is a really fancy way of finding the first usable disk for the
288 # install and not stomping on the USB device if it comes up first
290 # First, parse /proc/cmdline to find the boot args
291 set -- `cat /proc/cmdline`
292 for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
294 # Find either the ISO or USB device first chopping off partition
295 ISO_DEV=`readlink /dev/disk/by-label/oe_iso_boot`
296 sdev=`echo $ISO_DEV | sed -e 's/.$//'`
297 if [ -e /dev/disk/by-label/$sdev ] ; then
300 USB_DEV=`readlink /dev/disk/by-label/wr_usb_boot`
301 sdev=`echo $USB_DEV | sed -e 's/.$//'`
302 if [ -e /dev/disk/by-label/$sdev ] ; then
306 # Temporary, until lab pxelinux.cfg files are updated to specify install devices
307 if [ -z "$rootfs_device" -o -z "$boot_device" ]
310 # Prefer a vd* device if this is kvm/qemu
311 for e in vda vdb sda sdb nvme0n1; do
312 if [ -e /dev/$e -a "$ISO_DEV" != "../../$e" -a "$USB_DEV" != "../../$e" ] ; then
318 # Set variables to $INST_HDD if not set
319 rootfs_device=${rootfs_device:-$INST_HDD}
320 boot_device=${boot_device:-$INST_HDD}
324 orig_rootfs_device=$rootfs_device
325 rootfs_device=$(get_by_path $rootfs_device)
327 orig_boot_device=$boot_device
328 boot_device=$(get_by_path $boot_device)
330 if [ ! -e "$rootfs_device" -o ! -e "$boot_device" ] ; then
331 # Touch this file to prevent Anaconda from dying an ungraceful death
332 touch /tmp/part-include
334 report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is invalid."
337 # Ensure specified device is not a USB drive
338 udevadm info --query=property --name=$rootfs_device |grep -q '^ID_BUS=usb' || \
339 udevadm info --query=property --name=$boot_device |grep -q '^ID_BUS=usb'
340 if [ $? -eq 0 ]; then
341 # Touch this file to prevent Anaconda from dying an ungraceful death
342 touch /tmp/part-include
344 report_pre_failure_with_msg "ERROR: Specified installation ($orig_rootfs_device) or boot ($orig_boot_device) device is a USB drive."
347 # Deactivate existing volume groups to avoid Anaconda issues with pre-existing groups
348 vgs --noheadings -o vg_name | xargs --no-run-if-empty -n 1 vgchange -an
350 # Remove volumes and group for cgts-vg, if any
351 lvremove --force cgts-vg
352 pvs --select 'vg_name=cgts-vg' --noheadings -o pv_name | xargs --no-run-if-empty pvremove --force --force --yes
353 vgs --select 'vg_name=cgts-vg' --noheadings -o vg_name | xargs --no-run-if-empty vgremove --force
356 if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
357 # In an upgrade, only wipe the disk with the rootfs and boot partition
358 echo "In upgrade, wiping only $rootfs_device"
359 WIPE_HDD="$(get_disk $rootfs_device)"
360 ONLYUSE_HDD="$(basename $(get_disk $rootfs_device))"
361 if [ "$(get_disk $rootfs_device)" != "$(get_disk $boot_device)" ]; then
362 WIPE_HDD="$WIPE_HDD,$(get_disk $boot_device)"
363 ONLYUSE_HDD="$ONLYUSE_HDD,$(basename $(get_disk $boot_device))"
366 # Make a list of all the hard drives that are to be wiped
368 # Partition type OSD has a unique globally identifier
369 part_type_guid_str="Partition GUID code"
370 CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
372 # Check if we wipe OSDs
373 if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ]; then
374 echo "Wipe OSD data."
375 WIPE_CEPH_OSDS="true"
377 echo "Skip Ceph OSD data wipe."
378 WIPE_CEPH_OSDS="false"
381 for f in /dev/disk/by-path/*
383 dev=$(readlink -f $f)
384 lsblk --nodeps --pairs $dev | grep -q 'TYPE="disk"'
390 # Avoid wiping USB drives
391 udevadm info --query=property --name=$dev |grep -q '^ID_BUS=usb' && continue
393 # Avoid wiping ceph osds if sysinv tells us so
394 if [ ${WIPE_CEPH_OSDS} == "false" ]; then
396 part_numbers=( `parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
397 # Scanning the partitions looking for CEPH OSDs and
398 # skipping any disk found with such partitions
399 for part_number in "${part_numbers[@]}"; do
400 sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
401 part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
402 if [ "$part_type_guid" == $CEPH_OSD_GUID ]; then
403 echo "OSD found on $dev, skipping wipe"
408 if [ "$wipe_dev" == "false" ]; then
413 # Add device to the wipe list
414 devname=$(basename $dev)
415 if [ -e $dev -a "$ISO_DEV" != "../../$devname" -a "$USB_DEV" != "../../$devname" ]; then
416 if [ -n "$WIPE_HDD" ]; then
417 WIPE_HDD=$WIPE_HDD,$dev
423 echo "Not in upgrade, wiping disks: $WIPE_HDD"
426 for dev in ${WIPE_HDD//,/ }
428 # Clearing previous GPT tables or LVM data
429 # Delete the first few bytes at the start and end of the partition. This is required with
430 # GPT partitions, they save partition info at the start and the end of the block.
431 # Do this for each partition on the disk, as well.
432 partitions=$(lsblk -rip $dev -o TYPE,NAME |awk '$1 == "part" {print $2}')
433 for p in $partitions $dev
435 echo "Pre-wiping $p from kickstart"
436 dd if=/dev/zero of=$p bs=512 count=34
437 dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
441 # Check for remaining cgts-vg PVs, which could potentially happen
442 # in an upgrade where we're not wiping all disks.
443 # If we ever create other volume groups from kickstart in the future,
444 # include them in this search as well.
445 partitions=$(pvs --select 'vg_name=cgts-vg' -o pv_name --noheading | grep -v '\[unknown\]')
448 echo "Pre-wiping $p from kickstart (cgts-vg present)"
449 dd if=/dev/zero of=$p bs=512 count=34
450 dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
453 let -i gb=1024*1024*1024
455 cat<<EOF>/tmp/part-include
456 clearpart --all --drives=$WIPE_HDD --initlabel
459 if [ -n "$ONLYUSE_HDD" ]; then
460 cat<<EOF>>/tmp/part-include
461 ignoredisk --only-use=$ONLYUSE_HDD
465 if [ -d /sys/firmware/efi ] ; then
466 cat<<EOF>>/tmp/part-include
467 part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
470 cat<<EOF>>/tmp/part-include
471 part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
476 # Template from: pre_disk_aio.cfg
478 ## NOTE: updates to partition sizes need to be also reflected in
479 ## - stx-config/.../sysinv/conductor/manager.py:create_controller_filesystems()
480 ## - stx-config/.../sysinv/common/constants.py
482 ## NOTE: When adding partitions, we currently have a max of 4 primary partitions.
483 ## If more than 4 partitions are required, we can use a max of 3 --asprimary,
484 ## to allow 1 primary logical partition with extended partitions
486 ## NOTE: Max default PV size must align with the default controllerfs sizes
488 ## BACKUP_OVERHEAD = 20
490 ## Physical install (for disks over 240GB)
491 ## - DB size is doubled to allow for upgrades
493 ## DEFAULT_IMAGE_STOR_SIZE = 10
494 ## DEFAULT_DATABASE_STOR_SIZE = 20
495 ## DEFAULT_IMG_CONVERSION_STOR_SIZE = 20
496 ## BACKUP = DEFAULT_DATABASE_STOR_SIZE + DEFAULT_IMAGE_STOR_SIZE
497 ## + BACKUP_OVERHEAD = 50
498 ## LOG_VOL_SIZE = 8192
499 ## SCRATCH_VOL_SIZE = 8192
506 ## DOCKER_DIST = 16384
509 ## KUBELET_VOL_SIZE = 10240
510 ## RESERVED_PE = 16 (based on pesize=32768)
512 ## CGCS_PV_SIZE = 10240 + 2*20480 + 20480 + 51200 + 8196 + 8196 + 2048 +
513 ## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
514 ## 20480 + 10240 + 16 = 233496
516 ## small install - (for disks below 240GB)
517 ## - DB size is doubled to allow for upgrades
519 ## DEFAULT_SMALL_IMAGE_STOR_SIZE = 10
520 ## DEFAULT_SMALL_DATABASE_STOR_SIZE = 10
521 ## DEFAULT_SMALL_IMG_CONVERSION_STOR_SIZE = 10
522 ## DEFAULT_SMALL_BACKUP_STOR_SIZE = 40
524 ## LOG_VOL_SIZE = 8192
525 ## SCRATCH_VOL_SIZE = 8192
532 ## DOCKER_DIST = 16384
535 ## KUBELET_VOL_SIZE = 10240
536 ## RESERVED_PE = 16 (based on pesize=32768)
539 ## CGCS_PV_SIZE = 10240 + 2*10240 + 10240 + 40960 + 8192 + 8192 + 2048 +
540 ## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
541 ## 20480 + 10240 + 16 = 192528
543 ## NOTE: To maintain upgrade compatability within the volume group, keep the
544 ## undersized LOG_VOL_SIZE and SCRATCH_VOL_SIZE, but size the minimally size
545 ## physical volume correctly.
547 ## R4 AIO installations:
548 ## - R4 (case #1): /boot (0.5G), / (20G),
549 ## cgts-vg PV (239G), /local_pv (239G)
550 ## - R4 (case #2): /boot (0.5G), / (20G),
551 ## cgts-vg PV (239G), cgts-vg (239G)
553 ## Upgrade migration will start with R5 install and create a partition to align
554 ## above so filesystems within the volume group will be able to maintain their
556 ## - R5 install : /boot (0.5G), / (20G),
557 ## cgts-vg PV (142G), un-partitioned (336G)
558 ## - R5 (case #1): /boot (0.5G), / (20G),
559 ## cgts-vg PV (142G), cgts-vg PV (97G), unpartitioned (239G)
560 ## - R5 (case #2): /boot (0.5G), / (20G),
561 ## cgts-vg PV (142G), cgts-vg PV (336G)
564 sz=$(blockdev --getsize64 $(get_disk $rootfs_device))
565 if [ $sz -le $((240*$gb)) ] ; then
566 # Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
567 # 192528/1024=188.01. CGCS_PV_SIZE=189*1024=193536. Using a disk with a
568 # size under 189GiB will fail.
571 # Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
572 # 233496/1024=228.02. CGCS_PV_SIZE=229*1024=234496.
578 SCRATCH_VOL_SIZE=8000
580 ROOTFS_OPTIONS="defaults"
581 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
582 if [ -n "$profile_mode" ]; then
583 # Enable iversion labelling for rootfs when IMA is enabled
584 ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
587 cat<<EOF>>/tmp/part-include
588 part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
589 part pv.253004 --grow --size=500 --maxsize=$CGCS_PV_SIZE --ondrive=$(get_disk $rootfs_device)
590 volgroup cgts-vg --pesize=32768 pv.253004
591 logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
592 logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
593 part / --fstype=ext4 --asprimary --size=$ROOTFS_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
599 # Template from: post_platform_conf_aio.cfg
602 # Source common functions
603 . /tmp/ks-functions.sh
605 # Set the security profile mode
606 secprofile="standard"
607 profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
608 if [ -n "$profile_mode" ]; then
609 secprofile="extended"
612 mkdir -p -m 0775 /etc/platform
613 cat <<EOF > /etc/platform/platform.conf
615 subfunction=controller,worker
616 system_type=All-in-one
617 security_profile=$secprofile
623 # Template from: post_common.cfg
626 # Source common functions
627 . /tmp/ks-functions.sh
629 # Turn off locale support for i18n if is not installed
630 if [ ! -d /usr/share/i18n ] ; then
631 rm -f /etc/sysconfig/i18n
636 # If using a serial install make sure to add a getty on the tty1
637 conarg=`cat /proc/cmdline |xargs -n1 echo |grep console= |grep ttyS`
638 if [ -n "$conarg" ] ; then
639 echo "1:2345:respawn:/sbin/mingetty tty1" >> /etc/inittab
642 #### SECURITY PROFILE HANDLING (Post Installation) ####
643 # Check if the Security profile mode is enabled
644 # and load the appropriate kernel modules
645 secprofile=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
646 if [ -n "$secprofile" ]; then
647 echo "In Extended Security profile mode. Loading IMA kernel module"
648 systemctl enable auditd.service
649 # Add the securityfs mount for the IMA Runtime measurement list
650 echo "securityfs /sys/kernel/security securityfs defaults,nodev 0 0" >> /etc/fstab
652 # Disable audit daemon in the Standard Security Profile
653 systemctl disable auditd
656 . /etc/platform/platform.conf
657 # Configure smart package manager channels
658 rm -rf /var/lib/smart
660 /usr/bin/smart channel -y \
661 --add rpmdb type=rpm-sys name="RPM Database"
662 /usr/bin/smart channel -y \
663 --add base type=rpm-md name="Base" baseurl=http://controller:${http_port:-8080}/feed/rel-19.12
664 /usr/bin/smart channel -y \
665 --add updates type=rpm-md name="Patches" baseurl=http://controller:${http_port:-8080}/updates/rel-19.12
667 # Configure smart to use rpm --nolinktos option
668 /usr/bin/smart config --set rpm-nolinktos=true
670 # Configure smart to use rpm --nosignature option
671 /usr/bin/smart config --set rpm-check-signatures=false
673 # Delete the CentOS yum repo files
674 rm -f /etc/yum.repos.d/CentOS-*
676 # Persist the boot device naming as UDEV rules so that if the network device
677 # order changes post-install that we will still be able to DHCP from the
678 # correct interface to reach the active controller. For most nodes only the
679 # management/boot interface needs to be persisted but because we require both
680 # controllers to be identically configured and controller-0 and controller-1
681 # are installed differently (e.g., controller-0 from USB and controller-1 from
682 # network) it is not possible to know which interface to persist for
683 # controller-0. The simplest solution is to persist all interfaces.
685 mkdir -p /etc/udev/rules.d
686 echo "# Persisted network interfaces from anaconda installer" > /etc/udev/rules.d/70-persistent-net.rules
687 for dir in /sys/class/net/*; do
688 if [ -e ${dir}/device ]; then
689 dev=$(basename ${dir})
690 mac_address=$(cat /sys/class/net/${dev}/address)
691 echo "ACTION==\"add\", SUBSYSTEM==\"net\", DRIVERS==\"?*\", ATTR{address}==\"${mac_address}\", NAME=\"${dev}\"" >> /etc/udev/rules.d/70-persistent-net.rules
695 # Mark the sysadmin password as expired immediately
698 # Lock the root password
701 # Enable tmpfs mount for /tmp
702 # delete /var/tmp so that it can similinked in
704 systemctl enable tmp.mount
706 # Disable automount of /dev/hugepages
707 systemctl mask dev-hugepages.mount
710 systemctl disable firewalld
713 systemctl disable libvirtd.service
716 systemctl enable rsyncd.service
718 # Allow root to run sudo from a non-tty (for scripts running as root that run sudo cmds)
719 echo 'Defaults:root !requiretty' > /etc/sudoers.d/root
721 # Make fstab just root read/writable
724 # Create first_boot flag
725 touch /etc/platform/.first_boot
729 # Template from: post_kernel_aio_and_worker.cfg
732 # Source common functions
733 . /tmp/ks-functions.sh
735 # Source the generated platform.conf
736 . /etc/platform/platform.conf
738 # Update grub with custom kernel bootargs
739 source /etc/init.d/cpumap_functions.sh
740 n_cpus=$(cat /proc/cpuinfo 2>/dev/null | \
741 awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
742 n_numa=$(ls -d /sys/devices/system/node/node* 2>/dev/null | wc -l)
743 KERN_OPTS=" iommu=pt usbcore.autosuspend=-1"
745 KERN_OPTS="${KERN_OPTS} hugepagesz=2M hugepages=0 default_hugepagesz=2M"
747 # If this is an all-in-one system, we need at least 4 CPUs
748 if [ "$system_type" = "All-in-one" -a ${n_cpus} -lt 4 ]; then
749 report_post_failure_with_msg "ERROR: At least 4 CPUs are required for controller+worker node."
752 # Add kernel options for cpu isolation / affinity
753 if [ ${n_cpus} -gt 1 ]
755 base_cpulist=$(platform_expanded_cpu_list)
756 base_cpumap=$(cpulist_to_cpumap ${base_cpulist} ${n_cpus})
757 avp_cpulist=$(vswitch_expanded_cpu_list)
758 norcu_cpumap=$(invert_cpumap ${base_cpumap} ${n_cpus})
759 norcu_cpulist=$(cpumap_to_cpulist ${norcu_cpumap} ${n_cpus})
761 if [[ "$subfunction" =~ lowlatency ]]; then
762 KERN_OPTS="${KERN_OPTS} isolcpus=${norcu_cpulist}"
763 KERN_OPTS="${KERN_OPTS} nohz_full=${norcu_cpulist}"
765 KERN_OPTS="${KERN_OPTS} isolcpus=${avp_cpulist}"
767 KERN_OPTS="${KERN_OPTS} rcu_nocbs=${norcu_cpulist}"
768 KERN_OPTS="${KERN_OPTS} kthread_cpus=${base_cpulist}"
769 KERN_OPTS="${KERN_OPTS} irqaffinity=${base_cpulist}"
770 # Update vswitch.conf
771 sed -i "s/^VSWITCH_CPU_LIST=.*/VSWITCH_CPU_LIST=\"${avp_cpulist}\"/" /etc/vswitch/vswitch.conf
774 # Add kernel options to ensure an selinux is disabled
775 KERN_OPTS="${KERN_OPTS} selinux=0 enforcing=0"
777 # Add kernel options to set NMI watchdog
778 if [[ "$subfunction" =~ lowlatency ]]; then
779 KERN_OPTS="${KERN_OPTS} nmi_watchdog=0 softlockup_panic=0"
781 KERN_OPTS="${KERN_OPTS} nmi_watchdog=panic,1 softlockup_panic=1"
784 if [[ "$(dmidecode -s system-product-name)" =~ ^ProLiant.*Gen8$ ]]; then
785 KERN_OPTS="${KERN_OPTS} intel_iommu=on,eth_no_rmrr"
787 KERN_OPTS="${KERN_OPTS} intel_iommu=on"
790 # Add kernel option to disable biosdevname if enabled
791 # As this may already be in GRUB_CMDLINE_LINUX, only add if it is not already present
792 grep -q '^GRUB_CMDLINE_LINUX=.*biosdevname=0' /etc/default/grub
793 if [ $? -ne 0 ]; then
794 KERN_OPTS="${KERN_OPTS} biosdevname=0"
797 # Add kernel options to disable kvm-intel.eptad on Broadwell
798 # Broadwell: Model: 79, Model name: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
799 if grep -q -E "^model\s+:\s+79$" /proc/cpuinfo
801 KERN_OPTS="${KERN_OPTS} kvm-intel.eptad=0"
805 #KERN_OPTS="${KERN_OPTS} cgroup_disable=memory"
806 KERN_OPTS="${KERN_OPTS} user_namespace.enable=1"
808 # Add kernel option to avoid jiffies_lock contention on real-time kernel
809 if [[ "$subfunction" =~ lowlatency ]]; then
810 KERN_OPTS="${KERN_OPTS} skew_tick=1"
813 # If the installer asked us to use security related kernel params, use
814 # them in the grub line as well (until they can be configured via puppet)
815 grep -q 'nopti' /proc/cmdline
816 if [ $? -eq 0 ]; then
817 KERN_OPTS="${KERN_OPTS} nopti"
819 grep -q 'nospectre_v2' /proc/cmdline
820 if [ $? -eq 0 ]; then
821 KERN_OPTS="${KERN_OPTS} nospectre_v2"
824 perl -pi -e 's/(GRUB_CMDLINE_LINUX=.*)\"/\1'"$KERN_OPTS"'\"/g' /etc/default/grub
826 if [ -d /sys/firmware/efi ] ; then
827 grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
829 grub2-mkconfig -o /boot/grub2/grub.cfg
835 # Template from: post_lvm_pv_on_rootfs.cfg
838 # Source common functions
839 . /tmp/ks-functions.sh
841 # uncomment the global_filter line in lvm.conf
842 perl -0777 -i.bak -pe 's:(# This configuration option has an automatic default value\.\n)\t# global_filter:$1 global_filter:m' /etc/lvm/lvm.conf
844 # Determine which disk we created our PV on (i.e. the root disk)
845 ROOTDISK=$(get_by_path $(pvdisplay --select 'vg_name=cgts-vg' -C -o pv_name --noheadings))
846 if [ -z "$ROOTDISK" ]; then
847 report_post_failure_with_msg "ERROR: failed to identify rootdisk via pvdisplay"
849 # Edit the LVM config so LVM only looks for LVs on the root disk
850 sed -i "s#^\( *\)global_filter = \[.*#\1global_filter = [ \"a|${ROOTDISK}|\", \"r|.*|\" ]#" /etc/lvm/lvm.conf
854 # Template from: post_system_aio.cfg
857 # Source common functions
858 . /tmp/ks-functions.sh
860 # Source the generated platform.conf
861 . /etc/platform/platform.conf
863 ## Reserve more memory for base processes since the controller has higher
864 ## memory requirements but cap it to better handle systems with large
866 TOTALMEM=$(grep MemTotal /proc/meminfo | awk '{print int($2/1024)}')
868 if [ -e /sys/devices/system/node/node0 ]; then
869 RESERVEDMEM=$(grep MemTotal /sys/devices/system/node/node0/meminfo | awk '{printf "%d\n", $4/1024}')
871 RESERVEDMEM=$(grep MemTotal /proc/meminfo | awk '{print int($2/1024/4)}')
874 if [ ${RESERVEDMEM} -lt 6144 ]; then
876 elif [ ${RESERVEDMEM} -gt 14500 ]; then
878 elif [ ${RESERVEDMEM} -gt 8192 ]; then
882 sed -i -e "s#\(WORKER_BASE_RESERVED\)=.*#\1=(\"node0:${RESERVEDMEM}MB:1\" \"node1:2000MB:0\" \"node2:2000MB:0\" \"node3:2000MB:0\")#g" /etc/platform/worker_reserved.conf
884 # Update WORKER_CPU_LIST
885 N_CPUS=$(cat /proc/cpuinfo 2>/dev/null | awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
886 sed -i "s/^WORKER_CPU_LIST=.*/WORKER_CPU_LIST=\"0-$((N_CPUS-1))\"/" /etc/platform/worker_reserved.conf
891 # Template from: post_net_controller.cfg
894 # Source common functions
895 . /tmp/ks-functions.sh
897 http_port=$(get_http_port)
898 # Retrieve the installation uuid from the controller we booted from
899 INSTALL_UUID=`curl -sf http://pxecontroller:${http_port:-8080}/feed/rel-19.12/install_uuid`
905 grep -q INSTALL_UUID /etc/platform/platform.conf
906 if [ $? -ne 0 ]; then
907 echo "INSTALL_UUID=$INSTALL_UUID" >> /etc/platform/platform.conf
911 # Sync software repository
912 feed_url=http://pxecontroller:${http_port:-8080}/feed/
913 anaconda_logdir=/var/log/anaconda
914 mkdir -p $anaconda_logdir
916 echo "Mirroring software repository (may take several minutes)..." >/dev/console
917 wget --recursive --no-parent --no-host-directories --no-clobber --reject 'index.html*' --reject '*.log' $feed_url/ -o $anaconda_logdir/wget-feed-mirror.log \
918 || report_post_failure_with_logfile $anaconda_logdir/wget-feed-mirror.log
920 # Sync patching repository
921 updates_url=http://pxecontroller:${http_port:-8080}/updates/
922 wget --mirror --no-parent --no-host-directories --reject 'index.html*' --reject '*.log' $updates_url/ -o $anaconda_logdir/wget-updates-mirror.log \
923 || report_post_failure_with_logfile $anaconda_logdir/wget-updates-mirror.log
924 echo "Done" >/dev/console
928 # Check whether a second release is installed
930 CURRENT_REL_DIR=rel-${SW_VERSION}
932 for REL_DIR in /www/pages/feed/*; do
933 if [[ ! $REL_DIR =~ "${SW_VERSION}" ]]; then
934 OTHER_REL_DIR=`basename $REL_DIR`
935 OTHER_REL_VERSION=${OTHER_REL_DIR:4}
940 # If second release is installed, find the latest version of the installer
941 # RPM and install the pxeboot files we require to boot hosts with that release.
942 if [ ! -z "$OTHER_REL_DIR" ]; then
943 PATCH_RPM=`find /www/pages/updates/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1`
944 BASE_RPM=`find /www/pages/feed/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1`
946 if [ ! -z "$PATCH_RPM" ]; then
947 INSTALL_RPM=$PATCH_RPM
948 elif [ ! -z "$BASE_RPM" ]; then
949 INSTALL_RPM=$BASE_RPM
951 report_post_failure_with_msg "ERROR: Unable to find pxe-network-installer RPM for $OTHER_REL_DIR. Aborting installation."
954 echo "Installing pxeboot files for release $OTHER_REL_DIR from $INSTALL_RPM" >/dev/console
955 TMP_RPM=/tmp/pxe-network-installer
958 /usr/bin/rpm2cpio $INSTALL_RPM | cpio -idm \
959 || report_post_failure_with_msg "Failed to extract pxe-network-installer"
961 cp -r $TMP_RPM/usr / \
962 || report_post_failure_with_msg "Failed to copy pxe-network-installer /usr"
963 cp -r $TMP_RPM/pxeboot/$OTHER_REL_DIR /pxeboot/ \
964 || report_post_failure_with_msg "Failed to copy pxe-network-installer /pxeboot/$OTHER_REL_DIR"
965 cp $TMP_RPM/pxeboot/pxelinux.cfg.files/*-$OTHER_REL_VERSION /pxeboot/pxelinux.cfg.files/ \
966 || report_post_failure_with_msg "Failed to copy pxe-network-installer pxelinux.cfg files"
973 # Template from: post_net_common.cfg
976 # Source common functions
977 . /tmp/ks-functions.sh
979 http_port=$(get_http_port)
980 echo "repo --name=base --baseurl=http://pxecontroller:${http_port:-8080}/feed/rel-19.12/" > /tmp/repo-include
981 echo "repo --name=updates --baseurl=http://pxecontroller:${http_port:-8080}/updates/rel-19.12/" > /tmp/repo-include
985 # Repository arguments from %pre
986 %include /tmp/repo-include
991 # Source common functions
992 . /tmp/ks-functions.sh
994 # Persist the http port to the platform configuration
995 echo http_port=$(get_http_port) >> /etc/platform/platform.conf
997 # Obtain the boot interface from the PXE boot
998 BOOTIF=`cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=`
999 if [ -d /sys/firmware/efi ] ; then
1000 BOOTIF=${BOOTIF#BOOTIF=}
1002 BOOTIF=${BOOTIF#BOOTIF=01-}
1003 BOOTIF=${BOOTIF//-/:}
1008 if [ -n "$BOOTIF" ] ; then
1009 ndev=`ip link show |grep -B 1 $BOOTIF |head -1 |awk '{print $2}' |sed -e 's/://'`
1010 if [ -n "$ndev" ] ; then
1012 # Retrieve the management VLAN from sysinv if it exists
1013 mgmt_vlan=`curl -sf http://pxecontroller:6385/v1/isystems/mgmtvlan`
1016 report_post_failure_with_msg "ERROR: Unable to communicate with System Inventory REST API. Aborting installation."
1019 report_post_failure_with_msg "ERROR: Unable to determine mgmt interface from BOOTIF=$BOOTIF."
1022 report_post_failure_with_msg "ERROR: BOOTIF is not set. Unable to determine mgmt interface."
1025 if [ $mgmt_vlan -eq 0 ] ; then
1027 # Persist the boot device to the platform configuration. This will get
1028 # overwritten later if the management_interface is on a bonded interface.
1029 echo management_interface=$mgmt_dev >> /etc/platform/platform.conf
1031 # Build networking scripts
1032 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
1037 BROADCAST=127.255.255.255
1043 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
1053 # Check whether to use inet or inet6
1054 ipv6_addr=$(dig +short AAAA controller)
1055 if [[ -n "$ipv6_addr" ]]
1057 mgmt_address_family=inet6
1062 mgmt_address_family=inet
1068 # Persist the boot device to the platform configuration. This will get
1069 # overwritten later if the management_interface is on a bonded interface.
1070 echo management_interface=vlan$mgmt_vlan >> /etc/platform/platform.conf
1072 # Build networking scripts
1073 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
1078 BROADCAST=127.255.255.255
1084 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
1092 cat << EOF > /etc/sysconfig/network-scripts/ifcfg-vlan$mgmt_vlan
1093 DEVICE=vlan$mgmt_vlan
1095 DHCLIENTARGS=$dhclientargs
1105 # Reject DHCPOFFER from DHCP server that doesn't send
1106 # wrs-install-uuid option
1107 echo "require wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
1108 echo "require dhcp6.wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
1110 # Bring up the mgmt vlan so that a dhcp lease is acquired and an address is
1111 # setup prior to the post-install reboot. This is so that the timing of the IP
1112 # address allocation is similar to how normal/non-pxe installation works.
1113 mgmt_iface=vlan$mgmt_vlan
1114 dhclient_family=$([[ $mgmt_address_family == "inet" ]] && echo -4 || echo -6)
1115 ip link add link $mgmt_dev name $mgmt_iface type vlan id $mgmt_vlan
1116 ip link set up dev $mgmt_iface
1117 dhclient $dhclient_family $mgmt_iface || true