blob: bc4a811ba7e1c40223f17ba1588197b964099c1e [file] [log] [blame]
#!/bin/bash
# pre-requirments:
# apt-get install cloud-localds
# Cloudimg: wget https://cloud-images.ubuntu.com/xenial/XXXX/xenial-server-cloudimg-amd64-disk1.img
# Packer: https://releases.hashicorp.com/packer/1.1.3/packer_1.1.3_linux_amd64.zip
# Those script - only example for variables, which should be passed to packer and
# overwrite variables under /scripts/ directory
# External script sources:
# http/bootstrap.saltstack.com.sh https://github.com/saltstack/salt-bootstrap
#
export IMAGE_NAME="cfg01"
#
export CLUSTER_MODEL="http://gerrit.mcp.mirantis.com/mcp/mcp-drivetrain-model"
export CLUSTER_MODEL_REF="master"
export MCP_VERSION=proposed
export SCRIPTS_REF=master
export CLUSTER_NAME=mcp-day01
export FORMULA_VERSION=proposed
export UBUNTU_BASEURL="http://mirror.mirantis.com/proposed/ubuntu/"
export SALTSTACK_REPO="http://mirror.mirantis.com/proposed/saltstack-2017.7/xenial xenial main"
export APT_MIRANTIS_GPG="http://apt.mirantis.com/public.gpg"
export SALTSTACK_GPG="https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"
export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ proposed salt"
export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts"
export APT_REPOSITORY="deb [arch=amd64] http://apt.mirantis.com/xenial/ proposed salt"
export APT_REPOSITORY_GPG=http://apt.mirantis.com/public.gpg
###
# Hard-coded folder in template
export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/"
mkdir -p "${PACKER_IMAGES_CACHE}"
export PACKER_LOG=1
pushd config-drive
if [ ! -e model ]; then
git clone ${CLUSTER_MODEL} model/
pushd model
git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD
pushd classes/system
git submodule init
git submodule update
popd
popd
fi
if [ ! -e salt_scripts ]; then
git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/
pushd salt_scripts
git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD
popd
fi
popd
[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
# For qemu test-build:
packer build -only=qemu -parallel=false -on-error=ask template.json
#rm -rf ~/.packer.d/