diff options
Diffstat (limited to 'fuel/build/f_isoroot/f_bootstrap')
-rwxr-xr-x | fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh | 107 | ||||
-rwxr-xr-x | fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig | 108 |
2 files changed, 175 insertions, 40 deletions
diff --git a/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh b/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh index 348ce3c..8bdf566 100755 --- a/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh +++ b/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh @@ -1,4 +1,5 @@ #!/bin/bash +FUEL_RELEASE=$(grep release: /etc/fuel/version.yaml | cut -d: -f2 | tr -d '" ') function countdown() { local i @@ -47,9 +48,6 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then { 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 @@ -57,30 +55,51 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then 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" +service docker start -# extract docker images -mkdir -p $images_dir $sources_dir -rm -f $images_dir/*tar -pushd $images_dir &>/dev/null +if [ -f /root/.build_images ]; then + #Fail on all errors + set -e + trap fail EXIT -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 + echo "Loading Fuel base image for Docker..." + docker load -i /var/www/nailgun/docker/images/fuel-images.tar -# 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 + 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 @@ -102,4 +121,52 @@ 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!" 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 index 7b6e6bd..8d21c1e 100755 --- a/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig +++ b/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig @@ -1,4 +1,5 @@ #!/bin/bash +FUEL_RELEASE=$(grep release: /etc/fuel/version.yaml | cut -d: -f2 | tr -d '" ') function countdown() { local i @@ -37,9 +38,6 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then { 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 @@ -47,30 +45,51 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then 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" +service docker start -# extract docker images -mkdir -p $images_dir $sources_dir -rm -f $images_dir/*tar -pushd $images_dir &>/dev/null +if [ -f /root/.build_images ]; then + #Fail on all errors + set -e + trap fail EXIT -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 + 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" -# 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 + #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 @@ -81,4 +100,53 @@ rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote dockerctl check || fail bash /etc/rc.local + +# 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!" |