From: Andrew Grimberg Date: Fri, 13 Jan 2017 19:34:11 +0000 (-0800) Subject: Remove deprecated vagrant configuration X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=82ca7f8d5346c2d0c89a8ddf7b874a35c357b644;p=ci-management.git Remove deprecated vagrant configuration Remove redundant and unsuported vagrant configuration since packer changes were merged in early December 2016 and all systems have been moved to packer based images. Change-Id: I4859734ea732730e52a173c91b1d13cb77548506 Signed-off-by: Andrew Grimberg --- diff --git a/vagrant/basebuild/README.txt b/vagrant/basebuild/README.txt deleted file mode 100644 index e4fd83a1c..000000000 --- a/vagrant/basebuild/README.txt +++ /dev/null @@ -1,217 +0,0 @@ - -Standard Operating Procedures: - -=== Environmental specifics === - -For the use of this document, the following environment variables -should be assumed set: - - CPPROJECT=fdio - PVENAME=openstack-${CPPROJECT} - - LFID=cjcollier - CP_NAME=FD.io - CP_DOMAIN=fd.io - VAGRANT_DEFAULT_PROVIDER=openstack - RESEAL=1 - RUBY_VER=2.1.5 - LF_GIT=/usr/src/git/lf - PVEPATH=${HOME}/src/python-virtual - PVE_DIR=${PVEPATH}/${PVENAME} - SERVER_NAME=${LFID}-vagrant - - RH_ARCH_32=i686 - RH_ARCH_64=x86_64 - DEB_ARCH_64=amd64 - DEB_ARCH_32=i386 - - STACK_PROVIDER=vexxhost - STACK_PORTAL=secure.${STACK_PROVIDER}.com - STACK_ID_SERVER=auth.${STACK_PROVIDER}.net - STACK_REGION_NAME=ca-ymq-1 - - VAGRANT_DISTRIBUTOR=hashicorp - VDIST_DOMAIN=releases.${VAGRANT_DISTRIBUTOR}.com - # vagrant_${VDIST_VER}_${RH_ARCH_32}.deb - # vagrant_${VDIST_VER}_${RH_ARCH_64}.deb - VDIST_FILENAME=vagrant_${VDIST_VER}_${RH_ARCH}.deb - # Ask the web server what its latest version is - VDIST_VER=$(curl https://${VDIST_DOMAIN}/vagrant|html2text|awk -F_ '/_/ {print $2}'|sort|tail -1) - VDIST_PATH=vagrant/${VDIST_VER}/${VDIST_FILENAME} - VAGRANT_DISTFILE_URL=https://{$VDIST_DOMAIN}/${VDIST_PATH} - - GERRIT_HOSTNAME=gerrit.${CP_DOMAIN} - GERRIT_DIR=${LF_GIT}/${GERRIT_HOSTNAME} - CIADM_NAME=ci-management - CIADM_DIR=${GERRIT_DIR}/${CIADM_NAME} - RH_ARCH=${RH_ARCH_64} - DEB_ARCH=${DEB_ARCH_64} - PVERC=${PVE_DIR}/bin/activate - -=== Establish Cloudstack Credentials === - -To get the correct configuration for the environment you will need -openstack credentials. Those used for this project are managed by -${STACK_PROVIDER}. Establish credentials through appropriate -channels. Once credentials are acquired, visit this page: - -https://${STACK_PORTAL}/console/#/account/credentials - -The environment variables you need will be at the bottom of the page, -formatted as such: - - export OS_TENANT_NAME="00000000-0000-0000-0000-000000000000" - export OS_USERNAME="00000000-0000-0000-0000-000000000000" - export OS_PASSWORD="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - export OS_AUTH_URL="https://${STACK_ID_SERVER}/v2.0/" - export OS_REGION_NAME="${STACK_REGION_NAME}" - -Save these lines to /tmp/openstack-credentials.sh - -=== Establish a python-virtual environment === - -For Debian-based systems, be sure that you install the -virtualenvwrapper packages - - # Debian: sudo apt-get install virtualenvwrapper - mkdir -p ${PVEPATH} - cd ${PVEPATH} - virtualenv ${PVENAME} - cat /tmp/openstack-credentials.sh >> ${PVERC} - source ${PVERC} - pip install --upgrade pip setuptools - pip install python-{cinder,glance,keystone,neutron,nova,openstack}client - -=== Install your public key into the cloudstack environment === - -Via the web interface: https://${STACK_PORTAL}/console/v2.html#/compute/keypairs - -This command will install your yubikey-backed ssh key: - - ssh-add -L | grep cardno | nova keypair-add --pub-key - ${LFID} - -=== Establish the GUID of our network === - -Via the web interface: https://${STACK_PORTAL}/console/#/networking/networks - -Command line: - - export NETID=$(nova network-list | awk "/${CPPROJECT}/ {print \$2}") - grep -v '^NETID=' ${PVERC} | cat - > ${PVERC} - echo "NETID=${NETID}" >> ${PVERC} - -=== Install rbenv === - -==== Red Hat ==== - - sudo yum install -y \ - git-core zlib zlib-devel gcc-c++ patch readline readline-devel \ - libyaml-devel libffi-devel openssl-devel make bzip2 autoconf \ - automake libtool bison curl sqlite-devel - git clone git://github.com/sstephenson/rbenv.git ~/.rbenv - eval $(echo 'export PATH="${HOME}/.rbenv/bin:${PATH}"' | tee -a ~/.bashrc) - eval $(rbenv init -) - time rbenv install ${RUBY_VER} - -==== Debian ==== - - sudo apt-get build-dep ruby - sudo apt-get install rbenv ruby-build libssl-dev libreadline-dev - eval $(rbenv init -) - curl -fsSL https://gist.github.com/mislav/055441129184a1512bb5.txt > /tmp/debian-ssl-patch - time rbenv install --patch ${RUBY_VER} < /tmp/debian-ssl-patch # 7m42.708s - -==== Common ==== - - rbenv local ${RUBY_VER} - rbenv global ${RUBY_VER} - grep 'rbenv init' ~/.bashrc || \ - echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ - echo "rbenv local ${RUBY_VER}" >> ~/.bashrc && \ - echo "rbenv global ${RUBY_VER}" >> ~/.bashrc - -=== Install Vagrant, vagrant-openstack-provider === - -On Debian, you must uninstall the system vagrant and instead install -the upstream package: - - wget -O ${VAGRANT_DISTFILE_NAME} ${VAGRANT_DISTFILE_URL} - sudo dpkg -i ${VAGRANT_DISTFILE_NAME} - vagrant plugin install vagrant-openstack-provider - -=== Configure openstack 'dummy' box === - -CLI: - vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box - cp ${CIADM_DIR}/vagrant/examples/box/dummy/Vagrantfile ~/.vagrant.d/boxes/dummy/0/openstack/ - -=== Check out the ci-management repo from gerrit === - -CLI: - - mkdir -p ${GERRIT_DIR} - cd ${GERRIT_DIR} - git clone ssh://${GERRIT_HOSTNAME}:29418/${CIADM_NAME} - -=== Acquire base images === - -Cloud image links by platform: - -CentOS: http://cloud.centos.org/centos/ -Ubuntu: https://cloud-images.ubuntu.com/ -Debian: http://cdimage.debian.org/cdimage/openstack/ -Arch: http://linuximages.de/openstack/arch/ -Gentoo: http://linuximages.de/openstack/gentoo/ - -CLI: - - source ${CIADM_DIR}/vagrant/lib/respin-functions.sh - - download_deb_image 'Ubuntu' '14.04' 'amd64' - download_deb_image 'Ubuntu' '16.04' 'amd64' - download_deb_image 'Debian' 'stable' 'amd64' - download_deb_image 'Debian' 'testing' 'amd64' - download_deb_image 'Debian' 'unstable' 'amd64' - download_rh_image 'CentOS' '7' 'x86_64' - -=== Upload base images === - -CLI: - - source ${CIADM_DIR}/vagrant/lib/respin-functions.sh - - create_deb_image 'Ubuntu' '14.04' 'amd64' - create_deb_image 'Ubuntu' '16.04' 'amd64' - create_rh_image 'CentOS' '7' 'x86_64' - - -== Re-spin jcloud images == - -CLI: - - source ${PVERC} - - # Respin images - respin_deb_image 'Ubuntu' '14.04' 'amd64' - respin_deb_image 'Ubuntu' '16.04' 'amd64' - respin_rh_image 'CentOS' '7' 'x86_64' - -=== Manual bootstrap of Ubuntu 14.04 === - -CLI: - source ${CIADM_DIR}/vagrant/lib/respin-functions.sh - SRC_TIMESTAMP=$(latest_src_timestamp) - - DIST='Ubuntu' - VERSION='14.04' - IMAGE="${DIST} ${VERSION} (${SRC_TIMESTAMP}) - LF upload" - RESEAL=1 - - cd ${CIADM_DIR}/vagrant/basebuild - vagrant up - -On manual bootstrap failure, one can connect to the VM using - vagrant ssh - -On success - nova image-create --poll ${SERVER_NAME} "qq{$dist $version - basebuild - $isodate};" diff --git a/vagrant/basebuild/Vagrantfile b/vagrant/basebuild/Vagrantfile deleted file mode 100644 index 3aab38250..000000000 --- a/vagrant/basebuild/Vagrantfile +++ /dev/null @@ -1,57 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ts=2 sw=2 sts=2 et ft=ruby : - -Vagrant.configure(2) do |config| - config.vm.provider :openstack do |os, override| - config.vm.box = "dummy" - - # require an IMAGE to be passed in - # IMAGE must be a human name and not image ID! - if ENV['IMAGE'] - os.image = ENV['IMAGE'] - else - os.image = 'BAD IMAGE' - override.ssh.username = 'baduser' - end - - if ENV['SERVER_NAME'] - os.server_name = ENV['SERVER_NAME'] - end - - case ENV['IMAGE'] - when /.*ubuntu.*/i - override.ssh.username = 'ubuntu' - - when /.*fedora.*/i - override.ssh.username = 'fedora' - - # take care of the tty requirement by fedora for sudo - os.user_data = "#!/bin/bash -/bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;" - - when /.*centos.*/i - override.ssh.username = 'centos' - - # take care of the tty requirement by centos for sudo - os.user_data = "#!/bin/bash -/bin/sed -i 's/ requiretty/ !requiretty/' /etc/sudoers;" - end - end - - config.vm.synced_folder ".", "/vagrant" - config.vm.synced_folder "../lib/", "/vagrant/lib" - - # Do a full system update and set enforcing on - config.vm.provision 'shell', path: './bootstrap.sh' - - ################# - # FINAL CLEANUP # - ################# - - # set RESEAL to... anything if you want to snap an image of this box - # not setting the environment variable will cause the system to come - # up fully and not be in a resealable state - if ENV['RESEAL'] - config.vm.provision 'shell', path: '../lib/system_reseal.sh' - end -end diff --git a/vagrant/basebuild/bootstrap.sh b/vagrant/basebuild/bootstrap.sh deleted file mode 100644 index 87eb3860a..000000000 --- a/vagrant/basebuild/bootstrap.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -# die on errors -set -e - -# pull in bootstrap functions -. /vagrant/lib/bootstrap-functions.sh - -do_setup -do_mvn_install - -# record the bootstrap.sh checksum -sha1sum $0 > /etc/bootstrap.sha -sha1sum /vagrant/lib/bootstrap-functions.sh > /etc/bootstrap-functions.sha - -echo "---> Attempting to detect OS" -# OS selector -if [ -f /usr/bin/yum ] -then - echo "---> RH type system detected" - rh_clean_pkgs - rh_update_pkgs - rh_install_pkgs - -elif [ -f /usr/bin/apt-get ] -then - echo "---> Debian type system detected" - export DEBIAN_FRONTEND=noninteractive - - deb_aptconf_batchconf - deb_sync_minor - deb_correct_shell - deb_install_pkgs - deb_remove_pkgs - deb_disable_apt_systemd_daily - deb_flush - deb_reup_certs - - # It is not necessary to load uio module during bootstrap phase - # deb_probe_modules uio_pci_generic - - # Make sure uio loads at boot time - deb_enable_modules 'uio_pci_generic' - - deb_enable_hugepages - - # It is not necessary to mount hugepages during bootstrap phase - # deb_mount_hugepages - -fi - -do_cleanup - -echo "bootstrap process (PID=$$) complete." - -exit 0 diff --git a/vagrant/examples/box/dummy/Vagrantfile b/vagrant/examples/box/dummy/Vagrantfile deleted file mode 100644 index fc53530c5..000000000 --- a/vagrant/examples/box/dummy/Vagrantfile +++ /dev/null @@ -1,39 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby ts=2 sw=2 sts=2 et : - -# See ci-management/vagrant/lib/respin-functions.sh for examples of -# environment variable settings - -require 'vagrant-openstack-provider' - -Vagrant.configure("2") do |config| - - config.vm.provider :openstack do |os, override| - - # CPPROJECT=fdio - # STACK_PROVIDER=vexxhost - # STACK_PORTAL=secure.${STACK_PROVIDER}.com - # STACK_ID_SERVER=auth.${STACK_PROVIDER}.net - - # OPENSTACK_AUTH_URL="https://${STACK_ID_SERVER}/v2.0/" - # OPENSTACK_FLAVOR='v1-standard-4' - # STACK_REGION_NAME='ca-ymq-1' - # AVAILABILITY_ZONE='ca-ymq-2' - - os.openstack_auth_url = ENV['OPENSTACK_AUTH_URL'] - os.flavor = ENV['OPENSTACK_FLAVOR'] - os.region = ENV['STACK_REGION_NAME'] - os.availability_zone = ENV['AVAILABILITY_ZONE'] - - # https://${STACK_PORTAL}/console/#/account/credentials - os.tenant_name = ENV['OS_TENANT_NAME'] - os.username = ENV['OS_USERNAME'] - os.password = ENV['OS_PASSWORD'] - - # NETID=$(nova network-list | awk '/${CPPROJECT}/ {print $2}') - os.networks = ENV['NETID'] - - # personal default instance names: for example, ${USER}-vagrant - os.server_name = ENV['SERVER_NAME'] - end -end diff --git a/vagrant/lib/Respin.pm b/vagrant/lib/Respin.pm deleted file mode 100644 index 2db8181b5..000000000 --- a/vagrant/lib/Respin.pm +++ /dev/null @@ -1,32 +0,0 @@ -package Respin; - -use strict; -use warnings; -use DateTime; -use DateTime::Format::Duration; -use DateTime::Duration; -use JSON::XS; - -my $iso8601_rx = qr{^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$}; - -my $json = JSON::XS->new->utf8; - -my $dur_fmt = DateTime::Format::Duration->new( - normalize => 1, - pattern => - q{{"week":"%V","day":"%u","hour":"%k","minute":"%M","second":"%S"}} -); - -sub latest_src_age { - my ( $now, $src ) = @_; - - print STDERR "Computing duration between [$src] and [$now]\n"; - - my ( %now, %src ); - @now{qw(year month day hour minute second)} = ( $now =~ $iso8601_rx ); - @src{qw(year month day hour minute second)} = ( $src =~ $iso8601_rx ); - - print $dur_fmt->format_duration_from_deltas( - DateTime->new(%now)->subtract_datetime_absolute( DateTime->new(%src) ) - ->deltas ); -} diff --git a/vagrant/lib/bootstrap-functions.sh b/vagrant/lib/bootstrap-functions.sh deleted file mode 100644 index 2f1490cdd..000000000 --- a/vagrant/lib/bootstrap-functions.sh +++ /dev/null @@ -1,247 +0,0 @@ -#!/bin/bash - -do_setup() { - echo "127.0.1.1 $(hostname) # temporary" >> /etc/hosts - - # Dead peer detection - echo "TCPKeepAlive true" >> /etc/ssh/ssh_config - echo "ServerAliveCountMax 30" >> /etc/ssh/ssh_config - echo "ServerAliveInterval 10" >> /etc/ssh/ssh_config -} - -do_mvn_install() { - MAVEN_VERSION=3.3.9 - MAVEN_FILENAME=apache-maven-${MAVEN_VERSION}-bin.tar.gz - MAVEN_HOME=/opt/apache/maven - - mkdir -p ${MAVEN_HOME} - tar -C ${MAVEN_HOME} --strip-components 1 -xzf /vagrant/${MAVEN_FILENAME} -} - - -do_cleanup() { - perl -i -ne 'print unless /^127.0.1.1.*# temporary$/' /etc/hosts -} - -deb_probe_modules() { - for mod in "$@" - do - modprobe ${mod} - done -} - -deb_enable_modules() { - for mod in "$@" - do - echo ${mod} >> /etc/modules - done -} - -deb_aptconf_batchconf() { - cat <> /etc/apt/apt.conf -APT { - Get { - Assume-Yes "true"; - allow-change-held-packages "true"; - allow-downgrades "true"; - allow-remove-essential "true"; - }; -}; - -Dpkg::Options { - "--force-confdef"; - "--force-confold"; -}; - -quiet "2"; - -EOF -} - -deb_sync_minor() { - echo '---> Updating OS' - # Standard update + upgrade dance - apt-get update - apt-get upgrade - apt-get dist-upgrade -} - -deb_correct_shell() { - echo '---> Correcting system shell' - # Fix the silly notion that /bin/sh should point to dash by pointing it to bash - update-alternatives --install /bin/sh sh /bin/bash 100 -} - -deb_flush() { - echo '---> Flushing extra packages and package cache' - apt-get autoremove - apt-get clean -} - -deb_add_ppa() { - echo "---> Adding '$1' PPA" - apt-get install software-properties-common - ATTEMPT=0 - while [ ${ATTEMPT} -le 4 ] - do - FAIL=0 - apt-add-repository -y $1 || FAIL=1 - if [ ${FAIL} -eq 0 ] - then - break - fi - ATTEMPT=$(expr $ATTEMPT + 1) - done - apt-get update -} - -deb_install_pkgs() { - apt-get install lsb-release - LSB_PATH=$(which lsb_release) - - VERSION=$(lsb_release -r | awk '{print $2}') - DIST=$(lsb_release -i | awk '{print $3}') - CODENAME=$(lsb_release -c | awk '{print $2}') - - echo "---> Detected [${DIST} v${VERSION} (${CODENAME})]" - - # initialize PACKAGES - PACKAGES="cloud-initramfs-dyn-netconf cloud-initramfs-growroot - cloud-initramfs-rescuevol" - - if [ "$VERSION" = '14.04' ] - then - # openjdk-8-jdk is not available in 14.04 repos by default - deb_add_ppa ppa:openjdk-r/ppa - - # Install OpenJDK v8 *and* v7 on Trusty - PACKAGES="$PACKAGES openjdk-8-jdk-headless openjdk-7-jdk emacs24-nox" - elif [ "$VERSION" = '16.04' ] - then - # Install default jdk (v8 on this platform) - PACKAGES="$PACKAGES default-jdk-headless emacs-nox" - - # plymouth-label and plymouth-themes are required to get rid of - # initrd warnings / errors on 16.04 - apt-get install plymouth-themes plymouth-label - fi - - # Build tools - should match vpp/Makefile DEB_DEPENDS variable - PACKAGES="$PACKAGES curl build-essential autoconf automake bison libssl-dev - ccache debhelper dkms git libtool libganglia1-dev libapr1-dev - dh-systemd libconfuse-dev git-review exuberant-ctags cscope indent" - - # Interface manipulation tools, editors, debugger and lsb - PACKAGES="$PACKAGES iproute2 ethtool vlan bridge-utils - vim gdb lsb-release" - - # Install latest kernel and uio - PACKAGES="$PACKAGES linux-image-extra-virtual linux-headers-virtual" - - # $$$ comment out for the moment - # PACKAGES="$PACKAGES maven3" - - # Install virtualenv for test execution - PACKAGES="$PACKAGES python-virtualenv python-pip python-dev" - - # Install to allow the vpp-docs job to zip up docs to push them - PACKAGES="$PACKAGES zip" - - # Install for deb_dpdk debian package buiding - PACKAGES="$PACKAGES dpkg-dev dh-python inkscape libcap-dev libpcap-dev" - PACKAGES="$PACKAGES libxen-dev libxenstore3.0 python-sphinx python-sphinx-rtd-theme" - PACKAGES="$PACKAGES texlive-fonts-recommended texlive-latex-extra" - - echo '---> Installing packages' - # disable double quoting check - # shellcheck disable=SC2086 - apt-get install ${PACKAGES} - - # Specify documentation packages - DOC_PACKAGES="doxygen graphviz python-pyparsing python-jinja2" - apt-get install ${DOC_PACKAGES} -} - -deb_enable_hugepages() { - # Setup for hugepages using sysctl so it persists across reboots - AVP="vm.nr_hugepages=1024" - sysctl -w ${AVP} - echo "${AVP}" >> /etc/sysctl.conf - - mkdir -p /mnt/huge - echo "hugetlbfs /mnt/huge hugetlbfs defaults 0 0" >> /etc/fstab -} - -deb_mount_hugepages() { - mount /mnt/huge -} - -deb_reup_certs() { - # update CA certificates - echo '---> Forcing CA certificate update' - update-ca-certificates -f -} - -deb_remove_pkgs() { - echo '---> Removing unattended-upgrades packge to avoid it locking /var/lib/dpkg/lock' - apt-get remove unattended-upgrades -} - -deb_disable_apt_systemd_daily() { - echo '---> Stopping and disabling apt.systemd.daily to avoid it locking /var/lib/dpkg/lock' - if [ -f /usr/bin/systemctl ] - then - systemctl stop apt.systemd.daily - systemctl disable apt.systemd.daily - else - /etc/init.d/unattended-upgrades stop - update-rc.d -f unattended-upgrades remove - fi -} - -rh_clean_pkgs() { - echo '---> Cleaning caches' - yum clean all -q -} - -rh_update_pkgs() { - echo '---> Updating OS' - yum upgrade -q -y -} - -rh_install_pkgs() { - echo '---> Installing tools' - - # Install build tools - yum install -q -y @development redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils \ - openssl-devel apr-devel indent - - # Specify documentation packages - DOC_PACKAGES="doxygen graphviz pyparsing python-jinja2" - yum install -q -y install ${DOC_PACKAGES} - - # Install python development - OUTPUT=$(yum search python34-devel 2>&1 | grep 'No matches') - if [ -z "$OUTPUT" ] - then - echo '---> Installing python34-devel' - yum install -q -y python34-devel - else - echo '---> Installing python-devel' - yum install -q -y python-devel - fi - - echo '---> Configuring EPEL' - # Install EPEL - OUTPUT=$(rpm -qa epel-release) - if [ -z "$OUTPUT" ] - then - yum install -q -y /vagrant/epel-release-latest-7.noarch.rpm - fi - - # Install components to build Ganglia modules - yum install -q -y --enablerepo=epel {libconfuse,ganglia}-devel mock - - # Install debuginfo packages - debuginfo-install -q -y glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64 -} diff --git a/vagrant/lib/respin-functions.sh b/vagrant/lib/respin-functions.sh deleted file mode 100644 index 0c92f8ee1..000000000 --- a/vagrant/lib/respin-functions.sh +++ /dev/null @@ -1,294 +0,0 @@ -#!/bin/bash - -# Copyright 2016 The Linux Foundation - -source ${CI_MGMT}/vagrant/lib/vagrant-functions.sh - - -source ${PVERC} - -pip install -q --upgrade pip setuptools python-{cinder,glance,keystone,neutron,nova,openstack}client - -# -# usage: -# AGE_JSON=$(latest_src_age ${DIST} ${VERSION} ${ARCH}) -# -function latest_src_age () -{ - SRC_TS=$(latest_src_timestamp "$@") - NOW_TS=$(new_timestamp) - - perl -I${CI_MGMT}/vagrant/lib -MRespin -e 'Respin::latest_src_age( @ARGV )' "${NOW_TS}" "${SRC_TS}" - - return 0 -} - -function new_timestamp () -{ - date +'%F T %T' | sed -e 's/[-: ]//g' -} - -function new_dst_timestamp () -{ - if [ -z "${DST_TIMESTAMP}" ] - then - DST_TIMESTAMP=$(new_timestamp) - fi - - echo ${DST_TIMESTAMP} - return 0 -} - -function new_src_timestamp () -{ - if [ -z "${SRC_TIMESTAMP}" ] - then - SRC_TIMESTAMP=$(date +'%F T %T' | sed -e 's/[-: ]//g') - fi - - echo ${SRC_TIMESTAMP} - return 0 -} - -function latest_src_timestamp () -{ - if [ -z "${SRC_TIMESTAMP}" ] - then - SRC_TIMESTAMP=$(glance image-list | perl -n -e 'if( /\((\S+)\) - LF upload/ ){ print "$1\n" }' | sort | tail -1) - fi - - echo ${SRC_TIMESTAMP} - return 0 -} - -# -# usage: -# glance_image_create ${IMG_NAME} ${IMG_PATH} -# -# example: -# glance_image_create "CentOS 7 (20160517T143002) - LF upload" /var/lib/libvirt/images/CentOS-7-x86_64-GenericCloud.qcow2c -# -function glance_image_create () -{ - glance image-create --disk-format qcow2 --container-format bare --progress \ - --name "${1}" --file "${2}" -} - -function setup_rh () -{ - SRC_TIMESTAMP=$(new_src_timestamp) - DIST=$1 - VERSION=$2 - ARCH=$3 - ARCH=${ARCH:-${RH_ARCH64}} - IMG_FNAME="${DIST}-${VERSION}-${ARCH}-GenericCloud.qcow2c" - IMG_PATH="${LV_IMG_DIR}/${IMG_FNAME}" - IMG_NAME="${DIST} ${VERSION} (${SRC_TIMESTAMP}) - LF upload" -} - -# -# usage: -# create_rh_image ${DIST} ${VERSION} ${ARCH} -# -# example: -# create_rh_image CentOS 7 x86_64 -# -function create_rh_image () -{ - setup_rh "$@" - - if [ ! -f ${IMG_PATH} ]; then download_rh_image "$@"; fi - - glance_image_create "${IMG_NAME}" "${IMG_PATH}" -} - -function download_rh_image () -{ - setup_rh "$@" - echo "--> Fetching image file for ${DIST} ${VERSION}" - wget -qcP ${LV_IMG_DIR} "http://cloud.centos.org/centos/${VERSION}/images/${IMG_FNAME}" -} - - -declare -A deb_codename_map -deb_codename_map=(['3.0']=woody \ - ['3.1']=sarge \ - ['4']=etch \ - ['5']=lenny \ - ['6']=squeeze \ - ['7']=wheezy \ - ['8']=jessie \ - ['9']=stretch \ - ['10']=buster \ - ) -declare -A ubuntu_codename_map -ubuntu_codename_map=(['6.06']=dapper \ - ['8.04']=hardy \ - ['10.04']=lucid \ - ['12.04']=precise \ - ['14.04']=trusty \ - ['16.04']=xenial \ - ) -DEB_CURRENT_VER='8.4.0' -DEB_CURRENT_CODENAME='jessie' - -DEB_TESTING_VER='9.0.0' -DEB_TESTING_CODENAME='stretch' - -DEB_UNSTABLE_VER='10.0.0' -DEB_UNSTABLE_CODENAME='buster' - -function setup_deb () -{ - SRC_TIMESTAMP=$(new_src_timestamp) - DIST=$1 - VERSION=$2 - ARCH=$3 - ARCH=${ARCH:-${DEB_ARCH64}} - - declare -A V - VVAL=$(echo ${VERSION} | perl -ne 'm/(?:(\d+)(?:\.(\d+))?)(?:\.(\d+))?/; $min=$2 // 0; $mic = $3 // 0; print qq{([maj]=$1 [min]=$min [mic]=$mic)}') - eval "V=${VVAL}" - - LCDIST=$(echo ${DIST} | perl -ne 'print lc') - - MAJOR_VERSION="${V['maj']}" - MINOR_VERSION="${MAJOR_VERSION}.${V['min']}" - MICRO_VERSION="${MINOR_VERSION}.${V['mic']}" - - CODENAME="" - - if [ "Debian" == "${DIST}" ] - then - CODENAME="${deb_codename_map[$MINOR_VERSION]}" - CODENAME=${CODENAME:-${deb_codename_map[$MAJOR_VERSION]}} - if [ -z "$CODENAME" ] - then - echo "--> no codename for ${DIST} v${MICRO_VERSION}" - return -2 - fi - - URL_PFX="http://cdimage.debian.org/cdimage/openstack/" - - if [ "${DEB_CURRENT_CODENAME}" == "${CODENAME}" ] - then - OSTACK_SUBDIR='current' - QCOW_VER=${MICRO_VERSION} - elif [ "${DEB_TESTING_CODENAME}" == "${CODENAME}" ] - then - OSTACK_SUBDIR='testing' - QCOW_VER='testing' - else - echo "--> Not certain where to find images for ${DIST} v${MICRO_VERSION}" - fi - - IMG_FNAME="${LCDIST}-${QCOW_VER}-openstack-${ARCH}.qcow2" - URL="http://cdimage.debian.org/cdimage/openstack/${OSTACK_SUBDIR}/${IMG_FNAME}" - - elif [ "Ubuntu" == "${DIST}" ] - then - CODENAME="${ubuntu_codename_map[$MINOR_VERSION]}" - if [ -z "$CODENAME" ] - then - echo "--> no codename for ${DIST} v${MICRO_VERSION}" - return -2 - fi - - IMG_FNAME="${CODENAME}-server-cloudimg-${ARCH}-disk1.img" - URL="https://cloud-images.ubuntu.com/${CODENAME}/current/${IMG_FNAME}" - else - echo "--> unrecognized distribution: ${DIST}" - return -1 - fi - - export IMG_PATH="${LV_IMG_DIR}/${IMG_FNAME}" - export IMG_NAME="${DIST} ${VERSION} (${SRC_TIMESTAMP}) - LF upload" - -} -# -# usage: -# download_deb_image ${DIST} ${VERSION} ${ARCH} -# -# example: -# download_deb_image Ubuntu 14.04 amd64 -# -function download_deb_image () -{ - setup_deb "$@" - - if [ -z "$URL" ]; then echo "Cannot fetch qcow2 image for ${DIST} v${MICRO_VERSION}"; return -3; fi - echo "--> Fetching image file for ${DIST} ${VERSION}" - wget -qcP ${LV_IMG_DIR} "${URL}" -} - -# Used to upload -# -# usage: -# create_deb_image ${DIST} ${VERSION} ${ARCH} -# -# example: -# create_deb_image Ubuntu 14.04 amd64 -# -function create_deb_image () -{ - setup_deb "$@" - - if [ ! -f ${IMG_PATH} ]; then download_deb_image "$@"; fi - - echo "--> Pushing image ${IMG_NAME}" - glance_image_create "${IMG_NAME}" "${IMG_PATH}" -} - -function respin_deb_image () -{ - SRC_TIMESTAMP=$(latest_src_timestamp) - DST_TIMESTAMP=$(new_dst_timestamp) - setup_deb "$@" - export IMAGE="${IMG_NAME}" - echo "--> creating instance of image '${IMG_NAME}' as server name '${SERVER_NAME}'" - vagrant up --provider=openstack - if [ "Ubuntu" == "${DIST}" ] - then - DST_IMAGE="${DIST} ${VERSION} LTS - basebuild - ${DST_TIMESTAMP}" - elif [ "Debian" == "${DIST}" ] - then - DST_IMAGE="${DIST} ${VERSION} - basebuild - ${DST_TIMESTAMP}" - else - echo "unrecognized disribution: ${DIST}" - exit -4 - fi - echo "--> Taking snapshot of image '${IMG_NAME}' with name '${DST_IMAGE}'" - nova image-create --poll "${SERVER_NAME}" "${DST_IMAGE}" - echo "--> Bringing down vagrant instance" - vagrant destroy -} - -function respin_rh_image () -{ - SRC_TIMESTAMP=$(latest_src_timestamp) - DST_TIMESTAMP=$(new_dst_timestamp) - setup_rh "$@" - export IMAGE="${IMG_NAME}" - echo "--> creating instance of image '${IMG_NAME}' as server name '${SERVER_NAME}'" - vagrant up --provider=openstack - DST_IMAGE="${DIST} ${VERSION} - basebuild - ${DST_TIMESTAMP}" - echo "--> Taking snapshot of image '${IMG_NAME}' with name '${DST_IMAGE}'" - nova image-create --poll "${SERVER_NAME}" "${DST_IMAGE}" - echo "--> Bringing down vagrant instance" - vagrant destroy -} - -function dist_type () -{ - case "${1}" in - CentOS | RHEL | SuSE) - echo "rh" ;; - Debian | Ubuntu | Kali | ProxMox | VyOS) - echo "deb" ;; - *) - echo "Unrecognized distribution: ${1}" - exit 2 ;; - esac - -} - diff --git a/vagrant/lib/system_reseal.sh b/vagrant/lib/system_reseal.sh deleted file mode 100644 index 02d008498..000000000 --- a/vagrant/lib/system_reseal.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# vim: sw=2 ts=2 sts=2 et : - -if [ -f /.autorelabel ]; then - echo "**********************************************" - echo "* SYSTEM REQUIRES RELABELING SKIPPING RESEAL *" - echo "* PLEASE RESTART SYSTEM AND RERUN *" - echo "* PROVISIONING SCRIPTS *" - echo "**********************************************" - exit 1; -fi - -rm -rf /etc/Pegasus/*.cnf /etc/Pegasus/*.crt /etc/Pegasus/*.csr \ - /etc/Pegasus/*.pem /etc/Pegasus/*.srl \ - /root/anaconda-ks.cfg /root/anaconda-post.log \ - /root/initial-setup-ks.cfg /root/install.log \ - /root/install.log.syslog /var/cache/fontconfig/* \ - /var/cache/gdm/* /var/cache/man/* \ - /var/lib/AccountService/users/* /var/lib/fprint/* \ - /var/lib/logrotate.status /var/log/*.log* /var/log/BackupPC/LOG \ - /var/log/ConsoleKit/* /var/log/anaconda.syslog \ - /var/log/anaconda/* /var/log/apache2/*_log \ - /var/log/apache2/*_log-* /var/log/apt/* /var/log/aptitude* \ - /var/log/audit/* /var/log/btmp* /var/log/ceph/*.log \ - /var/log/chrony/*.log /var/log/cron* /var/log/cups/*_log \ - /var/log/debug* /var/log/dmesg* /var/log/exim4/* \ - /var/log/faillog* /var/log/gdm/* \ - /var/log/glusterfs/*glusterd.vol.log \ - /var/log/glusterfs/glusterfs.log /var/log/httpd/*log \ - /var/log/installer/* /var/log/jetty/jetty-console.log \ - /var/log/journal/* /var/log/lastlog* \ - /var/log/libvirt/libvirtd.log /var/log/libvirt/lxc/*.log \ - /var/log/libvirt/qemu/*.log /var/log/libvirt/uml/*.log \ - /var/log/lightdm/* /var/log/mail/* /var/log/maillog* \ - /var/log/messages* /var/log/ntp /var/log/ntpstats/* \ - /var/log/ppp/connect-errors /var/log/rhsm/* /var/log/sa/* \ - /var/log/secure* /var/log/setroubleshoot/*.log \ - /var/log/spooler* /var/log/squid/*.log /var/log/syslog* \ - /var/log/tallylog* /var/log/tuned/tuned.log /var/log/wtmp* \ - /var/named/data/named.run - -rm -rf ~/.viminfo /etc/ssh/ssh*key* ~/.ssh/* /root/.ssh/* - -# kill any cloud-init related bits -rm -rf /var/lib/cloud/* - -# cleanup /vagrant -rm -rf /vagrant - -if [ -f /etc/debian_version ] -then - echo "********************************************" - echo "* NOW INSTALLING cloud-init PACKAGE *" - echo "********************************************" - - apt-get -y -qq install cloud-init > /dev/null 2>&1 -fi - -# Force a system sync and sleep to get around any SSD issues -echo "Forcing sync and sleep for 10sec" -sync -sleep 10 - -echo "********************************************" -echo "* PLEASE SNAPSHOT IMAGE AT THIS TIME *" -echo "********************************************"