From d29df40fd66d6a90fde858e8a0bc0d0e98a01794 Mon Sep 17 00:00:00 2001 From: Jonas Bjurel Date: Fri, 30 Jan 2015 22:22:43 +0100 Subject: Version 0.0.1 of /fuel-bild This is a build system that rebases the result from fuel.org such that you can add or change packages/puppet manifests any way you like, and reliably produce a installable which can be reproduced any time. See README for more information. Signed-off-by: Jonas Bjurel --- fuel-build/f_isoroot/Makefile | 31 ++ fuel-build/f_isoroot/README | 16 + fuel-build/f_isoroot/f_bootstrap/Makefile | 29 ++ fuel-build/f_isoroot/f_bootstrap/README | 24 + .../f_isoroot/f_bootstrap/bootstrap_admin_node.sh | 105 ++++ .../f_bootstrap/bootstrap_admin_node.sh.orig | 84 ++++ .../f_bootstrap/post-scripts/00_post_example.sh | 4 + .../f_bootstrap/post-scripts/01_fix_iommubug.sh | 9 + .../post-scripts/02_fix_console_speed.sh | 15 + .../f_bootstrap/pre-scripts/00_pre_example.sh | 4 + fuel-build/f_isoroot/f_kscfg/Makefile | 25 + fuel-build/f_isoroot/f_kscfg/README | 18 + fuel-build/f_isoroot/f_kscfg/ks.cfg | 540 +++++++++++++++++++++ fuel-build/f_isoroot/f_kscfg/ks.cfg.orig | 534 ++++++++++++++++++++ fuel-build/f_isoroot/f_predeployment/Makefile | 28 ++ fuel-build/f_isoroot/f_predeployment/README | 18 + fuel-build/f_isoroot/f_predeployment/pre-deploy.sh | 401 +++++++++++++++ fuel-build/f_isoroot/f_predeployment/sysinfo.sh | 12 + .../f_isoroot/f_predeployment/transform_yaml.py | 68 +++ 19 files changed, 1965 insertions(+) create mode 100644 fuel-build/f_isoroot/Makefile create mode 100644 fuel-build/f_isoroot/README create mode 100644 fuel-build/f_isoroot/f_bootstrap/Makefile create mode 100644 fuel-build/f_isoroot/f_bootstrap/README create mode 100755 fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh create mode 100755 fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig create mode 100755 fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh create mode 100755 fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh create mode 100755 fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh create mode 100755 fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh create mode 100644 fuel-build/f_isoroot/f_kscfg/Makefile create mode 100644 fuel-build/f_isoroot/f_kscfg/README create mode 100755 fuel-build/f_isoroot/f_kscfg/ks.cfg create mode 100644 fuel-build/f_isoroot/f_kscfg/ks.cfg.orig create mode 100644 fuel-build/f_isoroot/f_predeployment/Makefile create mode 100644 fuel-build/f_isoroot/f_predeployment/README create mode 100755 fuel-build/f_isoroot/f_predeployment/pre-deploy.sh create mode 100755 fuel-build/f_isoroot/f_predeployment/sysinfo.sh create mode 100755 fuel-build/f_isoroot/f_predeployment/transform_yaml.py (limited to 'fuel-build/f_isoroot') diff --git a/fuel-build/f_isoroot/Makefile b/fuel-build/f_isoroot/Makefile new file mode 100644 index 0000000..2fdbbae --- /dev/null +++ b/fuel-build/f_isoroot/Makefile @@ -0,0 +1,31 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +SUBDIRS = f_predeployment f_kscfg f_bootstrap +SUBCLEAN = $(addsuffix .clean,$(SUBDIRS)) + +.PHONY: all +all: $(SUBDIRS) + +.PHONY: $(SUBDIRS) +$(SUBDIRS): + @mkdir -p release + $(MAKE) -C $@ -f Makefile release + +.PHONY: clean $(SUBCLEAN) +clean: $(SUBCLEAN) + @rm -Rf release + +$(SUBCLEAN): %.clean: + $(MAKE) -C $* -f Makefile clean + +.PHONY: release +release:clean $(SUBDIRS) + @cp -Rvp release/* ../release/isoroot diff --git a/fuel-build/f_isoroot/README b/fuel-build/f_isoroot/README new file mode 100644 index 0000000..eb54c08 --- /dev/null +++ b/fuel-build/f_isoroot/README @@ -0,0 +1,16 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is to (a) replace/patch existing Fuel ISO files as well +as adding new information directly into the ISO structure + +Please separate changes into "patches" and new content into +"additions". Both directories will be anchored at the ISO file +root. diff --git a/fuel-build/f_isoroot/f_bootstrap/Makefile b/fuel-build/f_isoroot/f_bootstrap/Makefile new file mode 100644 index 0000000..7404319 --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/Makefile @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + @mkdir -p release/opnfv/bootstrap/pre.d + @mkdir -p release/opnfv/bootstrap/post.d + @mkdir -p release/usr/local/sbin + @cp pre-scripts/* release/opnfv/bootstrap/pre.d + @cp post-scripts/* release/opnfv/bootstrap/post.d + @cp bootstrap_admin_node.sh release + @cp bootstrap_admin_node.sh.orig release + +.PHONY: clean +clean: + @rm -rf release + +.PHONY: release +release:all + @cp -Rvp release/* ../release diff --git a/fuel-build/f_isoroot/f_bootstrap/README b/fuel-build/f_isoroot/f_bootstrap/README new file mode 100644 index 0000000..5da954c --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/README @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This function modifies the adds hooks to the beginning and end of +/usr/local/sbin/bootstrap_admin_nodes.sh, which is run as the +last post step from ks.cfg + +This enables other functions to place scripts into two directories +run either at the beginning or the end of the bootstrap procedure: + + /opt/opnfv/bootstrap/pre.d + /opt/opnfv/bootstrap/post.d + +These will be run in lexical order at pre or post. + +CI note: Using pre.d, it would be possible to "inject" a pre-defined +astute.yaml for Fuel. diff --git a/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh new file mode 100755 index 0000000..348ce3c --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +function countdown() { + local i + sleep 1 + for ((i=$1-1; i>=1; i--)); do + printf '\b\b%02d' "$i" + sleep 1 + done +} + +function fail() { + echo "ERROR: Fuel node deployment FAILED! Check /var/log/puppet/bootstrap_admin_node.log for details" 1>&2 + exit 1 +} +# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details +export LANG=en_US.UTF8 +showmenu="no" +if [ -f /root/.showfuelmenu ]; then + . /root/.showfuelmenu +fi + +echo -n "Applying default Fuel settings..." +fuelmenu --save-only --iface=eth0 +echo "Done!" + +### OPNFV addition BEGIN +shopt -s nullglob +for script in /opt/opnfv/bootstrap/pre.d/*.sh +do + echo "Pre script: $script" >> /root/pre.log 2>&1 + $script >> /root/pre.log 2>&1 +done +shopt -u nullglob +### OPNFV addition END + +if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then + fuelmenu + else + #Give user 15 seconds to enter fuelmenu or else continue + echo + echo -n "Press a key to enter Fuel Setup (or press ESC to skip)... 15" + countdown 15 & pid=$! + if ! read -s -n 1 -t 15 key; then + echo -e "\nSkipping Fuel Setup..." + else + { kill "$pid"; wait $!; } 2>/dev/null + case "$key" in + $'\e') echo "Skipping Fuel Setup.." + echo -n "Applying default Fuel setings..." + fuelmenu --save-only --iface=eth0 + echo "Done!" + ;; + *) echo -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +### docker stuff +images_dir="/var/www/nailgun/docker/images" + +# extract docker images +mkdir -p $images_dir $sources_dir +rm -f $images_dir/*tar +pushd $images_dir &>/dev/null + +echo "Extracting and loading docker images. (This may take a while)" +lrzip -d -o fuel-images.tar fuel-images.tar.lrz && tar -xf fuel-images.tar && rm -f fuel-images.tar +popd &>/dev/null +service docker start + +# load docker images +for image in $images_dir/*tar ; do + echo "Loading docker image ${image}..." + docker load -i "$image" + # clean up extracted image + rm -f "$image" +done + +# apply puppet +puppet apply --detailed-exitcodes -d -v /etc/puppet/modules/nailgun/examples/host-only.pp +if [ $? -ge 4 ];then + fail +fi +rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote + +dockerctl check || fail +bash /etc/rc.local + +### OPNFV addition BEGIN +shopt -s nullglob +for script in /opt/opnfv/bootstrap/post.d/*.sh +do + echo "Post script: $script" >> /root/post.log 2>&1 + $script >> /root/post.log 2>&1 +done +shopt -u nullglob +### OPNFV addition END + +echo "Fuel node deployment complete!" diff --git a/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig new file mode 100755 index 0000000..7b6e6bd --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig @@ -0,0 +1,84 @@ +#!/bin/bash + +function countdown() { + local i + sleep 1 + for ((i=$1-1; i>=1; i--)); do + printf '\b\b%02d' "$i" + sleep 1 + done +} + +function fail() { + echo "ERROR: Fuel node deployment FAILED! Check /var/log/puppet/bootstrap_admin_node.log for details" 1>&2 + exit 1 +} +# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details +export LANG=en_US.UTF8 +showmenu="no" +if [ -f /root/.showfuelmenu ]; then + . /root/.showfuelmenu +fi + +echo -n "Applying default Fuel settings..." +fuelmenu --save-only --iface=eth0 +echo "Done!" + +if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then + fuelmenu + else + #Give user 15 seconds to enter fuelmenu or else continue + echo + echo -n "Press a key to enter Fuel Setup (or press ESC to skip)... 15" + countdown 15 & pid=$! + if ! read -s -n 1 -t 15 key; then + echo -e "\nSkipping Fuel Setup..." + else + { kill "$pid"; wait $!; } 2>/dev/null + case "$key" in + $'\e') echo "Skipping Fuel Setup.." + echo -n "Applying default Fuel setings..." + fuelmenu --save-only --iface=eth0 + echo "Done!" + ;; + *) echo -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +### docker stuff +images_dir="/var/www/nailgun/docker/images" + +# extract docker images +mkdir -p $images_dir $sources_dir +rm -f $images_dir/*tar +pushd $images_dir &>/dev/null + +echo "Extracting and loading docker images. (This may take a while)" +lrzip -d -o fuel-images.tar fuel-images.tar.lrz && tar -xf fuel-images.tar && rm -f fuel-images.tar +popd &>/dev/null +service docker start + +# load docker images +for image in $images_dir/*tar ; do + echo "Loading docker image ${image}..." + docker load -i "$image" + # clean up extracted image + rm -f "$image" +done + +# apply puppet +puppet apply --detailed-exitcodes -d -v /etc/puppet/modules/nailgun/examples/host-only.pp +if [ $? -ge 4 ];then + fail +fi +rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote + +dockerctl check || fail +bash /etc/rc.local +echo "Fuel node deployment complete!" diff --git a/fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh b/fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh new file mode 100755 index 0000000..7ac8965 --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh @@ -0,0 +1,4 @@ +#/bin/sh +date +echo "This is an example file run at post-bootstrap." +exit 0 diff --git a/fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh b/fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh new file mode 100755 index 0000000..79aa31a --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh @@ -0,0 +1,9 @@ +#/bin/sh +echo "Setting intel_iommu=off in bootstrap profile - a fix for the Dell systems" +echo "Old settings" +dockerctl shell cobbler cobbler profile report --name bootstrap +echo "Modifying" +dockerctl shell cobbler cobbler profile edit --name bootstrap --kopts "intel_iommu=off" --in-place +echo "New settings" +dockerctl shell cobbler cobbler profile report --name bootstrap + diff --git a/fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh b/fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh new file mode 100755 index 0000000..bf7591b --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh @@ -0,0 +1,15 @@ +#/bin/sh +echo "Changing console speed to 115200 (std is 9600) on bootstrap" +echo "Old settings" +dockerctl shell cobbler cobbler profile report --name bootstrap +echo "Modifying" +dockerctl shell cobbler cobbler profile edit --name bootstrap --kopts "console=tty0 console=ttyS0,115200" --in-place +echo "New settings" +dockerctl shell cobbler cobbler profile report --name bootstrap +echo "Setting console speed to 115200 on ubuntu_1204_x86_64 (std is no serial console)" +echo "Old settings" +dockerctl shell cobbler cobbler profile report --name ubuntu_1204_x86_64 +echo "Modifying" +dockerctl shell cobbler cobbler profile edit --name ubuntu_1204_x86_64 --kopts "console=tty0 console=ttyS0,115200" --in-place +echo "New settings" +dockerctl shell cobbler cobbler profile report --name ubuntu_1204_x86_64 diff --git a/fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh b/fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh new file mode 100755 index 0000000..ac427bf --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh @@ -0,0 +1,4 @@ +#/bin/sh +date +echo "This is an example file run at pre-bootstrap." +exit 0 diff --git a/fuel-build/f_isoroot/f_kscfg/Makefile b/fuel-build/f_isoroot/f_kscfg/Makefile new file mode 100644 index 0000000..38305fd --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/Makefile @@ -0,0 +1,25 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + @mkdir -p release + @cp ks.cfg release + @cp ks.cfg.orig release + +.PHONY: clean +clean: + @rm -rf release + +.PHONY: release +release: all + @cp -Rvp release/* ../release diff --git a/fuel-build/f_isoroot/f_kscfg/README b/fuel-build/f_isoroot/f_kscfg/README new file mode 100644 index 0000000..c85efde --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/README @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This function modifies the ks.cfg of the Fuel master to +make copy whatever is in the top level opnfv directory +of the ISO (populated by, for example, f_configfrontend) to +/opt/opnfv. In the end this is where the installation +parts will evolve. + +This is also the place to force the installation to overwrite +the disk (set forceformat="yes" instead of "no"). diff --git a/fuel-build/f_isoroot/f_kscfg/ks.cfg b/fuel-build/f_isoroot/f_kscfg/ks.cfg new file mode 100755 index 0000000..8194e8d --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/ks.cfg @@ -0,0 +1,540 @@ +install +text +%include /tmp/source.ks +reboot --eject +lang en_US.UTF-8 +keyboard us +rootpw r00tme +timezone --utc Etc/UTC +firewall --disabled +selinux --disabled +# ignore unsupported hardware warning +unsupported_hardware +# SKIP CONFIGURING X +skipx +# NEVER ever place zerombr here, it breaks automated installation +%include /tmp/bootloader.ks +%include /tmp/partition.ks + +# PREINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE +# INSTALLATION PROCESS ITSELF +%pre +#!/bin/sh + +# hard drives +drives="" +removable_drives="" +for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do + if (grep -q 0 /sys/block/${drv}/removable); then + drives="${drives} ${drv}" + else + removable_drives="${removable_drives} ${drv}" + fi +done +default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'` + +installdrive="undefined" +forceformat="no" +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +set ${drives} ${removable_drives} +numdrives=`echo $#` + +tgtdrive="${installdrive}" + +function confirm_format { + check_drive="$1" + local confirm_format="no" + + if [[ "$forceformat" == "yes" ]] ; then + return 0 + fi + + if parted -s /dev/$check_drive print &>/dev/null ; then + echo + echo "$check_drive drive contains partition table:" + parted -s /dev/$check_drive print + echo + read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format + if [[ "$confirm_format" == "y" ]] || [[ "$forceformat" == "yes" ]]; then + return 0 + else + return 1 + fi + else + return 0 + fi +} + +format_confirmed="no" + +if [ $numdrives -lt 1 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* There is no suitable media available for installation. *' + echo '* Please attach a drive and try again. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to shut down the system: " _ + poweroff +fi + +if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + while [ "${tgtdrive}" = "undefined" ]; do + clear + echo + echo '********************************************************************************' + echo '* W A R N I N G *' + echo '* *' + echo '* Which of the detected hard drives do you want to be used as *' + echo '* the installation target? *' + echo '* *' + echo '********************************************************************************' + echo + echo "Possible choices" + echo "Persistent drives: ${drives}" + echo "Removable drives: ${removable_drives}" + echo + if [ `echo ${drives} | wc -w` -eq 1 ] ; then + read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive + else + read -p "Choose hard drive: " tgtdrive + fi + match="no" + for drive in ${drives[@]} ${removable_drives[@]}; do + if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then + if confirm_format $tgtdrive ; then + format_confirmed="yes" + break + else + tgtdrive="undefined" + read -p "You may select another disk. Press Enter to continue." _ + fi + fi + done + if [[ "$match" == "no" ]]; then + tgtdrive="undefined" + read -p "Invalid choice. Press Enter to continue." _ + fi + done + clear + chvt 1 +else + tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"` +fi + +if [ "$format_confirmed" != "yes" ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + if ! confirm_format $tgtdrive ; then + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Disk $tgtdrive contains active partition(s). *' + echo '* Installation cannot continue without confirmation. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot + fi + chvt 1 +fi + +# verify tgtdrive is at least 30GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 30720 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Your disk is under 30GB in size. Installation cannot continue. *' + echo '* Restart installation with a larger disk. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot +fi + +# paths in /dev have "/" instead of "!" for cciss devices +tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//') + +# source +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks +else + echo "cdrom" > /tmp/source.ks +fi + +vgremove -ff os +dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10 +sleep 3 +hdparm -z /dev/${tgtdrive} +parted -s /dev/${tgtdrive} mklabel gpt +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24 +parted -s /dev/${tgtdrive} set 1 bios_grub on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224 +parted -s /dev/${tgtdrive} set 2 boot on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424 +sleep 3 +hdparm -z /dev/${tgtdrive} + +# partition + +# This adds support for the p seperator required for cciss devices +if echo ${tgtdrive} | grep -q -e cciss ; then + bootdev=${tgtdrive}p +else + bootdev=${tgtdrive} +fi +echo > /tmp/partition.ks +echo "partition /boot --onpart=/dev/${bootdev}3" >> /tmp/partition.ks +echo "partition pv.001 --ondisk=${tgtdrive} --size=30000 --grow" >> /tmp/partition.ks +echo "volgroup os pv.001" >> /tmp/partition.ks +echo "logvol swap --vgname=os --recommended --name=swap" >> /tmp/partition.ks +echo "logvol / --vgname=os --size=10000 --name=root --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var --vgname=os --size=1 --grow --name=var --fstype=xfs" >> /tmp/partition.ks + +# bootloader +echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks + +# Anaconda can not install grub 0.97 on disks which are >4T. +# The reason is that grub does not support such large geometries +# and it simply thinks that the cylinder number has negative value. +# Here we just set geometry manually so that grub thinks that disk +# size is equal to 1G. +# 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G +echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks +echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks + +%end + +%packages --nobase --excludedocs +@Core +authconfig +bind-utils +cronie +crontabs +curl +daemonize +dhcp +docker-io +fuelmenu +gdisk +lrzip +lsof +man +mlocate +nmap-ncat +ntp +openssh-clients +policycoreutils +rsync +ruby21-puppet +ruby21-rubygem-netaddr +ruby21-rubygem-openstack +selinux-policy-targeted +strace +subscription-manager +sysstat +system-config-firewall-base +tcpdump +telnet +vim-enhanced +virt-what +wget +yum + +%include /tmp/post_partition.ks + +# POSTINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER +# INSTALLATION ITSELF COMPLETED +%post +echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules +chmod +x /etc/rc.modules +echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf +mkdir -p /var/log/coredump +echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf +chmod 777 /var/log/coredump +echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf + +# Mount installation media in chroot +%post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log +#!/bin/sh + +SOURCE="/mnt/sysimage/tmp/source" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +mkdir -p "${SOURCE}" + +case "${repo}" in + nfs:*) + nfs_url="${repo#nfs:}" + mount -t nfs "${nfs_url}" "${SOURCE}" + ;; + *) + if [ -d "/mnt/source" ]; then + mount -o bind "/mnt/source" "${SOURCE}" + fi + ;; +esac + +%post --log=/root/anaconda-post-after-chroot.log +#!/bin/bash + +set -x + +function save_cfg { + scrFile="/etc/sysconfig/network-scripts/ifcfg-$device" + search="domain $domain\nsearch $domain" + sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network + grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts + echo "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream + [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf + [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream + + echo DEVICE=$device > $scrFile + echo ONBOOT=yes >> $scrFile + echo NM_CONTROLLED=no >> $scrFile + echo HWADDR=$hwaddr >> $scrFile + echo USERCTL=no >> $scrFile + echo PEERDNS=no >> $scrFile + if [ $ip ]; then + echo BOOTPROTO=static >> $scrFile + echo IPADDR=$ip >> $scrFile + echo NETMASK=$netmask >> $scrFile + else + echo BOOTPROTO=dhcp >> $scrFile + fi + scrDHCPFile="/etc/sysconfig/network-scripts/ifcfg-$dhcp_interface" + #Ignore gateway and set up DHCP if it is used, otherwise apply it + if [ $dhcp_interface ] && [ "$dhcp_interface" != "$device" ]; then + echo "DEVICE=$dhcp_interface" > $scrDHCPFile + echo "BOOTPROTO=dhcp" >> $scrDHCPFile + echo "ONBOOT=yes" >> $scrDHCPFile + echo "USERCTL=no" >> $scrDHCPFile + else + echo GATEWAY=$gw >> /etc/sysconfig/network + fi +} + +# Default FQDN +hostname="nailgun.mirantis.com" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done +hostname=$hostname +domain=${hostname#*.} +ip=$ip +netmask=$netmask +gw=$gw +device="eth0" +hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` +dhcp_interface=$dhcp_interface +save_cfg + +# Mounting installation source +SOURCE=/tmp/source +FS=/tmp/fs + +echo +mkdir -p ${SOURCE} +mkdir -p ${FS} + +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS} + mount -o loop ${FS}/nailgun.iso ${SOURCE} +fi + +# Copying Repo to the nailgun /var/www directory +repodir="/var/www/nailgun" +mkdir -p ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/images ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/isolinux ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/repodata ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/Packages ${repodir}/centos/fuelweb/x86_64 +cp ${SOURCE}/.treeinfo ${repodir}/centos/fuelweb/x86_64 + +# Copying Ubuntu files +mkdir -p ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/conf ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/db ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/indices ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz ${repodir}/ubuntu/fuelweb/x86_64/images + +# Copying bootstrap image +mkdir -p ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/initramfs.img ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/linux ${repodir}/bootstrap + +mkdir -p /root/.ssh +chmod 700 /root/.ssh +cp ${SOURCE}/bootstrap/bootstrap.rsa /root/.ssh +chmod 600 /root/.ssh/bootstrap.rsa + +# Unpacking puppet manifests for master and slave +cp ${SOURCE}/puppet-slave.tgz ${repodir}/ +tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/modules +mkdir -p /etc/puppet/manifests/ +cp /etc/puppet/modules/osnailyfacter/examples/site.pp /etc/puppet/manifests/site.pp +cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/manifests/ +cp ${SOURCE}/send2syslog.py /bin/send2syslog.py +mkdir -p /var/lib/hiera +touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml + +# Deploy docker images and ctl tools if we built ISO with docker containers support +[ -d "${SOURCE}/docker" ] && cp -r ${SOURCE}/docker ${repodir}/docker + +# Prepare local repository specification +rm /etc/yum.repos.d/CentOS*.repo +cat > /etc/yum.repos.d/nailgun.repo << EOF +[nailgun] +name=Nailgun Local Repo +baseurl=file:/var/www/nailgun/centos/fuelweb/x86_64 +gpgcheck=0 +EOF + +# Disable subscription-manager plugins +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || : +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || : + +# Disable GSSAPI in ssh server config +sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config + +# Copying bootstrap_admin_node.sh, chmod it and +# adding /etc/init/bootstrap_admin_node.conf +cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh +chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh +cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf +echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node + +# Copying version.yaml file. It contains COMMIT_SHA of last commit. +RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml) +mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions +cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml +ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml + +# Generete Fuel UUID +uuidgen > /etc/fuel/fuel-uuid + +###Run fuel menu +[ -z "$showmenu" ] && showmenu="no" +cat > /root/.showfuelmenu << EOF +#Set to yes to run Fuel Setup +#Set to no to accept default settings +showmenu=$showmenu +EOF + +# Prepare custom /etc/issue logon banner and script for changing IP in it +cat > /etc/issue << EOF +######################################### +# Welcome to the Fuel server # +######################################### +Server is running on \m platform + +Fuel UI is available on: +http://:8000 + +Default administrator login: root +Default administrator password: r00tme + +Default Fuel UI login: admin +Default Fuel UI password: admin + +Please change root password on first login. + +EOF + + +cat >> '/etc/rc.local' << EOF +first=yes +for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do +if [ "\$first" = "yes" ]; then + ipstr="Fuel UI is available on: http://\$ip:8000" + first=no +else + ipstr=\$(printf "%s\n%51s" "\$ipstr" "http://\$ip:8000") +fi +done +tmpissue=\$(mktemp) +while read -r line; do + if [[ "\$line" =~ "Fuel UI is available on" ]]; then + echo -e "\$ipstr" >> \$tmpissue + elif [[ "\$line" =~ :8000$ ]]; then + : + else + echo -e "\$line" >> \$tmpissue + fi +done < /etc/issue +mv "\$tmpissue" /etc/issue + +EOF + +######### OPNFV addition BEGIN ############ +# Copy data into /opt/opnfv +# TODO: This ought to be a package instead! +mkdir -p /opt/opnfv +cp -r ${SOURCE}/opnfv /opt +######### OPNFV addition END ############ + +# Unmounting source +umount -f ${SOURCE} +rm -rf ${SOURCE} + +umount -f ${FS} || true +rm -rf ${FS} + +# Enabling/configuring NTPD and ntpdate services +echo "server 127.127.1.0" >> /etc/ntp.conf +echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf +echo "tos orphan 7" >> /etc/ntp.conf + +# Do not show error message on ntpdate failure. Customers should not be confused +# if admin node does not have access to the internet time servers. +sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/' + +# Disabling splash +sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf +sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf + +# Disabling console clearing +sed -i 's/getty/getty --noclear/' /etc/init/tty.conf + +# Disabling starting first console from start-ttys service +sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init + +# Copying default bash settings to the root directory +cp -f /etc/skel/.bash* /root/ + +# Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors +[[ $(virt-what) = "virtualbox" ]] && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf + +%end diff --git a/fuel-build/f_isoroot/f_kscfg/ks.cfg.orig b/fuel-build/f_isoroot/f_kscfg/ks.cfg.orig new file mode 100644 index 0000000..8d00dff --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/ks.cfg.orig @@ -0,0 +1,534 @@ +install +text +%include /tmp/source.ks +reboot --eject +lang en_US.UTF-8 +keyboard us +rootpw r00tme +timezone --utc Etc/UTC +firewall --disabled +selinux --disabled +# ignore unsupported hardware warning +unsupported_hardware +# SKIP CONFIGURING X +skipx +# NEVER ever place zerombr here, it breaks automated installation +%include /tmp/bootloader.ks +%include /tmp/partition.ks + +# PREINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE +# INSTALLATION PROCESS ITSELF +%pre +#!/bin/sh + +# hard drives +drives="" +removable_drives="" +for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do + if (grep -q 0 /sys/block/${drv}/removable); then + drives="${drives} ${drv}" + else + removable_drives="${removable_drives} ${drv}" + fi +done +default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'` + +installdrive="undefined" +forceformat="no" +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +set ${drives} ${removable_drives} +numdrives=`echo $#` + +tgtdrive="${installdrive}" + +function confirm_format { + check_drive="$1" + local confirm_format="no" + + if [[ "$forceformat" == "yes" ]] ; then + return 0 + fi + + if parted -s /dev/$check_drive print &>/dev/null ; then + echo + echo "$check_drive drive contains partition table:" + parted -s /dev/$check_drive print + echo + read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format + if [[ "$confirm_format" == "y" ]] || [[ "$forceformat" == "yes" ]]; then + return 0 + else + return 1 + fi + else + return 0 + fi +} + +format_confirmed="no" + +if [ $numdrives -lt 1 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* There is no suitable media available for installation. *' + echo '* Please attach a drive and try again. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to shut down the system: " _ + poweroff +fi + +if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + while [ "${tgtdrive}" = "undefined" ]; do + clear + echo + echo '********************************************************************************' + echo '* W A R N I N G *' + echo '* *' + echo '* Which of the detected hard drives do you want to be used as *' + echo '* the installation target? *' + echo '* *' + echo '********************************************************************************' + echo + echo "Possible choices" + echo "Persistent drives: ${drives}" + echo "Removable drives: ${removable_drives}" + echo + if [ `echo ${drives} | wc -w` -eq 1 ] ; then + read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive + else + read -p "Choose hard drive: " tgtdrive + fi + match="no" + for drive in ${drives[@]} ${removable_drives[@]}; do + if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then + if confirm_format $tgtdrive ; then + format_confirmed="yes" + break + else + tgtdrive="undefined" + read -p "You may select another disk. Press Enter to continue." _ + fi + fi + done + if [[ "$match" == "no" ]]; then + tgtdrive="undefined" + read -p "Invalid choice. Press Enter to continue." _ + fi + done + clear + chvt 1 +else + tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"` +fi + +if [ "$format_confirmed" != "yes" ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + if ! confirm_format $tgtdrive ; then + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Disk $tgtdrive contains active partition(s). *' + echo '* Installation cannot continue without confirmation. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot + fi + chvt 1 +fi + +# verify tgtdrive is at least 30GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 30720 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Your disk is under 30GB in size. Installation cannot continue. *' + echo '* Restart installation with a larger disk. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot +fi + +# paths in /dev have "/" instead of "!" for cciss devices +tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//') + +# source +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks +else + echo "cdrom" > /tmp/source.ks +fi + +vgremove -ff os +dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10 +sleep 3 +hdparm -z /dev/${tgtdrive} +parted -s /dev/${tgtdrive} mklabel gpt +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24 +parted -s /dev/${tgtdrive} set 1 bios_grub on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224 +parted -s /dev/${tgtdrive} set 2 boot on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424 +sleep 3 +hdparm -z /dev/${tgtdrive} + +# partition + +# This adds support for the p seperator required for cciss devices +if echo ${tgtdrive} | grep -q -e cciss ; then + bootdev=${tgtdrive}p +else + bootdev=${tgtdrive} +fi +echo > /tmp/partition.ks +echo "partition /boot --onpart=/dev/${bootdev}3" >> /tmp/partition.ks +echo "partition pv.001 --ondisk=${tgtdrive} --size=30000 --grow" >> /tmp/partition.ks +echo "volgroup os pv.001" >> /tmp/partition.ks +echo "logvol swap --vgname=os --recommended --name=swap" >> /tmp/partition.ks +echo "logvol / --vgname=os --size=10000 --name=root --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var --vgname=os --size=1 --grow --name=var --fstype=xfs" >> /tmp/partition.ks + +# bootloader +echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks + +# Anaconda can not install grub 0.97 on disks which are >4T. +# The reason is that grub does not support such large geometries +# and it simply thinks that the cylinder number has negative value. +# Here we just set geometry manually so that grub thinks that disk +# size is equal to 1G. +# 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G +echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks +echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks + +%end + +%packages --nobase --excludedocs +@Core +authconfig +bind-utils +cronie +crontabs +curl +daemonize +dhcp +docker-io +fuelmenu +gdisk +lrzip +lsof +man +mlocate +nmap-ncat +ntp +openssh-clients +policycoreutils +rsync +ruby21-puppet +ruby21-rubygem-netaddr +ruby21-rubygem-openstack +selinux-policy-targeted +strace +subscription-manager +sysstat +system-config-firewall-base +tcpdump +telnet +vim-enhanced +virt-what +wget +yum + +%include /tmp/post_partition.ks + +# POSTINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER +# INSTALLATION ITSELF COMPLETED +%post +echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules +chmod +x /etc/rc.modules +echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf +mkdir -p /var/log/coredump +echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf +chmod 777 /var/log/coredump +echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf + +# Mount installation media in chroot +%post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log +#!/bin/sh + +SOURCE="/mnt/sysimage/tmp/source" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +mkdir -p "${SOURCE}" + +case "${repo}" in + nfs:*) + nfs_url="${repo#nfs:}" + mount -t nfs "${nfs_url}" "${SOURCE}" + ;; + *) + if [ -d "/mnt/source" ]; then + mount -o bind "/mnt/source" "${SOURCE}" + fi + ;; +esac + +%post --log=/root/anaconda-post-after-chroot.log +#!/bin/bash + +set -x + +function save_cfg { + scrFile="/etc/sysconfig/network-scripts/ifcfg-$device" + search="domain $domain\nsearch $domain" + sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network + grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts + echo "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream + [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf + [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream + + echo DEVICE=$device > $scrFile + echo ONBOOT=yes >> $scrFile + echo NM_CONTROLLED=no >> $scrFile + echo HWADDR=$hwaddr >> $scrFile + echo USERCTL=no >> $scrFile + echo PEERDNS=no >> $scrFile + if [ $ip ]; then + echo BOOTPROTO=static >> $scrFile + echo IPADDR=$ip >> $scrFile + echo NETMASK=$netmask >> $scrFile + else + echo BOOTPROTO=dhcp >> $scrFile + fi + scrDHCPFile="/etc/sysconfig/network-scripts/ifcfg-$dhcp_interface" + #Ignore gateway and set up DHCP if it is used, otherwise apply it + if [ $dhcp_interface ] && [ "$dhcp_interface" != "$device" ]; then + echo "DEVICE=$dhcp_interface" > $scrDHCPFile + echo "BOOTPROTO=dhcp" >> $scrDHCPFile + echo "ONBOOT=yes" >> $scrDHCPFile + echo "USERCTL=no" >> $scrDHCPFile + else + echo GATEWAY=$gw >> /etc/sysconfig/network + fi +} + +# Default FQDN +hostname="nailgun.mirantis.com" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done +hostname=$hostname +domain=${hostname#*.} +ip=$ip +netmask=$netmask +gw=$gw +device="eth0" +hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` +dhcp_interface=$dhcp_interface +save_cfg + +# Mounting installation source +SOURCE=/tmp/source +FS=/tmp/fs + +echo +mkdir -p ${SOURCE} +mkdir -p ${FS} + +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS} + mount -o loop ${FS}/nailgun.iso ${SOURCE} +fi + +# Copying Repo to the nailgun /var/www directory +repodir="/var/www/nailgun" +mkdir -p ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/images ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/isolinux ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/repodata ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/Packages ${repodir}/centos/fuelweb/x86_64 +cp ${SOURCE}/.treeinfo ${repodir}/centos/fuelweb/x86_64 + +# Copying Ubuntu files +mkdir -p ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/conf ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/db ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/indices ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz ${repodir}/ubuntu/fuelweb/x86_64/images + +# Copying bootstrap image +mkdir -p ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/initramfs.img ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/linux ${repodir}/bootstrap + +mkdir -p /root/.ssh +chmod 700 /root/.ssh +cp ${SOURCE}/bootstrap/bootstrap.rsa /root/.ssh +chmod 600 /root/.ssh/bootstrap.rsa + +# Unpacking puppet manifests for master and slave +cp ${SOURCE}/puppet-slave.tgz ${repodir}/ +tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/modules +mkdir -p /etc/puppet/manifests/ +cp /etc/puppet/modules/osnailyfacter/examples/site.pp /etc/puppet/manifests/site.pp +cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/manifests/ +cp ${SOURCE}/send2syslog.py /bin/send2syslog.py +mkdir -p /var/lib/hiera +touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml + +# Deploy docker images and ctl tools if we built ISO with docker containers support +[ -d "${SOURCE}/docker" ] && cp -r ${SOURCE}/docker ${repodir}/docker + +# Prepare local repository specification +rm /etc/yum.repos.d/CentOS*.repo +cat > /etc/yum.repos.d/nailgun.repo << EOF +[nailgun] +name=Nailgun Local Repo +baseurl=file:/var/www/nailgun/centos/fuelweb/x86_64 +gpgcheck=0 +EOF + +# Disable subscription-manager plugins +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || : +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || : + +# Disable GSSAPI in ssh server config +sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config + +# Copying bootstrap_admin_node.sh, chmod it and +# adding /etc/init/bootstrap_admin_node.conf +cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh +chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh +cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf +echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node + +# Copying version.yaml file. It contains COMMIT_SHA of last commit. +RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml) +mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions +cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml +ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml + +# Generete Fuel UUID +uuidgen > /etc/fuel/fuel-uuid + +###Run fuel menu +[ -z "$showmenu" ] && showmenu="no" +cat > /root/.showfuelmenu << EOF +#Set to yes to run Fuel Setup +#Set to no to accept default settings +showmenu=$showmenu +EOF + +# Prepare custom /etc/issue logon banner and script for changing IP in it +cat > /etc/issue << EOF +######################################### +# Welcome to the Fuel server # +######################################### +Server is running on \m platform + +Fuel UI is available on: +http://:8000 + +Default administrator login: root +Default administrator password: r00tme + +Default Fuel UI login: admin +Default Fuel UI password: admin + +Please change root password on first login. + +EOF + + +cat >> '/etc/rc.local' << EOF +first=yes +for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do +if [ "\$first" = "yes" ]; then + ipstr="Fuel UI is available on: http://\$ip:8000" + first=no +else + ipstr=\$(printf "%s\n%51s" "\$ipstr" "http://\$ip:8000") +fi +done +tmpissue=\$(mktemp) +while read -r line; do + if [[ "\$line" =~ "Fuel UI is available on" ]]; then + echo -e "\$ipstr" >> \$tmpissue + elif [[ "\$line" =~ :8000$ ]]; then + : + else + echo -e "\$line" >> \$tmpissue + fi +done < /etc/issue +mv "\$tmpissue" /etc/issue + +EOF + + +# Unmounting source +umount -f ${SOURCE} +rm -rf ${SOURCE} + +umount -f ${FS} || true +rm -rf ${FS} + +# Enabling/configuring NTPD and ntpdate services +echo "server 127.127.1.0" >> /etc/ntp.conf +echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf +echo "tos orphan 7" >> /etc/ntp.conf + +# Do not show error message on ntpdate failure. Customers should not be confused +# if admin node does not have access to the internet time servers. +sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/' + +# Disabling splash +sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf +sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf + +# Disabling console clearing +sed -i 's/getty/getty --noclear/' /etc/init/tty.conf + +# Disabling starting first console from start-ttys service +sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init + +# Copying default bash settings to the root directory +cp -f /etc/skel/.bash* /root/ + +# Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors +[[ $(virt-what) = "virtualbox" ]] && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf + +%end \ No newline at end of file diff --git a/fuel-build/f_isoroot/f_predeployment/Makefile b/fuel-build/f_isoroot/f_predeployment/Makefile new file mode 100644 index 0000000..a5252df --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/Makefile @@ -0,0 +1,28 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + @mkdir -p release/opnfv + @cp pre-deploy.sh release/opnfv + @cp sysinfo.sh release/opnfv + @cp transform_yaml.py release/opnfv + @chmod 755 release/opnfv/* + +.PHONY: clean +clean: + @rm -rf release + + +.PHONY: release +release:clean all + @cp -Rvp release/* ../release diff --git a/fuel-build/f_isoroot/f_predeployment/README b/fuel-build/f_isoroot/f_predeployment/README new file mode 100644 index 0000000..3eef9f2 --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/README @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is the start of the interactive frontend that will add OPNFV configuration into +the astute.yaml of the nodes. Currently just a test setup - prepare an installation +up to the point of "deploy changes", but run "./pre-deploy.sh fragment.yaml" +before actually hitting deploy, which will make sure to add the example fragment to +the nodes. + +Note that the only part of the fragment.yaml that actually is acted on is the hosts +part at this time. diff --git a/fuel-build/f_isoroot/f_predeployment/pre-deploy.sh b/fuel-build/f_isoroot/f_predeployment/pre-deploy.sh new file mode 100755 index 0000000..c5c6c42 --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/pre-deploy.sh @@ -0,0 +1,401 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +error_exit () { + echo "$@" >&2 + exit 1 +} + +get_env() { + local env_id=${1:-""} + + if [ -z $env_id ]; then + local n_envs=$(fuel env --list | grep -v -E "^id|^--|^ *$" | wc -l) + if [ $n_envs -ne 1 ]; then + echo "Usage: $0 []" >&2 + error_exit "If only a single environment is present it can be left" \ + "out. Otherwise the environment must be selected" + fi + env_id=$(fuel env --list | grep -v -E "^id|^--" | awk '{print $1}') + else + if ! fuel --env $env_id environment 2>/dev/null grep -v -E "^id|^--" | \ + grep -q ^$env_id; then + error_exit "No such environment ID: $env_id" + fi + fi + echo $env_id +} + +get_node_uid () { + cat $1 | grep "^uid: " | sed "s/^uid: '//" | sed "s/'$//" +} + +get_node_role () { + cat $1 | grep "^role: " | sed "s/^role: //" +} + +get_next_cic () { + file=$1 + + last=`cat $file | sed 's/.*://' | grep "cic-" | sed 's/cic\-.*sl//' | sort -n | tail -1` + if [ -z "$last" ]; then + next=1 + else + next=$[$last + 2] + fi + echo $next +} + +get_next_compute () { + file=$1 + + last=`cat $file | sed 's/.*://' | grep "cmp-" | sed 's/cmp\-.*sl//' | sort -n | tail -1` + if [ -z "$last" ]; then + next=7 + else + next=$[$last + 2] + fi + echo $next +} + +modify_hostnames () { + env=$1 + file=$2 + for line in `cat $file` + do + old=`echo $line | sed 's/:.*//'` + new=`echo $line | sed 's/.*://'` + echo "Applying: $old -> $new" + + for dfile in deployment_$env/*.yaml + do + sed -i "s/$old/$new/g" $dfile + done + + for pfile in provisioning_$env/*.yaml + do + sed -i "s/$old/$new/g" $pfile + done + done +} + +setup_hostnames () { + ENV=$1 + cd ${CONFIGDIR} + touch hostnames.$ENV + + for dfile in deployment_$ENV/*.yaml + do + uid=`get_node_uid $dfile` + hostname=`grep "^node-$uid:" hostnames.$ENV | sed 's/.*://'` + if [ -z $hostname ]; then + + pfile=provisioning_$ENV/node-$uid.yaml + role=`get_node_role $dfile` + + case $role in + primary-controller) + hostname="cic-pod0-sh0-sl`get_next_cic hostnames.$ENV`" + ;; + controller) + hostname="cic-pod0-sh0-sl`get_next_cic hostnames.$ENV`" + ;; + compute) + hostname="cmp-pod0-sh0-sl`get_next_compute hostnames.$ENV`" + ;; + *) + echo "Unknown node type for UID $uid" + exit 1 + ;; + esac + + echo "node-$uid:$hostname" >> hostnames.$ENV + else + echo "Already got hostname $hostname for node-$uid" + + fi + done + + rm -f hostnames.$ENV.old + mv hostnames.$ENV hostnames.$ENV.old + sort hostnames.$ENV.old | uniq > hostnames.$ENV + modify_hostnames $ENV hostnames.$ENV +} + + + +get_provisioning_info () { + ENV=$1 + mkdir -p ${CONFIGDIR} + cd ${CONFIGDIR} + rm -Rf provisioning_$ENV + echo "Getting provisioning info..." + fuel --env $ENV provisioning --default + if [ $? -ne 0 ]; then + echo "Error: Could not get provisioning info for env $ENV">&2 + exit 1 + fi +} + +get_deployment_info () { + ENV=$1 + mkdir -p ${CONFIGDIR} + cd ${CONFIGDIR} + rm -Rf deployment_$ENV + echo "Getting deployment info..." + fuel --env $ENV deployment --default + if [ $? -ne 0 ]; then + echo "Error: Could not get deployment info for env $ENV">&2 + exit 1 + fi +} + +transform_yaml () { + ENV=$1 + cd ${CONFIGDIR} + for dfile in deployment_$ENV/*.yaml + do + /opt/opnfv/transform_yaml.py $dfile + done +} + +commit_changes () { + ENV=$1 + cd ${CONFIGDIR} + + fuel --env $ENV deployment --upload + fuel --env $ENV provisioning --upload +} + +add_yaml_fragment () { + ENV=$1 + FRAGMENT=${CONFIGDIR}/fragment.yaml.$ENV + + cd ${CONFIGDIR} + for dfile in deployment_$ENV/*.yaml + do + cnt=`grep "^opnfv:" $dfile | wc -l ` + if [ $cnt -eq 0 ]; then + echo "Adding fragment to $dfile" + cat $FRAGMENT >> $dfile + else + echo "Already have fragment in $dfile" + fi + done +} + + +ip_valid() { + IP_ADDRESS="$1" + # Check if the format looks right_ + echo "$IP_ADDRESS" | egrep -qE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' || return 1 + #check that each octect is less than or equal to 255: + echo $IP_ADDRESS | awk -F'.' '$1 <=255 && $2 <= 255 && $3 <=255 && $4 <= 255 {print "Y" } ' | grep -q Y || return 1 + return 0 +} + + +generate_ntp_entry() { + FILE=$1 + read -p "NTP server:" NTP_SERVER + if [ -z "$NTP_SERVER" ]; then + return 1 + elif confirm_yes "Are you sure you want to add this entry (y/n): "; then + echo "Confirmed" + echo " server $NTP_SERVER" >> $FILE + fi +} + +generate_hostfile_entry() { + FILE=$1 + read -p "Name:" HOST_NAME + if [ -z "$HOST_NAME" ]; then + return 1 + else + read -p "FQDN:" HOST_FQDN + read -p "IP: " HOST_IP + while ! ip_valid "$HOST_IP" + do + echo "This is not a valid IP! Try again." + read -p "IP: " HOST_IP + done + fi + if confirm_yes "Are you sure you want to add this entry (y/n): "; then + echo "Confirmed" + echo " - name: $HOST_NAME" >> $FILE + echo " address: $HOST_IP" >> $FILE + echo " fqdn: $HOST_FQDN" >> $FILE + else + echo "Not confirmed" + fi + return 0 +} + +generate_dns_entry() { + FILE=$1 + PROMPT=$2 + read -p "${PROMPT}:" DNS_IP + if [ -z "$DNS_IP" ]; then + return 1 + else + while ! ip_valid "$DNS_IP" + do + echo "This is not a valid IP! Try again." + read -p "${PROMPT}: " DNS_IP + done + fi + if confirm_yes "Are you sure you want to add this entry (y/n): "; then + echo "Confirmed" + echo " - $DNS_IP" >> $FILE + else + echo "Not confirmed" + fi + return 0 +} + +confirm_yes() { + prompt=$1 + while true + do + read -p "$prompt" YESNO + case $YESNO in + [Yy]) + return 0 + ;; + [Nn]) + return 1 + ;; + esac + done +} + +generate_yaml_fragment() { + ENV=$1 + FRAGMENT=${CONFIGDIR}/fragment.yaml.$ENV + + if [ -f $FRAGMENT ]; then + echo "Manual configuration already performed, reusing previous data from $FRAGMENT." + echo "Press return to continue or ^C to stop." + read ans + return + fi + + echo "opnfv:" > ${FRAGMENT} + + clear + echo -e "\n\nPre-deployment configuration\n\n" + + echo -e "\n\nIPs for the DNS servers to go into /etc/resolv.conf. You will be" + echo -e "prompted for one IP at the time. Press return on an empty line" + echo -e "to complete your input. If no DNS server is specified, the IP of" + echo -e "the Fuel master will be used instead.\n" + + DNSCICYAML=${CONFIGDIR}/cicdns.yaml.$ENV + rm -f $DNSCICYAML + + echo -e "\n\n" + + while generate_dns_entry $DNSCICYAML "IP for CIC name servers" + do + : + done + + if [ -f $DNSCICYAML ]; then + echo " dns:" >> $FRAGMENT + echo " controller:" >> $FRAGMENT + cat $DNSCICYAML >> $FRAGMENT + fi + + + DNSCMPYAML=${CONFIGDIR}/cmpdns.yaml.$ENV + rm -f $DNSCMPYAML + + echo -e "\n\n" + + while generate_dns_entry $DNSCMPYAML "IP for compute node name servers" + do + : + done + + + if [ -f $DNSCMPYAML ]; then + if [ ! -f $DNSCICYAML ]; then + echo " dns:" >> $FRAGMENT + fi + echo " compute:" >> $FRAGMENT + cat $DNSCMPYAML >> $FRAGMENT + fi + + echo -e "\n\nHosts file additions for controllers and compute nodes. You will be" + echo -e "prompted for name, FQDN and IP for each entry. Press return when prompted" + echo -e "for a name when you have completed your input.\n" + + + HOSTYAML=${CONFIGDIR}/hosts.yaml.$ENV + rm -f $HOSTYAML + while generate_hostfile_entry $HOSTYAML + do + : + done + + if [ -f $HOSTYAML ]; then + echo " hosts:" >> $FRAGMENT + cat $HOSTYAML >> $FRAGMENT + fi + + echo -e "\n\nNTP upstream configuration for controllers.You will be" + echo -e "prompted for a NTP server each entry. Press return when prompted" + echo -e "for a NTP serverwhen you have completed your input.\n" + + + NTPYAML=${CONFIGDIR}/ntp.yaml.$ENV + rm -f $NTPYAML + while generate_ntp_entry $NTPYAML + do + : + done + + if [ -f $NTPYAML ]; then + echo " ntp:" >> $FRAGMENT + echo " controller: |" >> $FRAGMENT + cat $NTPYAML >> $FRAGMENT + + echo " compute: |" >> $FRAGMENT + for ctl in `find $CONFIGDIR/deployment_$ENV -name '*controller*.yaml'` + do + fqdn=`grep "^fqdn:" $ctl | sed 's/fqdn: *//'` + echo " server $fqdn" >> $FRAGMENT + done + fi + + # If nothing added make sure we get an empty opnfv hash + # instead of a NULL hash. + if [ $(wc -l $FRAGMENT | awk '{print $1}') -le 1 ]; then + echo "opnfv: {}" >$FRAGMENT + fi +} + +ENV=$(get_env "$@") + +CONFIGDIR="/var/lib/opnfv" +mkdir -p $CONFIGDIR + +get_deployment_info $ENV +# Uncomment the below to enable the control_bond example +#transform_yaml $ENV +get_provisioning_info $ENV +generate_yaml_fragment $ENV +# The feature to change hostnames from node- to cmp- or cic- is disabled. +# To turn it on, uncomment the following line. +#setup_hostnames $ENV +add_yaml_fragment $ENV +commit_changes $ENV diff --git a/fuel-build/f_isoroot/f_predeployment/sysinfo.sh b/fuel-build/f_isoroot/f_predeployment/sysinfo.sh new file mode 100755 index 0000000..e99cac0 --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/sysinfo.sh @@ -0,0 +1,12 @@ +#!/bin/sh +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +dockerctl shell cobbler cobbler system list | grep -v default | xargs -n 1 host | sort | sed 's/\..* /\t/' diff --git a/fuel-build/f_isoroot/f_predeployment/transform_yaml.py b/fuel-build/f_isoroot/f_predeployment/transform_yaml.py new file mode 100755 index 0000000..14eec4c --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/transform_yaml.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Remove control and management network transformations from file. +# Only to be used together with f_control_bond_example (enable in +# pre-deploy.sh) + +import yaml +import re +import sys +import os + +if len(sys.argv) != 2: + sys.stderr.write("Usage: "+sys.argv[0]+" \n") + sys.exit(1) + +filename = sys.argv[1] +if not os.path.exists(filename): + sys.stderr.write("ERROR: The file "+filename+" could not be opened\n") + sys.exit(1) + +ignore_values = [ "eth0", "eth1", "br-mgmt", "br-fw-admin" ] + +infile = open(filename, 'r') +doc = yaml.load(infile) +infile.close() + +out={} + +for scheme in doc: + if scheme == "network_scheme": + mytransformation = {} + for operation in doc[scheme]: + if operation == "transformations": + # We need the base bridges for l23network to be happy, + # remove everything else. + mytrans = [ { "action": "add-br", "name": "br-mgmt" }, + { "action": "add-br", "name": "br-fw-admin" } ] + for trans in doc[scheme][operation]: + delete = 0 + for ignore in ignore_values: + matchObj = re.search(ignore,str(trans)) + if matchObj: + delete = 1 + if delete == 0: + mytrans.append(trans) + else: + pass + #print "Deleted", trans + + mytransformation[operation] = mytrans + else: + mytransformation[operation] = doc[scheme][operation] + out[scheme] = mytransformation + else: + out[scheme] = doc[scheme] + +outfile = open(filename, 'w') +outfile.write(yaml.dump(out, default_flow_style=False)) +outfile.close() -- cgit 1.2.3-korg