diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst new file mode 100644 index 0000000000..eadae3bbd8 --- /dev/null +++ b/diskimage-create/README.rst @@ -0,0 +1,205 @@ +Diskimage-builder script for creating Octavia Amphora images +============================================================ + +Octavia is an operator-grade reference implementation for Load Balancing as a +Service (LBaaS) for OpenStack. The component of Octavia that does the load +balancing is known as amphora. Amphora may be a virtual machine, may be a +container, or may run on bare metal. Creating images for bare metal amphora +installs is outside the scope of this version but may be added in a +future release. + +Prerequisites +============= + +This script assumes a typical Linux environment and was developed on +Ubuntu 12.04.5 LTS. + +Python pip should be installed as well as the following python modules: + + | argparse + | Babel>=1.3 + | dib-utils + | PyYAML + +Your cache directory should have at least 1GB available, the working directory +will need ~1.5GB, and your image destination will need ~500MB + +The script expects to find the diskimage-builder and tripleo-image-elements +git repositories one directory above the Octavia git repository. + + | //octavia + | //diskimage-builder + | //tripleo-image-elements + + | cd / + | git clone https://github.com/stackforge/octavia.git + | git clone https://git.openstack.org/openstack/diskimage-builder.git + | git clone https://git.openstack.org/openstack/tripleo-image-elements.git + +These paths can be overriden with the following environment variables: + + | OCTAVIA_REPO_PATH = //octavia + | DIB_REPO_PATH = //diskimage-builder + | DIB_ELEMENTS = //diskimage-builder/elements + | ELEMENTS_REPO_PATH = //tripleo-image-elements + | TRIPLEO_ELEMENTS_PATH = //tripleo-image-elements/elements + +The following packages are required on each platform: +Ubuntu and Fedora: qemu kpartx git +CentOS and RedHat Enterprise Linux: qemu-kvm qemu-img kpartx git +CentOS requires the EPEL repo and python-argparse: + +.. code:: bash + + $ sudo rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm + $ yum install python-argparse + +Test Prerequisites +------------------ +The tox image tests require libguestfs-tools 1.24 or newer. +Libguestfs allows testing the Amphora image without requiring root privledges. +On Ubuntu systems you also need to give read access to the kernels for the user +running the tests: + +.. code:: bash + + $ sudo chmod 0644 /boot/vmlinuz* + +Tests were run on Ubuntu 14.04.1 LTS during development. + +Usage +===== +This script and associated elements will build Amphora images. Current support +is with an Ubuntu base OS and HAProxy. The script can use Fedora +or CentOS as a base OS but these will not initially be tested or supported. +As the project progresses and/or the diskimage-builder project adds support +for additional base OS options they may become available for Amphora images. +This does not mean that they are necessarily supported or tested. + +The script will use environment variables to customize the build beyond the +Octavia project defaults, such as adding elements. + +The supported and tested image is created by using the diskimage-create.sh +defaults (no command line parameters or environment variables set). As the +project progresses we may add additional supported configurations. + +Command syntax: + + +.. line-block:: + + $ diskimage-create.sh + [-a i386 | **amd64** | armhf ] + [-b **haproxy** ] + [-c **~/.cache/image-create** | ] + [-h] + [-i **ubuntu** | fedora | centos ] + [-o **amphora-x64-haproxy** | ] + [-r ] + [-s **5** | ] + [-t **qcow2** | tar ] + [-v] + [-w ] + + '-a' is the architecture type for the image (default: amd64) + '-b' is the backend type (default: haproxy) + '-c' is the path to the cache directory (default: ~/.cache/image-create) + '-h' display help message + '-i' is the base OS (default: ubuntu) + '-o' is the output image file name + '-r' enable the root account in the generated image (default: disabled) + '-s' is the image size to produce in gigabytes (default: 5) + '-t' is the image type (default: qcow2) + '-v' display the script version + '-w' working directory for image building (default: .) + + +Environment Variables +===================== +These are optional environment variables that can be set to override the script +defaults. + +CLOUD_INIT_DATASOURCES + - Comma seperated list of cloud-int datasources + - Default: ConfigDrive + - Options: NoCloud, ConfigDrive, OVF, MAAS, Ec2, + - Reference: https://launchpad.net/cloud-init + +BASE_OS_MIRROR + - URL to a mirror for the base OS selected + - Default: None + +DIB_ELEMENTS + - Override the elements used to build the image + - Default: None + +DIB_LOCAL_ELEMENTS + - Elements to add to the build (requires DIB_LOCAL_ELEMENTS_PATH be + specified) + - Default: None + +DIB_LOCAL_ELEMENTS_PATH + - Path to the local elements directory + - Default: None + +DIB_REPO_PATH + - Directory containing diskimage-builder + - Default: /diskimage-builder + - Reference: https://github.com/openstack/diskimage-builder + +ELEMENTS_PATH + - Directory that contains the default elements + - Default: /elements + - Reference: https://github.com/openstack/tripleo-image-elements + +ELEMENTS_REPO_PATH + - Directory containing tripleo-image-elements + - Default: /tripleo-image-elements + - Reference: https://github.com/openstack/tripleo-image-elements + +OCTAVIA_REPO_PATH + - Directory containing octavia + - + - Reference: https://github.com/stackforge/octavia + +Container Support +================= +The Docker command line required to import a tar file created with this script +is: + +.. code:: bash + + $ docker import - image:amphora-x64-haproxy < amphora-x64-haproxy.tar + + +References +========== + +This documentation and script(s) leverage prior work by the OpenStack TripleO +and Sahara teams. Thank you to everyone that worked on them for providing a +great foundation for creating Octavia Amphora images. + + | https://github.com/openstack/diskimage-builder + | https://github.com/openstack/diskimage-builder/blob/master/docs/docker.md + | https://github.com/openstack/tripleo-image-elements + | https://github.com/openstack/sahara-image-elements + +Copyright +========= + +Copyright 2014 Hewlett-Packard Development Company, L.P. + +All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +a copy of the License at + + | http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. + diff --git a/diskimage-create/diskimage-create.sh b/diskimage-create/diskimage-create.sh new file mode 100755 index 0000000000..84646dbbb3 --- /dev/null +++ b/diskimage-create/diskimage-create.sh @@ -0,0 +1,342 @@ +#!/bin/bash +# +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +set -e + +usage() { + echo + echo "Usage: $(basename $0)" + echo " [-a i386 | **amd64** | armhf ]" + echo " [-b **haproxy** ]" + echo " [-c **~/.cache/image-create** | ]" + echo " [-h]" + echo " [-i **ubuntu** | fedora | centos ]" + echo " [-o **amphora-x64-haproxy** | ]" + echo " [-r ]" + echo " [-s **5** | ]" + echo " [-t **qcow2** | tar ]" + echo " [-v]" + echo " [-w ]" + echo + echo " '-a' is the architecture type for the image (default: amd64)" + echo " '-b' is the backend type (default: haproxy)" + echo " '-c' is the path to the cache directory (default: ~/.cache/image-create)" + echo " '-h' display this help message" + echo " '-i' is the base OS (default: ubuntu)" + echo " '-o' is the output image file name" + echo " '-r' enable the root account in the generated image (default: disabled)" + echo " '-s' is the image size to produce in gigabytes (default: 5)" + echo " '-t' is the image type (default: qcow2)" + echo " '-v' display the script version" + echo " '-w' working directory for image building (default: .)" + echo + exit 1 +} + +version() { + echo "Amphora disk image creation script version:"\ + "`cat $OCTAVIA_REPO_PATH/diskimage-create/version.txt`" + exit 1 +} + +# Figure out where our directory is located +if [ -z $OCTAVIA_REPO_PATH ]; then + AMP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + OCTAVIA_REPO_PATH=${OCTAVIA_REPO_PATH:-${AMP_DIR%/*}} +fi + +while getopts "a:b:c:hi:o:t:r:s:vw:" opt; do + case $opt in + a) + AMP_ARCH=$OPTARG + if [ $AMP_ARCH != "i386" ] && \ + [ $AMP_ARCH != "amd64" ] && \ + [ $AMP_ARCH != "armhf" ]; then + echo "Error: Unsupported architecture " $AMP_ARCH " specified" + exit 3 + fi + ;; + b) + if [ $OPTARG == "haproxy" ]; then + AMP_BACKEND=$OPTARG-octavia + else + echo "Error: Unsupported backend type " $AMP_BACKEND " specified" + exit 3 + fi + ;; + c) + AMP_CACHEDIR=$OPTARG + ;; + h) + usage + ;; + i) + AMP_BASEOS=$OPTARG + if [ $AMP_BASEOS != "ubuntu" ] && \ + [ $AMP_BASEOS != "fedora" ] && \ + [ $AMP_BASEOS != "centos" ]; then + echo "Error: Unsupported base OS " $AMP_BASEOS " specified" + exit 3 + fi + ;; + o) + AMP_OUTPUTFILENAME=$OPTARG + ;; + t) + AMP_IMAGETYPE=$OPTARG + if [ $AMP_IMAGETYPE != "qcow2" ] && \ + [ $AMP_IMAGETYPE != "tar" ]; then + echo "Error: Unsupported image type " $AMP_IMAGETYPE " specified" + exit 3 + fi + ;; + r) + AMP_ROOTPW=$OPTARG + ;; + s) + AMP_IMAGESIZE=$OPTARG + if ! [[ $AMP_IMAGESIZE =~ ^[0-9]+$ ]]; then + echo "Error: Invalid image size " $AMP_IMAGESIZE " specified" + exit 3 + fi + ;; + v) + version + ;; + w) + AMP_WORKING_DIR=$OPTARG + ;; + *) + usage + ;; + esac +done + +shift $((OPTIND-1)) +if [ "$1" ]; then + usage +fi + +# Set the Octavia Amphora defaults if they aren't already set +AMP_ARCH=${AMP_ARCH:-"amd64"} + +AMP_BACKEND=${AMP_BACKEND:-"haproxy-octavia"} + +AMP_CACHEDIR=${AMP_CACHEDIR:-"$HOME/.cache/image-create"} + +AMP_BASEOS=${AMP_BASEOS:-"ubuntu"} + +AMP_OUTPUTFILENAME=${AMP_OUTPUTFILENAME:-"$AMP_DIR/amphora-x64-haproxy"} + +AMP_IMAGETYPE=${AMP_IMAGETYPE:-"qcow2"} + +AMP_IMAGESIZE=${AMP_IMAGESIZE:-5} + +OCTAVIA_ELEMENTS_PATH=$OCTAVIA_REPO_PATH/elements + +if ! [ -d $OCTAVIA_ELEMENTS_PATH ]; then + echo "ERROR: Octavia elements directory not found at: " $OCTAVIA_ELEMENTS_PATH " Exiting." + exit 1 +fi + +DIB_REPO_PATH=${DIB_REPO_PATH:-${OCTAVIA_REPO_PATH%/*}/diskimage-builder} + +if ! [ -d $DIB_REPO_PATH ]; then + echo "ERROR: diskimage-builder repo directory not found at: " $DIB_REPO_PATH " Exiting." + exit 1 +fi + +export PATH=$PATH:$DIB_REPO_PATH/bin + +DIB_ELEMENTS_PATH=${DIB_REPO_PATH:-${OCTAVIA_REPO_PATH%/*}/diskimage-builder/elements} + +if ! [ -d $DIB_ELEMENTS_PATH ]; then + echo "ERROR: diskimage-builder elements directory not found at: " $DIB_ELEMENTS_PATH " Exiting." + exit 1 +fi + +ELEMENTS_REPO_PATH=${ELEMENTS_REPO_PATH:-${OCTAVIA_REPO_PATH%/*}/tripleo-image-elements} + +if ! [ -d $ELEMENTS_REPO_PATH ]; then + echo "ERROR: tripleo-image-elements repo directory not found at: " $ELEMENTS_REPO_PATH " Exiting." + exit 1 +fi + +TRIPLEO_ELEMENTS_PATH=${ELEMENTS_PATH:-$ELEMENTS_REPO_PATH/elements} + +if ! [ -d $TRIPLEO_ELEMENTS_PATH ]; then + echo "ERROR: tripleo-image-elements elements directory not found at: " $TRIPLEO_ELEMENTS_PATH " Exiting." + exit 1 +fi + +if [ "$DIB_LOCAL_ELEMENTS_PATH" ]; then + export ELEMENTS_PATH=$DIB_ELEMENTS_PATH:$TRIPLEO_ELEMENTS_PATH:$OCTAVIA_ELEMENTS_PATH:$DIB_LOCAL_ELEMENTS_PATH +else + export ELEMENTS_PATH=$DIB_ELEMENTS_PATH:$TRIPLEO_ELEMENTS_PATH:$OCTAVIA_ELEMENTS_PATH +fi + +export CLOUD_INIT_DATASOURCES=${CLOUD_INIT_DATASOURCES:-"ConfigDrive"} + +# Find out what platform we are on +if [ -e /etc/os-release ]; then + platform=$(head -1 /etc/os-release) +else + platform=$(head -1 /etc/system-release | grep -e CentOS -e 'Red Hat Enterprise Linux' || :) + if [ -z "$platform" ]; then + echo -e "Unknown Host OS. Impossible to build images.\nAborting" + exit 2 + fi +fi + +if [ "$AMP_ROOTPW" ] && [ "$platform" != 'NAME="Ubuntu"' ]; then + if [ "$(getenforce)" != "Disabled" ]; then + echo "A root password cannot be enabled for images built on this platform while SELinux is enabled." + exit 1 + fi +fi + +if [ "$AMP_ROOTPW" ]; then + echo "Warning: Using a root password in the image, NOT FOR PRODUCTION USAGE." +fi + +# Make sure we have the required packages installed +if [ "$platform" = 'NAME="Ubuntu"' ]; then + PKG_LIST="qemu kpartx git" + for pkg in $PKG_LIST; do + if ! dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then + echo "Required package " $pkg " is not installed. Exiting." + exit 1 + fi + done + + # Also check if we can build the BASEOS on this Ubuntu version + UBUNTU_VERSION=`lsb_release -r | awk '{print $2}'` + if [ "$AMP_BASEOS" != "ubuntu" ] && \ + [ 1 -eq $(echo "$UBUNTU_VERSION < 14.04" | bc) ]; then + echo "Ubuntu minimum version 14.04 required to build $AMP_BASEOS." + echo "Earlier versions don't support the extended attributes required." + exit 1 + fi + +elif [ "$platform" = 'NAME=Fedora' ]; then + PKG_LIST="qemu kpartx git" + for pkg in $PKG_LIST; do + if ! yum list $pkg &> /dev/null; then + echo "Required package " $pkg " is not installed. Exiting." + exit 1 + fi + done +else + # centos or rhel + PKG_LIST="qemu-kvm qemu-img kpartx git" + for pkg in $PKG_LIST; do + if ! yum list $pkg &> /dev/null; then + echo "Required package " $pkg " is not installed. Exiting." + exit 1 + fi + done + if [ ${platform:0:6} = "CentOS" ]; then + # install EPEL repo, in order to install argparse + PKG_LIST="python-argparse" + if ! yum list $pkg &> /dev/null; then + echo "CentOS requires the python-argparse package be " + echo "installed separately from the EPEL repo." + echo "Required package " $pkg " is not installed. Exiting." + exit 1 + fi + fi +fi + +PKG_LIST="Babel argparse dib-utils PyYAML" + for pkg in $PKG_LIST; do + if ! pip freeze 2>/dev/null| grep -q "^$pkg==" &>/dev/null; then + echo "Required python package " $pkg " is not installed. Exiting." + exit 1 + fi + done + +if [ "$AMP_WORKING_DIR" ]; then + mkdir -p $AMP_WORKING_DIR + TEMP=$(mktemp -d $AMP_WORKING_DIR/diskimage-create.XXXXXX) +else + TEMP=$(mktemp -d diskimage-create.XXXXXX) +fi +pushd $TEMP > /dev/null + +# Setup some environment variables with the commit IDs used to build the image +pushd $DIB_REPO_PATH > /dev/null +export DIB_COMMIT_ID=`git rev-parse HEAD` +popd > /dev/null + +pushd $ELEMENTS_REPO_PATH > /dev/null +export ELEMENTS_COMMIT_ID=`git rev-parse HEAD` +popd > /dev/null + +pushd $OCTAVIA_REPO_PATH > /dev/null +export OCTAVIA_COMMIT_ID=`git rev-parse HEAD` +popd > /dev/null + + +# Setup the elements list + +if [ "$AMP_BASEOS" = "ubuntu" ]; then + AMP_element_sequence=${AMP_element_sequence:-"base vm ubuntu"} + if [ "$BASE_OS_MIRROR" ]; then + AMP_element_sequence="$AMP_element_sequence apt-mirror" + export UBUNTU_MIRROR="$BASE_OS_MIRROR" + fi +elif [ "$AMP_BASEOS" = "fedora" ]; then + AMP_element_sequence=${AMP_element_sequence:-"base vm fedora"} + if [ "$BASE_OS_MIRROR" ]; then + AMP_element_sequence="$AMP_element_sequence fedora-mirror" + export FEDORA_MIRROR="$BASE_OS_MIRROR" + fi +elif [ "$AMP_BASEOS" = "centos" ]; then + AMP_element_sequence=${AMP_element_sequence:-"base vm centos7"} + if [ "$BASE_OS_MIRROR" ]; then + AMP_element_sequence="$AMP_element_sequence centos-mirror" + export CENTOS_MIRROR="$BASE_OS_MIRROR" + fi +fi + +if [ "$AMP_ROOTPW" ]; then + AMP_element_sequence="$AMP_element_sequence root-passwd" + export DIB_PASSWORD=$AMP_ROOTPW +fi + +# Add the Octavia Amphora backend element +AMP_element_sequence="$AMP_element_sequence $AMP_BACKEND" + +# Allow full elements override +if [ "$DIB_ELEMENTS" ]; then + AMP_element_sequence="$DIB_ELEMENTS" +fi + +if [ "$DIB_LOCAL_ELEMENTS" ]; then + AMP_element_sequence="$AMP_element_sequence $DIB_LOCAL_ELEMENTS" +fi + +# Build the image + +if [ "$AMP_BASEOS" = "ubuntu" ]; then + export DIB_CLOUD_INIT_DATASOURCES=$CLOUD_INIT_DATASOURCES +fi + +disk-image-create -a $AMP_ARCH -o $AMP_OUTPUTFILENAME -t $AMP_IMAGETYPE --image-size $AMP_IMAGESIZE --image-cache $AMP_CACHEDIR $AMP_element_sequence + +popd > /dev/null # out of $TEMP +rm -rf $TEMP diff --git a/diskimage-create/image-tests.sh b/diskimage-create/image-tests.sh new file mode 100755 index 0000000000..1041f077b6 --- /dev/null +++ b/diskimage-create/image-tests.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +# This file is necessary because tox cannot handle pipes in commands + +echo "Examining the Amphora image. This will take some time." + +if [ "$1" ]; then + AMP_IMAGE_LOCATION=$1/amphora-x64-haproxy.qcow2 +else + AMP_IMAGE_LOCATION=amphora-x64-haproxy.qcow2 +fi + +if ! [ -f $AMP_IMAGE_LOCATION ]; then + echo "ERROR: Amphora image not found at: $AMP_IMAGE_LOCATION" + exit 1 +fi + +# Check the image size +virt-df -a $AMP_IMAGE_LOCATION | \ + grep -q "amphora-x64-haproxy.qcow2:/dev/sda1[ \t]*5015940[ \t]*.*" +if [ $? != 0 ]; then + echo "ERROR: Amphora image did not pass the default size test" + exit 1 +else + echo "Amphora image size is correct" +fi + +# Check the kernel +virt-inspector $AMP_IMAGE_LOCATION | \ + virt-inspector --xpath \ + '/operatingsystems/operatingsystem/distro' \ + | grep -q 'ubuntu' +if [ $? != 0 ]; then + echo "ERROR: Amphora image is using the wrong default distribution" + exit 1 +else + echo "Amphora image is using the correct distribution" +fi + +virt-inspector $AMP_IMAGE_LOCATION | \ + virt-inspector --xpath \ + '/operatingsystems/operatingsystem/arch' \ + | grep -q 'x86_64' +if [ $? != 0 ]; then + echo "ERROR: Amphora image is using the wrong default architecture" + exit 1 +else + echo "Amphora image is using the correct architecture" +fi + +virt-inspector $AMP_IMAGE_LOCATION | \ + virt-inspector --xpath \ + '/operatingsystems/operatingsystem/format' \ + | grep -q 'installed' +if [ $? != 0 ]; then + echo "ERROR: Amphora image is in the wrong format (should be installed)" + exit 1 +else + echo "Amphora image is using the correct format" +fi + +# Check for HAProxy +virt-inspector $AMP_IMAGE_LOCATION | \ + virt-inspector --xpath \ + '/operatingsystems/operatingsystem/applications/application/name[text()="haproxy"]' \ + | grep -q 'haproxy' +if [ $? != 0 ]; then + echo "ERROR: Amphora image is missing the haproxy package" + exit 1 +else + echo "HAProxy package found in the Amphora image" +fi + +echo "Amphora image looks good." +exit 0 diff --git a/diskimage-create/requirements.txt b/diskimage-create/requirements.txt new file mode 100644 index 0000000000..e8ae8ef916 --- /dev/null +++ b/diskimage-create/requirements.txt @@ -0,0 +1,4 @@ +argparse +Babel>=1.3 +dib-utils +PyYAML diff --git a/diskimage-create/test-requirements.txt b/diskimage-create/test-requirements.txt new file mode 100644 index 0000000000..925a68f4ab --- /dev/null +++ b/diskimage-create/test-requirements.txt @@ -0,0 +1,3 @@ +bashate +doc8 +Pygments diff --git a/diskimage-create/tox.ini b/diskimage-create/tox.ini new file mode 100644 index 0000000000..f5aef49146 --- /dev/null +++ b/diskimage-create/tox.ini @@ -0,0 +1,28 @@ +[tox] +minversion = 1.8 +envlist = bashate,docs,py27 +skipsdist = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} +install_command = pip install -U {opts} {packages} +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +whitelist_externals = virt-df + virt-inspector + mkdir + rm +commands = mkdir -p {toxinidir}/.amp_tox_test + ./diskimage-create.sh -o {toxinidir}/.amp_tox_test/amphora-x64-haproxy -w {toxworkdir} +# Work around tox limitations with command pipes +# https://bitbucket.org/hpk42/tox/issue/73/pipe-output-of-command-into-file + ./image-tests.sh {toxinidir}/.amp_tox_test + rm -rf {toxinidir}/.amp_tox_test + +[testenv:docs] +commands = doc8 README.rst ../elements/centos-mirror/README.rst ../elements/apt-mirror/README.rst ../elements/fedora-mirror/README.rst ../elements/haproxy-octavia/README.rst ../elements/root-passwd/README.rst + +[testenv:bashate] +commands = bashate diskimage-create.sh + bashate image-tests.sh + diff --git a/diskimage-create/version.txt b/diskimage-create/version.txt new file mode 100644 index 0000000000..49d59571fb --- /dev/null +++ b/diskimage-create/version.txt @@ -0,0 +1 @@ +0.1 diff --git a/elements/apt-mirror/README.rst b/elements/apt-mirror/README.rst new file mode 100644 index 0000000000..c4259092af --- /dev/null +++ b/elements/apt-mirror/README.rst @@ -0,0 +1,9 @@ +This element enables the use of a mirror for updating Ubuntu cloud images. +Using a local mirror increases the speed of building the image. + +The Ubuntu mirror URL is specified by setting the 'UBUNTU_MIRROR' environment +variable. + +.. code:: bash + + $ export UBUNTU_MIRROR=http:/// diff --git a/elements/apt-mirror/finalise.d/99-setup b/elements/apt-mirror/finalise.d/99-setup new file mode 100755 index 0000000000..9e47021eef --- /dev/null +++ b/elements/apt-mirror/finalise.d/99-setup @@ -0,0 +1,3 @@ +#!/bin/bash + +rm /etc/apt/apt.conf.d/01proxy diff --git a/elements/apt-mirror/pre-install.d/00-apt b/elements/apt-mirror/pre-install.d/00-apt new file mode 100755 index 0000000000..492b59a5c6 --- /dev/null +++ b/elements/apt-mirror/pre-install.d/00-apt @@ -0,0 +1,5 @@ +#!/bin/bash + +mkdir -p /etc/apt/apt.conf.d/ +touch /etc/apt/apt.conf.d/01proxy +echo -e "Acquire::http { Proxy \"$UBUNTU_MIRROR\"; };" > /etc/apt/apt.conf.d/01proxy diff --git a/elements/apt-mirror/root.d/0-check b/elements/apt-mirror/root.d/0-check new file mode 100755 index 0000000000..d67fae29e5 --- /dev/null +++ b/elements/apt-mirror/root.d/0-check @@ -0,0 +1,5 @@ +#!/bin/bash +if [ -z "$UBUNTU_MIRROR" ]; then + echo "You should specify parameter 'UBUNTU_MIRROR'" + exit 2 +fi diff --git a/elements/centos-mirror/README.rst b/elements/centos-mirror/README.rst new file mode 100644 index 0000000000..676d5f72be --- /dev/null +++ b/elements/centos-mirror/README.rst @@ -0,0 +1,9 @@ +This element enables the use of a mirror for updating CentOS cloud images. +Using a local mirror increases the speed of building the image. + +The CentOS mirror URL is specified by setting the 'CENTOS_MIRROR' environment +variable. + +.. code:: bash + + $ export UBUNTU_MIRROR=http:/// diff --git a/elements/centos-mirror/finalise.d/99-setup b/elements/centos-mirror/finalise.d/99-setup new file mode 100755 index 0000000000..331abbf906 --- /dev/null +++ b/elements/centos-mirror/finalise.d/99-setup @@ -0,0 +1,3 @@ +#!/bin/bash + +mv /opt/repos/* /etc/yum.repos.d/ diff --git a/elements/centos-mirror/pre-install.d/00-yum b/elements/centos-mirror/pre-install.d/00-yum new file mode 100755 index 0000000000..7ed033cfab --- /dev/null +++ b/elements/centos-mirror/pre-install.d/00-yum @@ -0,0 +1,13 @@ +#!/bin/bash + +mkdir -p /opt/repos +mv /etc/yum.repos.d/* /opt/repos/ +cat >> /etc/yum.repos.d/centos.repo </ diff --git a/elements/fedora-mirror/finalise.d/99-setup b/elements/fedora-mirror/finalise.d/99-setup new file mode 100755 index 0000000000..331abbf906 --- /dev/null +++ b/elements/fedora-mirror/finalise.d/99-setup @@ -0,0 +1,3 @@ +#!/bin/bash + +mv /opt/repos/* /etc/yum.repos.d/ diff --git a/elements/fedora-mirror/pre-install.d/00-yum b/elements/fedora-mirror/pre-install.d/00-yum new file mode 100755 index 0000000000..bf6138e698 --- /dev/null +++ b/elements/fedora-mirror/pre-install.d/00-yum @@ -0,0 +1,13 @@ +#!/bin/bash + +mkdir -p /opt/repos +mv /etc/yum.repos.d/* /opt/repos +cat >> /etc/yum.repos.d/fedora.repo < $FILENAME < $FILENAME < $FILENAME < ] + [-h] [-i **ubuntu** | fedora | centos ] [-o **amphora-x64-haproxy** | ] - [-t **qcow2** | tar ] + [-r ] [-s **5** | ] + [-t **qcow2** | tar ] + [-w ] '-a' is the architecture type for the image (default: amd64) '-b' is the backend type (default: haproxy) '-c' is the path to the cache directory (default: ~/.cache/image-create) + '-h' display help message '-i' is the base OS (default: ubuntu) '-o' is the output image file name - '-t' is the image type (default: qcow2) + '-r' enable the root account in the generated image (default: disabled) '-s' is the image size to produce in gigabytes (default: 5) + '-t' is the image type (default: qcow2) + '-w' working directory for image building (default: .) .. line-block:: @@ -78,6 +84,7 @@ Command syntax: Environment variables supported by the script: BASE_OS_MIRROR - URL to a mirror for the base OS selected (-i). DIB_REPO_PATH - Path to the diskimage-builder repository (default: ../../diskimage-builder) + ELEMENTS_REPO_PATH - Path to the /tripleo-image-elements repository (default: ../../tripleo-image-elements) DIB_ELEMENTS - Override the elements used to build the image DIB_LOCAL_ELEMENTS - Elements to add to the build (requires DIB_LOCAL_ELEMENTS_PATH be specified) DIB_LOCAL_ELEMENTS_PATH - Path to the local elements directory