blob: c52b2a324c6fee5f3ede98cfe2ecd1bfecf18eb7 [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 CLUSTER_NAME="mcp-day01"
export MCP_VERSION="proposed"
export SALTSTACK_GPG=${SALTSTACK_GPG:-"http://mirror.mirantis.com/${MCP_VERSION}/saltstack-2017.7/xenial/SALTSTACK-GPG-KEY.pub"}
export SALTSTACK_REPO=${SALTSTACK_REPO:-"http://mirror.mirantis.com/${MCP_VERSION}/saltstack-2017.7/ xenial main"}
export APT_MIRANTIS_SALT_REPO="http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial xenial main"
export APT_MIRANTIS_SALT_GPG="http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial/archive-salt-formulas.key"
export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts"
export SCRIPTS_REF="master"
export UBUNTU_BASEURL="http://mirror.mirantis.com/${MCP_VERSION}/ubuntu/"
###
# 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/