MAAS Show and Tell: Building CentOS images; MAAS RAD update/demo

Today, Lee (@ltrager) talked about building CentOS images, and Bill (@billwear) gave a demonstration of RAD as it makes its way into the live documentation, in preparation for the 2.9 release.

Enjoy! Please add questions, comments, and selections below .

2 Likes

Setup script:

#!/bin/bash -ex
# Configure git proxy
git config --global http.proxy "${http_proxy}"
git config --global https.proxy "${http_proxy}"

# Don't use proxy for internal things
# export no_proxy=.launchpad.net

# Install required build dependencies
sudo -n DEBIAN_FRONTEND=non-interactive apt-get install -y qemu-system-x86 qemu-utils unzip wget python3-simplestreams

# Download packer if it isn't already available.
PACKER_ZIP_PATH="$WORKSPACE_TMP/$(basename $PACKER_URL)"
if [ ! -f "$PACKER_ZIP_PATH" ] || [ ! -f "$WORKSPACE_TMP/packer" ]; then
    mkdir -p $WORKSPACE_TMP
    wget --continue $PACKER_URL -P $WORKSPACE_TMP
    unzip -o -d $WORKSPACE_TMP $PACKER_ZIP_PATH
fi

# Start with a clean workspace.
# 1. The job allows defining a custom git remote and branch.
# 2. lp:maas-images will add newly generated images to existing streams.
[ -d $WORKSPACE ] && sudo -n rm -rf $WORKSPACE/*
git clone --recurse-submodules -b $MAAS_IMAGE_BRANCH $MAAS_IMAGES_GIT

cd maas-images/packer-maas
# Switch to specified packer-maas remote and branch
git remote add $JOB_BASE_NAME $PACKER_MAAS_GIT
git fetch $JOB_BASE_NAME
git checkout $JOB_BASE_NAME/$PACKER_MAAS_BRANCH
git submodule update

# Set proxy settings for CentOS/RHEL
for template in */http/*.ks; do
    sed -Ei "/^(url|repo)/ s|$| --proxy=\"$http_proxy\"|" $template
done

Build script:

# Packer only recognizes upper case proxy environment variables - https://github.com/hashicorp/packer/issues/2275
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"

# meph2-import will use PACKER_PATH from the environment variable when defined, otherwise it search $PATH
export PACKER_PATH=$WORKSPACE_TMP/packer

# Cache ISOs into WORKSPACE_TMP so the cache survivies multiple builds.
export PACKER_CACHE_DIR=$WORKSPACE_TMP

# Disable checking for a new Packer version, it's blocked anyway.
export CHECKPOINT_DISABLE=1

# Needed to enable serial output
export PACKER_LOG=1

sudo -En $WORKSPACE/maas-images/bin/meph2-import -u packer-maas.yaml $WORKSPACE/centos-stream
2 Likes