From 0d4a1f4143d71fc616f456a3708d5c8c2a24ec3f Mon Sep 17 00:00:00 2001 From: Jonas Bjurel Date: Fri, 2 Oct 2015 13:29:56 +0200 Subject: Move of genesis/fuel master branch: commit 563547b4a9f44090f32c0e17d040114854563760 Note: other installers and /common are removed Change-Id: Ie5a2b0b7f3e7fa2eda191710c98456eeec17ed61 Signed-off-by: Jonas Bjurel --- .../f_isoroot/f_bootstrap/bootstrap_admin_node.sh | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100755 fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh (limited to 'fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh') 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 000000000..8bdf5667c --- /dev/null +++ b/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh @@ -0,0 +1,172 @@ +#!/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%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 -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi + + +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +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 + +### 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/centos-6/mos${FUEL_RELEASE}/updates/ +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/centos-6/mos${FUEL_RELEASE}/security/ +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 + warning="WARNING: There are issues connecting to Fuel update repository.\ +\nPlease fix your connection and update this node with \`yum update\`\ +\nThen run \`dockerctl destroy all; bootstrap_admin_node.sh;\`\ +\nto repeat bootstrap on Fuel Master with the latest updates.\ +\nFor more information, check out Fuel documentation at:\ +\nhttp://docs.mirantis.com/fuel" +else + warning="WARNING: There may be updates available for Fuel.\ +\nYou should update this node with \`yum update\`. If there are available\ +\n updates, run \`dockerctl destroy all; bootstrap_admin_node.sh;\`\ +\nto repeat bootstrap on Fuel Master with the latest updates.\ +\nFor more information, check out Fuel documentation at:\ +\nhttp://docs.mirantis.com/fuel" +fi +echo +echo "*************************************************" +echo -e "$warning" +echo "*************************************************" +echo "Sending notification to Fuel UI..." +fuel notify --topic warning --send "$warning" +echo "Fuel node deployment complete!" -- cgit 1.2.3-korg