diff options
Diffstat (limited to 'build/f_isoroot')
-rw-r--r-- | build/f_isoroot/Makefile | 33 | ||||
-rw-r--r-- | build/f_isoroot/README | 16 | ||||
-rw-r--r-- | build/f_isoroot/cache.mk | 37 | ||||
-rw-r--r-- | build/f_isoroot/f_bootstrap/Makefile | 48 | ||||
-rw-r--r-- | build/f_isoroot/f_bootstrap/README | 24 | ||||
-rwxr-xr-x | build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh | 266 | ||||
-rwxr-xr-x | build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig | 246 | ||||
-rwxr-xr-x | build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh | 4 | ||||
-rwxr-xr-x | build/f_isoroot/f_bootstrap/post-scripts/03_install_repo.sh | 19 | ||||
-rwxr-xr-x | build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh | 4 | ||||
-rw-r--r-- | build/f_isoroot/f_kscfg/Makefile | 44 | ||||
-rw-r--r-- | build/f_isoroot/f_kscfg/README | 18 | ||||
-rw-r--r-- | build/f_isoroot/f_kscfg/ks.cfg | 609 | ||||
-rw-r--r-- | build/f_isoroot/f_kscfg/ks.cfg.orig | 602 | ||||
-rw-r--r-- | build/f_isoroot/f_odlpluginbuild/Makefile | 73 | ||||
-rw-r--r-- | build/f_isoroot/f_odlpluginbuild/config/opendaylight_config.yaml | 52 | ||||
-rw-r--r-- | build/f_isoroot/f_repobuild/Makefile | 86 | ||||
-rwxr-xr-x | build/f_isoroot/f_repobuild/select_ubuntu_repo.sh | 33 |
18 files changed, 2214 insertions, 0 deletions
diff --git a/build/f_isoroot/Makefile b/build/f_isoroot/Makefile new file mode 100644 index 000000000..3831a09f0 --- /dev/null +++ b/build/f_isoroot/Makefile @@ -0,0 +1,33 @@ +############################################################################## +# 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_kscfg f_bootstrap f_repobuild f_odlpluginbuild +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: $(SUBDIRS) + @cp -Rvp release/* ../release/isoroot + +include cache.mk diff --git a/build/f_isoroot/README b/build/f_isoroot/README new file mode 100644 index 000000000..eb54c0827 --- /dev/null +++ b/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/build/f_isoroot/cache.mk b/build/f_isoroot/cache.mk new file mode 100644 index 000000000..2df3b6bd1 --- /dev/null +++ b/build/f_isoroot/cache.mk @@ -0,0 +1,37 @@ +############################################################################## +# 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 +############################################################################## + +############################################################################# +# Cache operations - only used when building through ci/build.sh +# +# This file is only meant for a top Makefile which is only calling its +# own SUBDIRS, without building any cachable artifact by itself. +############################################################################# + +# Call sub caches +SUBGETCACHE = $(addsuffix .getcache,$(SUBDIRS)) +$(SUBGETCACHE): %.getcache: + $(MAKE) -C $* -f Makefile get-cache + +SUBPUTCACHE = $(addsuffix .putcache,$(SUBDIRS)) +$(SUBPUTCACHE): %.putcache: + $(MAKE) -C $* -f Makefile put-cache + +SUBCLEANCACHE = $(addsuffix .cleancache,$(SUBDIRS)) +$(SUBCLEANCACHE): %.cleancache: + $(MAKE) -C $* -f Makefile clean-cache + +.PHONY: get-cache +get-cache: $(SUBGETCACHE) + +.PHONY: put-cache +put-cache: $(SUBPUTCACHE) + +.PHONY: clean-cache +clean-cache: $(SUBCLEANCACHE) diff --git a/build/f_isoroot/f_bootstrap/Makefile b/build/f_isoroot/f_bootstrap/Makefile new file mode 100644 index 000000000..a958aa2d6 --- /dev/null +++ b/build/f_isoroot/f_bootstrap/Makefile @@ -0,0 +1,48 @@ +############################################################################## +# 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 + +############################################################################# +# Cache operations - only used when building through ci/build.sh +############################################################################# + +# Clean local data related to caching - called prior to ordinary build +.PHONY: clean-cache +clean-cache: clean + @echo "clean-cache not implemented" + +# Try to download cache - called prior to ordinary build +.PHONY: get-cache +get-cache: + @echo "get-cache not implemented" + +# Store cache if not already stored - called after ordinary build +.PHONY: put-cache +put-cache: + @echo "put-cache not implemented" diff --git a/build/f_isoroot/f_bootstrap/README b/build/f_isoroot/f_bootstrap/README new file mode 100644 index 000000000..5da954ca4 --- /dev/null +++ b/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/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh b/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh new file mode 100755 index 000000000..065d0cb7d --- /dev/null +++ b/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh @@ -0,0 +1,266 @@ +#!/bin/bash +FUEL_RELEASE=$(grep release: /etc/fuel/version.yaml | cut -d: -f2 | tr -d '" ') + +function countdown() { + local i + sleep 1 + for ((i=$1-1; i>=1; i--)); do + printf '\b\b\b\b%04d' "$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 +export ADMIN_INTERFACE=eth0 + +showmenu="no" +if [ -f /etc/fuel/bootstrap_admin_node.conf ]; then + . /etc/fuel/bootstrap_admin_node.conf + echo "Applying admin interface '$ADMIN_INTERFACE'" +fi + +echo "Applying default Fuel settings..." +set -x +fuelmenu --save-only --iface=$ADMIN_INTERFACE +set +x +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 -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi + +if [ "$wait_for_external_config" == "yes" ]; then + wait_timeout=3000 + pidfile=/var/lock/wait_for_external_config + echo -n "Waiting for external configuration (or press ESC to skip)... +$wait_timeout" + countdown $wait_timeout & countdown_pid=$! + exec -a wait_for_external_config sleep $wait_timeout & wait_pid=$! + echo $wait_pid > $pidfile + while ps -p $countdown_pid &> /dev/null && ps -p $wait_pid &>/dev/null; do + read -s -n 1 -t 2 key + case "$key" in + $'\e') echo -e "\b\b\b\b abort on user input" + break + ;; + *) ;; + esac + done + { kill $countdown_pid $wait_pid & wait $!; } + rm -f $pidfile +fi + + +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +# XXX: ssh keys which should be included into the bootstrap image are +# generated during containers deployment. However cobbler checkfs for +# a kernel and initramfs when creating a profile, which poses chicken +# and egg problem. Fortunately cobbler is pretty happy with empty files +# so it's easy to break the loop. +make_ubuntu_bootstrap_stub () { + local bootstrap_dir='/var/www/nailgun/bootstrap/ubuntu' + mkdir -p $bootstrap_dir + for item in linux initramfs.img; do + touch "$bootstrap_dir/$item" + done +} + +get_bootstrap_flavor () { + local ASTUTE_YAML='/etc/fuel/astute.yaml' + python <<-EOF + from fuelmenu.fuelmenu import Settings + conf = Settings().read("$ASTUTE_YAML").get('BOOTSTRAP', {}) + print(conf.get('flavor', 'centos')) + EOF +} + +# Actually build the bootstrap image +build_ubuntu_bootstrap () { + local ret=1 + local max_attempts=3 + local config='/etc/fuel-bootstrap-image.conf' + local log='/var/log/fuel-bootstrap-image-build.log' + if ! grep -qE '^BOOTSTRAP_SSH_KEYS' "$config"; then + # FIXME: config file generated by fuelmenu has no trailing newline + echo >> "$config" + cat >> "$config" <<-EOF + BOOTSTRAP_SSH_KEYS=/root/.ssh/id_rsa.pub + EOF + fi + for n in `seq 1 $max_attempts`; do + echo "Bulding bootstrap image, attempt $n" >&2 + if fuel-bootstrap-image >>"$log" 2>&1; then + ret=0 + fuel-bootstrap-image-set "ubuntu" + break + fi + done + if [ $ret -ne 0 ]; then + warning="WARNING: failed to build the bootstrap image, see $log for details. +Perhaps your Internet connection is broken. Please fix the problem and run +\`fuel-bootstrap-image-set ubuntu\`" + fuel notify --topic warning --send "$warning" + fi + return $ret +} + + +# Create empty files to make cobbler happy +# (even if we don't use Ubuntu based bootstrap) +make_ubuntu_bootstrap_stub + +service docker start + +if [ -f /root/.build_images ]; then + #Fail on all errors + set -e + trap fail EXIT + + echo "Loading Fuel base image for Docker..." + docker load -i /var/www/nailgun/docker/images/fuel-images.tar + + echo "Building Fuel Docker images..." + WORKDIR=$(mktemp -d /tmp/docker-buildXXX) + SOURCE=/var/www/nailgun/docker + REPO_CONT_ID=$(docker -D run -d -p 80 -v /var/www/nailgun:/var/www/nailgun fuel/centos sh -c 'mkdir /var/www/html/os;ln -sf /var/www/nailgun/centos/x86_64 /var/www/html/os/x86_64;/usr/sbin/apachectl -DFOREGROUND') + RANDOM_PORT=$(docker port $REPO_CONT_ID 80 | cut -d':' -f2) + + for imagesource in /var/www/nailgun/docker/sources/*; do + if ! [ -f "$imagesource/Dockerfile" ]; then + echo "Skipping ${imagesource}..." + continue + fi + image=$(basename "$imagesource") + cp -R "$imagesource" $WORKDIR/$image + mkdir -p $WORKDIR/$image/etc + cp -R /etc/puppet /etc/fuel $WORKDIR/$image/etc + sed -e "s/_PORT_/${RANDOM_PORT}/" -i $WORKDIR/$image/Dockerfile + sed -e 's/production:.*/production: "docker-build"/' -i $WORKDIR/$image/etc/fuel/version.yaml + docker build -t fuel/${image}_${FUEL_RELEASE} $WORKDIR/$image + done + docker rm -f $REPO_CONT_ID + rm -rf "$WORKDIR" + + #Remove trap for normal deployment + trap - EXIT + set +e +else + echo "Loading docker images. (This may take a while)" + docker load -i /var/www/nailgun/docker/images/fuel-images.tar +fi + +# 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 + +if [ "`get_bootstrap_flavor`" = "ubuntu" ]; then + build_ubuntu_bootstrap || true +fi + +### 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 + +# Enable updates repository +cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-updates.repo << EOF +[mos${FUEL_RELEASE}-updates] +name=mos${FUEL_RELEASE}-updates +baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/updates/x86_64/ +gpgcheck=0 +skip_if_unavailable=1 +EOF + +# Enable security repository +cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-security.repo << EOF +[mos${FUEL_RELEASE}-security] +name=mos${FUEL_RELEASE}-security +baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/security/x86_64/ +gpgcheck=0 +skip_if_unavailable=1 +EOF + +#Check if repo is accessible +echo "Checking for access to updates repository..." +repourl=$(grep baseurl /etc/yum.repos.d/*updates* 2>/dev/null | cut -d'=' -f2- | head -1) +if urlaccesscheck check "$repourl" ; then + UPDATE_ISSUES=0 +else + UPDATE_ISSUES=1 +fi + +if [ $UPDATE_ISSUES -eq 1 ]; then + message="There is an issue connecting to the Fuel update repository. \ +Please fix your connection prior to applying any updates. \ +Once the connection is fixed, we recommend reviewing and applying \ +Maintenance Updates for this release of Mirantis OpenStack: \ +https://docs.mirantis.com/openstack/fuel/fuel-${FUEL_RELEASE}/\ +release-notes.html#maintenance-updates" + level="warning" +else + message="We recommend reviewing and applying Maintenance Updates \ +for this release of Mirantis OpenStack: \ +https://docs.mirantis.com/openstack/fuel/fuel-${FUEL_RELEASE}/\ +release-notes.html#maintenance-updates" + level="done" +fi +echo +echo "*************************************************" +echo -e "${message}" +echo "*************************************************" +echo "Sending notification to Fuel UI..." +fuel notify --topic "${level}" --send "${message}" + +# TODO(kozhukalov) If building of bootstrap image fails +# and if this image was supposed to be a default bootstrap image +# we need to warn a user about this and give her +# advice how to treat this. + +echo "Fuel node deployment complete!" diff --git a/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig b/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig new file mode 100755 index 000000000..1bc349314 --- /dev/null +++ b/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig @@ -0,0 +1,246 @@ +#!/bin/bash +FUEL_RELEASE=$(grep release: /etc/fuel/version.yaml | cut -d: -f2 | tr -d '" ') + +function countdown() { + local i + sleep 1 + for ((i=$1-1; i>=1; i--)); do + printf '\b\b\b\b%04d' "$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 +export ADMIN_INTERFACE=eth0 + +showmenu="no" +if [ -f /etc/fuel/bootstrap_admin_node.conf ]; then + . /etc/fuel/bootstrap_admin_node.conf + echo "Applying admin interface '$ADMIN_INTERFACE'" +fi + +echo "Applying default Fuel settings..." +set -x +fuelmenu --save-only --iface=$ADMIN_INTERFACE +set +x +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 -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi + +if [ "$wait_for_external_config" == "yes" ]; then + wait_timeout=3000 + pidfile=/var/lock/wait_for_external_config + echo -n "Waiting for external configuration (or press ESC to skip)... +$wait_timeout" + countdown $wait_timeout & countdown_pid=$! + exec -a wait_for_external_config sleep $wait_timeout & wait_pid=$! + echo $wait_pid > $pidfile + while ps -p $countdown_pid &> /dev/null && ps -p $wait_pid &>/dev/null; do + read -s -n 1 -t 2 key + case "$key" in + $'\e') echo -e "\b\b\b\b abort on user input" + break + ;; + *) ;; + esac + done + { kill $countdown_pid $wait_pid & wait $!; } + rm -f $pidfile +fi + + +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +# XXX: ssh keys which should be included into the bootstrap image are +# generated during containers deployment. However cobbler checkfs for +# a kernel and initramfs when creating a profile, which poses chicken +# and egg problem. Fortunately cobbler is pretty happy with empty files +# so it's easy to break the loop. +make_ubuntu_bootstrap_stub () { + local bootstrap_dir='/var/www/nailgun/bootstrap/ubuntu' + mkdir -p $bootstrap_dir + for item in linux initramfs.img; do + touch "$bootstrap_dir/$item" + done +} + +get_bootstrap_flavor () { + local ASTUTE_YAML='/etc/fuel/astute.yaml' + python <<-EOF + from fuelmenu.fuelmenu import Settings + conf = Settings().read("$ASTUTE_YAML").get('BOOTSTRAP', {}) + print(conf.get('flavor', 'centos')) + EOF +} + +# Actually build the bootstrap image +build_ubuntu_bootstrap () { + local ret=1 + local max_attempts=3 + local config='/etc/fuel-bootstrap-image.conf' + local log='/var/log/fuel-bootstrap-image-build.log' + if ! grep -qE '^BOOTSTRAP_SSH_KEYS' "$config"; then + # FIXME: config file generated by fuelmenu has no trailing newline + echo >> "$config" + cat >> "$config" <<-EOF + BOOTSTRAP_SSH_KEYS=/root/.ssh/id_rsa.pub + EOF + fi + for n in `seq 1 $max_attempts`; do + echo "Bulding bootstrap image, attempt $n" >&2 + if fuel-bootstrap-image >>"$log" 2>&1; then + ret=0 + fuel-bootstrap-image-set "ubuntu" + break + fi + done + if [ $ret -ne 0 ]; then + warning="WARNING: failed to build the bootstrap image, see $log for details. +Perhaps your Internet connection is broken. Please fix the problem and run +\`fuel-bootstrap-image-set ubuntu\`" + fuel notify --topic warning --send "$warning" + fi + return $ret +} + + +# Create empty files to make cobbler happy +# (even if we don't use Ubuntu based bootstrap) +make_ubuntu_bootstrap_stub + +service docker start + +if [ -f /root/.build_images ]; then + #Fail on all errors + set -e + trap fail EXIT + + echo "Loading Fuel base image for Docker..." + docker load -i /var/www/nailgun/docker/images/fuel-images.tar + + echo "Building Fuel Docker images..." + WORKDIR=$(mktemp -d /tmp/docker-buildXXX) + SOURCE=/var/www/nailgun/docker + REPO_CONT_ID=$(docker -D run -d -p 80 -v /var/www/nailgun:/var/www/nailgun fuel/centos sh -c 'mkdir /var/www/html/os;ln -sf /var/www/nailgun/centos/x86_64 /var/www/html/os/x86_64;/usr/sbin/apachectl -DFOREGROUND') + RANDOM_PORT=$(docker port $REPO_CONT_ID 80 | cut -d':' -f2) + + for imagesource in /var/www/nailgun/docker/sources/*; do + if ! [ -f "$imagesource/Dockerfile" ]; then + echo "Skipping ${imagesource}..." + continue + fi + image=$(basename "$imagesource") + cp -R "$imagesource" $WORKDIR/$image + mkdir -p $WORKDIR/$image/etc + cp -R /etc/puppet /etc/fuel $WORKDIR/$image/etc + sed -e "s/_PORT_/${RANDOM_PORT}/" -i $WORKDIR/$image/Dockerfile + sed -e 's/production:.*/production: "docker-build"/' -i $WORKDIR/$image/etc/fuel/version.yaml + docker build -t fuel/${image}_${FUEL_RELEASE} $WORKDIR/$image + done + docker rm -f $REPO_CONT_ID + rm -rf "$WORKDIR" + + #Remove trap for normal deployment + trap - EXIT + set +e +else + echo "Loading docker images. (This may take a while)" + docker load -i /var/www/nailgun/docker/images/fuel-images.tar +fi + +# 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 + +if [ "`get_bootstrap_flavor`" = "ubuntu" ]; then + build_ubuntu_bootstrap || true +fi + +# Enable updates repository +cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-updates.repo << EOF +[mos${FUEL_RELEASE}-updates] +name=mos${FUEL_RELEASE}-updates +baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/updates/x86_64/ +gpgcheck=0 +skip_if_unavailable=1 +EOF + +# Enable security repository +cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-security.repo << EOF +[mos${FUEL_RELEASE}-security] +name=mos${FUEL_RELEASE}-security +baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/security/x86_64/ +gpgcheck=0 +skip_if_unavailable=1 +EOF + +#Check if repo is accessible +echo "Checking for access to updates repository..." +repourl=$(grep baseurl /etc/yum.repos.d/*updates* 2>/dev/null | cut -d'=' -f2- | head -1) +if urlaccesscheck check "$repourl" ; then + UPDATE_ISSUES=0 +else + UPDATE_ISSUES=1 +fi + +if [ $UPDATE_ISSUES -eq 1 ]; then + message="There is an issue connecting to the Fuel update repository. \ +Please fix your connection prior to applying any updates. \ +Once the connection is fixed, we recommend reviewing and applying \ +Maintenance Updates for this release of Mirantis OpenStack: \ +https://docs.mirantis.com/openstack/fuel/fuel-${FUEL_RELEASE}/\ +release-notes.html#maintenance-updates" + level="warning" +else + message="We recommend reviewing and applying Maintenance Updates \ +for this release of Mirantis OpenStack: \ +https://docs.mirantis.com/openstack/fuel/fuel-${FUEL_RELEASE}/\ +release-notes.html#maintenance-updates" + level="done" +fi +echo +echo "*************************************************" +echo -e "${message}" +echo "*************************************************" +echo "Sending notification to Fuel UI..." +fuel notify --topic "${level}" --send "${message}" + +# TODO(kozhukalov) If building of bootstrap image fails +# and if this image was supposed to be a default bootstrap image +# we need to warn a user about this and give her +# advice how to treat this. + +echo "Fuel node deployment complete!" diff --git a/build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh b/build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh new file mode 100755 index 000000000..7ac896589 --- /dev/null +++ b/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/build/f_isoroot/f_bootstrap/post-scripts/03_install_repo.sh b/build/f_isoroot/f_bootstrap/post-scripts/03_install_repo.sh new file mode 100755 index 000000000..427a55add --- /dev/null +++ b/build/f_isoroot/f_bootstrap/post-scripts/03_install_repo.sh @@ -0,0 +1,19 @@ +#/bin/sh +echo "Installing pre-build repo" +if [ ! -d /opt/opnfv/nailgun ]; then + echo "Error - found no repo!" + exit 1 +fi + +mkdir -p /var/www/nailgun +mv /opt/opnfv/nailgun/* /var/www/nailgun +if [ $? -ne 0 ]; then + echo "Error moving repos to their correct location!" + exit 1 +fi +rmdir /opt/opnfv/nailgun +if [ $? -ne 0 ]; then + echo "Error removing /opt/opnfv/nailgun directory!" + exit 1 +fi +echo "Done installing pre-build repo" diff --git a/build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh b/build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh new file mode 100755 index 000000000..ac427bf87 --- /dev/null +++ b/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/build/f_isoroot/f_kscfg/Makefile b/build/f_isoroot/f_kscfg/Makefile new file mode 100644 index 000000000..fe740418d --- /dev/null +++ b/build/f_isoroot/f_kscfg/Makefile @@ -0,0 +1,44 @@ +############################################################################## +# 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 + +############################################################################# +# Cache operations - only used when building through ci/build.sh +############################################################################# + +# Clean local data related to caching - called prior to ordinary build +.PHONY: clean-cache +clean-cache: clean + @echo "clean-cache not implemented" + +# Try to download cache - called prior to ordinary build +.PHONY: get-cache +get-cache: + @echo "get-cache not implemented" + +# Store cache if not already stored - called after ordinary build +.PHONY: put-cache +put-cache: + @echo "put-cache not implemented" diff --git a/build/f_isoroot/f_kscfg/README b/build/f_isoroot/f_kscfg/README new file mode 100644 index 000000000..c85efde77 --- /dev/null +++ b/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/build/f_isoroot/f_kscfg/ks.cfg b/build/f_isoroot/f_kscfg/ks.cfg new file mode 100644 index 000000000..8c20971f8 --- /dev/null +++ b/build/f_isoroot/f_kscfg/ks.cfg @@ -0,0 +1,609 @@ +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 !(blkid | grep -q "${drv}.*Fuel"); then + if (grep -q 0 /sys/block/${drv}/removable); then + drives="${drives} ${drv}" + else + removable_drives="${removable_drives} ${drv}" + fi + 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" ]] || [[ "$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 41GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 41984 ]; 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 41GB 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-label/"OpenStack_Fuel"; then + echo "harddrive --partition=LABEL="OpenStack_Fuel" --dir=/" > /tmp/source.ks +elif 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 /boot/efi --onpart=/dev/${bootdev}2" >> /tmp/partition.ks +echo "partition pv.001 --ondisk=${tgtdrive} --size=41000 --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=10000 --percent 30 --grow --name=var --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var/lib/docker --vgname=os --size=17000 --percent 20 --grow --name=varlibdocker --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var/log --vgname=os --size=4096 --percent 50 --grow --name=varlog --fstype=ext4" >> /tmp/partition.ks + + +# bootloader +echo "bootloader --location=partition --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 +fuel +fuel-library >= 7.0 +fuel-dockerctl +authconfig +bind-utils +cronie +crontabs +curl +daemonize +dhcp +docker-io +fuel-bootstrap-image +fuel-bootstrap-image-builder +fuel-createmirror +fuel-target-centos-images6.6 +fuel-package-updates +fuelmenu +fuel-docker-images +gdisk +lrzip +lsof +man +mlocate +nmap-ncat +ntp +ntpdate +openssh-clients +policycoreutils +python-daemon +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 +yum-plugin-priorities + +%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 + +set -x + +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-$admin_interface" + 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=$admin_interface > $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" != "$admin_interface" ]; 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 + [ -n "$build_images" -a "$build_images" != "0" ] && echo -e "$build_images" > /root/.build_images +} + +# 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 +admin_interface=${admin_interface:-"eth0"} +hwaddr=`ifconfig $admin_interface | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` +dhcp_interface=$dhcp_interface +build_images=$build_images +wait_for_external_config=$wait_for_external_config +save_cfg + +# Mounting installation source +SOURCE=/tmp/source +FS=/tmp/fs + +echo +mkdir -p ${SOURCE} +mkdir -p ${FS} + +if test -e /dev/disk/by-label/"OpenStack_Fuel"; then + mount /dev/disk/by-label/"OpenStack_Fuel" ${SOURCE} +elif 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 + +OPENSTACK_VERSION=`cat ${SOURCE}/openstack_version` + +# ---------------------- +# UNPACKING REPOSITORIES +# ---------------------- + +wwwdir="/var/www/nailgun" +repodir="${wwwdir}/${OPENSTACK_VERSION}" + +# Copying Centos files +mkdir -p ${repodir}/centos/x86_64 +cp -r ${SOURCE}/images ${repodir}/centos/x86_64 +cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64 +cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64 +cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64 +cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64 + +# Copying Ubuntu files +mkdir -p ${repodir}/ubuntu/x86_64/images +cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64 +cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64 + +# We do not ship debian-installer kernel and initrd on ISO. +# But we still need to be able to create ubuntu cobbler distro +# which requires kernel and initrd to be available. So, we +# just touch these files to work around cobbler's limitation. +touch ${repodir}/ubuntu/x86_64/images/linux +touch ${repodir}/ubuntu/x86_64/images/initrd.gz + +# make links for backward compatibility +ln -s ${repodir}/centos ${wwwdir}/centos +ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu + +# -------------------------- +# UNPACKING PUPPET MANIFESTS +# -------------------------- + +# create folders +#mkdir -p /etc/puppet/${OPENSTACK_VERSION}/manifests/ +#mkdir -p /etc/puppet/${OPENSTACK_VERSION}/modules/ +#rm -rf /etc/puppet/modules/ + +# TODO(ikalnitsky): investigate why we need this +#cp ${SOURCE}/puppet-slave.tgz ${wwwdir}/ + +# place modules and manifests +#tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/${OPENSTACK_VERSION}/modules +#cp /etc/puppet/${OPENSTACK_VERSION}/modules/osnailyfacter/examples/site.pp /etc/puppet/${OPENSTACK_VERSION}/manifests/site.pp +cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/${OPENSTACK_VERSION}/manifests/ + +# make links for backward compatibility +#pushd /etc/puppet +#ln -s ${OPENSTACK_VERSION}/manifests/ /etc/puppet/manifests +#ln -s ${OPENSTACK_VERSION}/modules/ /etc/puppet/modules +#popd + +cp ${SOURCE}/send2syslog.py /bin/send2syslog.py +mkdir -p /var/lib/hiera +touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml + +# 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/${OPENSTACK_VERSION}/centos/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 + +# Enable MOTD banner in sshd +sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config + +# Add note regarding local repos creation to MOTD +cat >> /etc/motd << EOF + +All environments use online repositories by default. +Use the following commands to create local repositories +on master node and change default repository settings: + +* CentOS: fuel-package-updates (see --help for options) +* Ubuntu: fuel-createmirror (see --help for options) + +Please refer to the following guide for more information: +https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror + +EOF + +# 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" + +# Pause during bootstrap_admin_node to wait for external config +[ -z "$wait_for_external_config" ] && wait_for_external_config="no" + + +# Prepare bootstrap_admin_node config +cat > /etc/fuel/bootstrap_admin_node.conf << EOF +#Set to yes to run Fuel Setup +#Set to no to accept default settings +ADMIN_INTERFACE=${admin_interface} +showmenu=${showmenu} +wait_for_external_config=${wait_for_external_config} +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: +https://:8443 + +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: https://\$ip:8443" + first=no +else + ipstr=\$(printf "%s\n%25s%s" "\$ipstr" " " "https://\$ip:8443") +fi +done +tmpissue=\$(mktemp) +while read -r line; do + if [[ "\$line" =~ "Fuel UI is available on" ]]; then + echo -e "\$ipstr" >> \$tmpissue + elif [[ "\$line" =~ :8443$ ]]; 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 +cp ${SOURCE}/gitinfo.txt / +######### OPNFV addition END ############ + +# Unmounting source +umount -f ${SOURCE} +rm -rf ${SOURCE} + +umount -f ${FS} || true +rm -rf ${FS} + +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/build/f_isoroot/f_kscfg/ks.cfg.orig b/build/f_isoroot/f_kscfg/ks.cfg.orig new file mode 100644 index 000000000..148ef9908 --- /dev/null +++ b/build/f_isoroot/f_kscfg/ks.cfg.orig @@ -0,0 +1,602 @@ +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 !(blkid | grep -q "${drv}.*Fuel"); then + if (grep -q 0 /sys/block/${drv}/removable); then + drives="${drives} ${drv}" + else + removable_drives="${removable_drives} ${drv}" + fi + 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" ]] || [[ "$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 41GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 41984 ]; 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 41GB 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-label/"OpenStack_Fuel"; then + echo "harddrive --partition=LABEL="OpenStack_Fuel" --dir=/" > /tmp/source.ks +elif 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 /boot/efi --onpart=/dev/${bootdev}2" >> /tmp/partition.ks +echo "partition pv.001 --ondisk=${tgtdrive} --size=41000 --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=10000 --percent 30 --grow --name=var --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var/lib/docker --vgname=os --size=17000 --percent 20 --grow --name=varlibdocker --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var/log --vgname=os --size=4096 --percent 50 --grow --name=varlog --fstype=ext4" >> /tmp/partition.ks + + +# bootloader +echo "bootloader --location=partition --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 +fuel +fuel-library >= 7.0 +fuel-dockerctl +authconfig +bind-utils +cronie +crontabs +curl +daemonize +dhcp +docker-io +fuel-bootstrap-image +fuel-bootstrap-image-builder +fuel-createmirror +fuel-target-centos-images6.6 +fuel-package-updates +fuelmenu +fuel-docker-images +gdisk +lrzip +lsof +man +mlocate +nmap-ncat +ntp +ntpdate +openssh-clients +policycoreutils +python-daemon +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 +yum-plugin-priorities + +%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 + +set -x + +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-$admin_interface" + 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=$admin_interface > $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" != "$admin_interface" ]; 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 + [ -n "$build_images" -a "$build_images" != "0" ] && echo -e "$build_images" > /root/.build_images +} + +# 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 +admin_interface=${admin_interface:-"eth0"} +hwaddr=`ifconfig $admin_interface | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` +dhcp_interface=$dhcp_interface +build_images=$build_images +wait_for_external_config=$wait_for_external_config +save_cfg + +# Mounting installation source +SOURCE=/tmp/source +FS=/tmp/fs + +echo +mkdir -p ${SOURCE} +mkdir -p ${FS} + +if test -e /dev/disk/by-label/"OpenStack_Fuel"; then + mount /dev/disk/by-label/"OpenStack_Fuel" ${SOURCE} +elif 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 + +OPENSTACK_VERSION=`cat ${SOURCE}/openstack_version` + +# ---------------------- +# UNPACKING REPOSITORIES +# ---------------------- + +wwwdir="/var/www/nailgun" +repodir="${wwwdir}/${OPENSTACK_VERSION}" + +# Copying Centos files +mkdir -p ${repodir}/centos/x86_64 +cp -r ${SOURCE}/images ${repodir}/centos/x86_64 +cp -r ${SOURCE}/isolinux ${repodir}/centos/x86_64 +cp -r ${SOURCE}/repodata ${repodir}/centos/x86_64 +cp -r ${SOURCE}/Packages ${repodir}/centos/x86_64 +cp ${SOURCE}/.treeinfo ${repodir}/centos/x86_64 + +# Copying Ubuntu files +mkdir -p ${repodir}/ubuntu/x86_64/images +cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/x86_64 +cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/x86_64 + +# We do not ship debian-installer kernel and initrd on ISO. +# But we still need to be able to create ubuntu cobbler distro +# which requires kernel and initrd to be available. So, we +# just touch these files to work around cobbler's limitation. +touch ${repodir}/ubuntu/x86_64/images/linux +touch ${repodir}/ubuntu/x86_64/images/initrd.gz + +# make links for backward compatibility +ln -s ${repodir}/centos ${wwwdir}/centos +ln -s ${repodir}/ubuntu ${wwwdir}/ubuntu + +# -------------------------- +# UNPACKING PUPPET MANIFESTS +# -------------------------- + +# create folders +#mkdir -p /etc/puppet/${OPENSTACK_VERSION}/manifests/ +#mkdir -p /etc/puppet/${OPENSTACK_VERSION}/modules/ +#rm -rf /etc/puppet/modules/ + +# TODO(ikalnitsky): investigate why we need this +#cp ${SOURCE}/puppet-slave.tgz ${wwwdir}/ + +# place modules and manifests +#tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/${OPENSTACK_VERSION}/modules +#cp /etc/puppet/${OPENSTACK_VERSION}/modules/osnailyfacter/examples/site.pp /etc/puppet/${OPENSTACK_VERSION}/manifests/site.pp +cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/${OPENSTACK_VERSION}/manifests/ + +# make links for backward compatibility +#pushd /etc/puppet +#ln -s ${OPENSTACK_VERSION}/manifests/ /etc/puppet/manifests +#ln -s ${OPENSTACK_VERSION}/modules/ /etc/puppet/modules +#popd + +cp ${SOURCE}/send2syslog.py /bin/send2syslog.py +mkdir -p /var/lib/hiera +touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml + +# 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/${OPENSTACK_VERSION}/centos/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 + +# Enable MOTD banner in sshd +sed -i -e "s/^\s*PrintMotd no/PrintMotd yes/g" /etc/ssh/sshd_config + +# Add note regarding local repos creation to MOTD +cat >> /etc/motd << EOF + +All environments use online repositories by default. +Use the following commands to create local repositories +on master node and change default repository settings: + +* CentOS: fuel-package-updates (see --help for options) +* Ubuntu: fuel-createmirror (see --help for options) + +Please refer to the following guide for more information: +https://docs.mirantis.com/openstack/fuel/fuel-7.0/reference-architecture.html#fuel-rep-mirror + +EOF + +# 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" + +# Pause during bootstrap_admin_node to wait for external config +[ -z "$wait_for_external_config" ] && wait_for_external_config="no" + + +# Prepare bootstrap_admin_node config +cat > /etc/fuel/bootstrap_admin_node.conf << EOF +#Set to yes to run Fuel Setup +#Set to no to accept default settings +ADMIN_INTERFACE=${admin_interface} +showmenu=${showmenu} +wait_for_external_config=${wait_for_external_config} +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: +https://:8443 + +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: https://\$ip:8443" + first=no +else + ipstr=\$(printf "%s\n%25s%s" "\$ipstr" " " "https://\$ip:8443") +fi +done +tmpissue=\$(mktemp) +while read -r line; do + if [[ "\$line" =~ "Fuel UI is available on" ]]; then + echo -e "\$ipstr" >> \$tmpissue + elif [[ "\$line" =~ :8443$ ]]; 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} + +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/build/f_isoroot/f_odlpluginbuild/Makefile b/build/f_isoroot/f_odlpluginbuild/Makefile new file mode 100644 index 000000000..a63cdadf8 --- /dev/null +++ b/build/f_isoroot/f_odlpluginbuild/Makefile @@ -0,0 +1,73 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# mskalski@mirantis.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) +ODL_BRANCH=7.0 +ODL_REPO="https://github.com/openstack/fuel-plugin-opendaylight.git" + +.PHONY: all +all: .odlbuild + +.PHONY: clean +clean: + @rm -f .odlbuild ../release/opnfv/opendaylight*.rpm opendaylight*.rpm + @rm -f $(BUILD_BASE)/gitinfo_odlplugin.txt gitinfo_odlplugin.txt + +.PHONY: release +release:.odlbuild + @rm -f ../release/opnfv/opendaylight*.rpm + @mkdir -p ../release/opnfv + @cp opendaylight*.rpm ../release/opnfv/ + cp gitinfo_odlplugin.txt $(BUILD_BASE) + cd $(BUILD_BASE) && mkdir -p ../deploy/templates/plugins && cp -rf $(TOP)/config/* ../deploy/templates/plugins +.odlbuild: + rm -rf fuel-plugin-opendaylight + sudo apt-get -y install build-essential ruby-dev rubygems-integration python-pip git rpm createrepo dpkg-dev + sudo gem install fpm + sudo pip install fuel-plugin-builder + git clone -b $(ODL_BRANCH) $(ODL_REPO) + @$(BUILD_BASE)/check_dependencies.sh fuel-plugin-opendaylight/odl_package/ubuntu/dependencies.txt + INCLUDE_DEPENDENCIES=true fpb --debug --build fuel-plugin-opendaylight/ + mv fuel-plugin-opendaylight/opendaylight*.rpm . + $(REPOINFO) -r . > gitinfo_odlplugin.txt + rm -rf fuel-plugin-opendaylight + touch .odlbuild + +############################################################################# +# Cache operations - only used when building through ci/build.sh +############################################################################# + + +# Create a unique hash to be used for getting and putting cache, based on: +# - The SHA1 hash of the HEAD on the plugin repo's $(ODL_BRANCH) +# - The contents of this Makefile +.cacheid: + git ls-remote --heads $(ODL_REPO) | grep $(ODL_BRANCH) > .cachedata + sha1sum Makefile >> .cachedata + cat .cachedata | $(CACHETOOL) getid > .cacheid + +# Clean local data related to caching - called prior to ordinary build +.PHONY: clean-cache +clean-cache: clean + rm -f .cachedata .cacheid + +# Try to download cache - called prior to ordinary build +.PHONY: get-cache +get-cache: .cacheid + @if $(CACHETOOL) check $(shell cat .cacheid); then \ + $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\ + else \ + echo "No cache item found for $(shell cat .cacheid)" ;\ + exit 0;\ + fi + +# Store cache if not already stored - called after ordinary build +.PHONY: put-cache +put-cache: .cacheid + @tar cf - .odlbuild opendaylight*.rpm gitinfo_odlplugin.txt | $(CACHETOOL) put $(shell cat .cacheid) diff --git a/build/f_isoroot/f_odlpluginbuild/config/opendaylight_config.yaml b/build/f_isoroot/f_odlpluginbuild/config/opendaylight_config.yaml new file mode 100644 index 000000000..183ef9ca9 --- /dev/null +++ b/build/f_isoroot/f_odlpluginbuild/config/opendaylight_config.yaml @@ -0,0 +1,52 @@ +opendaylight: + metadata: + enabled: true + label: OpenDaylight plugin + plugin_id: 1 + restrictions: + - cluster:net_provider != 'neutron': Only neutron is supported by OpenDaylight + toggleable: true + weight: 70 + rest_api_port: + description: Port on which ODL REST API will be available. + label: Port number + regex: + error: Invalid port number + source: ^([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$ + type: text + value: '8282' + weight: 40 + use_vxlan: + description: Configure neutron to use VXLAN tunneling + label: Use vxlan + restrictions: + - action: disable + condition: networking_parameters:segmentation_type == 'vlan' + message: Neutron with GRE segmentation required + type: checkbox + value: true + weight: 20 + vni_range_end: + description: VXLAN VNI IDs range end + label: VNI range end + regex: + error: Invalid ID number + source: ^\d+$ + restrictions: + - action: hide + condition: networking_parameters:segmentation_type == 'vlan' + type: text + value: '10000' + weight: 31 + vni_range_start: + description: VXLAN VNI IDs range start + label: VNI range start + regex: + error: Invalid ID number + source: ^\d+$ + restrictions: + - action: hide + condition: networking_parameters:segmentation_type == 'vlan' + type: text + value: '10' + weight: 30 diff --git a/build/f_isoroot/f_repobuild/Makefile b/build/f_isoroot/f_repobuild/Makefile new file mode 100644 index 000000000..d7db2dd90 --- /dev/null +++ b/build/f_isoroot/f_repobuild/Makefile @@ -0,0 +1,86 @@ +############################################################################## +# 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 +############################################################################## + +SHELL := /bin/bash +TOP := $(shell pwd) +RSYNC_HOST := $(shell ./select_ubuntu_repo.sh) + + +.PHONY: all +all: nailgun + +nailgun: +# If RSYNC_CONNECT_PROG is set we need to do some magic to copy the +# keys. Make sure to have the username set in the SSH_CONNECT_PROG +# as well! + @if [ -n "${RSYNC_CONNECT_PROG}" -a ! -d /root/.ssh ]; then \ + sudo mkdir -p /root/.ssh; \ + test -d ${HOME}/.ssh && sudo find ${HOME}/.ssh -maxdepth 1 -type f -exec cp {} /root/.ssh \; ; \ + sudo bash -c "echo StrictHostKeyChecking=no > /root/.ssh/config"; \ + sudo chmod 700 /root/.ssh; \ + fi + sudo apt-get install -y rsync python python-yaml dpkg-dev openssl + rm -rf tmpiso tmpdir + mkdir tmpiso + fuseiso ${ISOCACHE} tmpiso + cp tmpiso/ubuntu/pool/main/f/fuel-createmirror/fuel-createmirror_*.deb . + fusermount -u tmpiso + rm -rf tmpiso + sudo dpkg -i fuel-createmirror_*.deb + sudo sed -i 's/DOCKER_MODE=true/DOCKER_MODE=false/' /etc/fuel-createmirror/common.cfg + sudo sed -i 's/DEBUG="no"/DEBUG="yes"/' /etc/fuel-createmirror/ubuntu.cfg + sudo sed -i "s/MIRROR_UBUNTU_HOST=\".*\"/MIRROR_UBUNTU_HOST=\"$(RSYNC_HOST)\"/" /etc/fuel-createmirror/common.cfg + rm -Rf nailgun + sudo mkdir -p /var/www + sudo su - -c /opt/fuel-createmirror-*/fuel-createmirror + sudo chmod -R 755 /var/www/nailgun + cp -Rp /var/www/nailgun . + +.PHONY: clean +clean: + @rm -rf ../release/opnfv/nailgun nailgun fuel-createmirror_6.1*.deb + +.PHONY: release +release:nailgun + @rm -Rf ../release/opnfv/nailgun + @mkdir -p ../release/opnfv + @cp -Rp nailgun ../release/opnfv/nailgun + +############################################################################# +# Cache operations - only used when building through ci/build.sh +############################################################################# + +# Create a unique hash to be used for getting and putting cache, based on: +# - Year and week (causing the cache to be rebuilt weekly) +# - The contents of this Makefile +.cacheid: + date +"Repocache %G%V" > .cachedata + sha1sum Makefile >> .cachedata + cat .cachedata | $(CACHETOOL) getid > .cacheid + +# Clean local data related to caching - called prior to ordinary build +.PHONY: clean-cache +clean-cache: clean + rm -f .cachedata .cacheid + +# Try to download cache - called prior to ordinary build +.PHONY: get-cache +get-cache: .cacheid + @if $(CACHETOOL) check $(shell cat .cacheid); then \ + $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\ + else \ + echo "No cache item found for $(shell cat .cacheid)" ;\ + exit 0;\ + fi + +# Store cache if not already stored - called after ordinary build +.PHONY: put-cache +put-cache: .cacheid + @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid) diff --git a/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh b/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh new file mode 100755 index 000000000..cb05fe136 --- /dev/null +++ b/build/f_isoroot/f_repobuild/select_ubuntu_repo.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +RSYNC="rsync -4 --contimeout 5 --no-motd --list-only" + +# try to choose close ubuntu mirror which support rsync protocol +# https://bugs.launchpad.net/fuel/+bug/1459252 + +# A minor modificiation of Michal Skalski's original Makefile version +# to only consider repos where no repo updates are in progress (as +# that may have us hanging quite a while otherwise). If no suitable +# local mirror can be found after four attempts, the default archive +# is returned instead. + +cnt=0 +while [ $cnt -lt 4 ] +do + for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt) + do + host=$(echo $url | cut -d'/' -f3) + if $RSYNC "${host}::ubuntu/." &> /dev/null + then + if ! $RSYNC "${host}::ubuntu/Archive-Update-in-Progress*" &> /dev/null + then + echo "$host" + exit 0 + fi + fi + done + cnt=$[cnt + 1] + sleep 15 +done +echo "archive.ubuntu.com" + |