| #!/bin/bash | 
 |  | 
 | # pre-requirments: | 
 | # apt-get install cloud-localds | 
 | # Cloudimg: wget https://cloud-images.ubuntu.com/xenial/current/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="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')" | 
 | export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/" | 
 | # | 
 | export CLUSTER_MODEL="https://gerrit.mcp.mirantis.com/mcp/mcp-offline-model" | 
 | export CLUSTER_MODEL_REF="master" | 
 | export CLUSTER_NAME="mcp-offline" | 
 |  | 
 | export MCP_VERSION="proposed" | 
 |  | 
 | BINARY_MCP_VERSION="proposed" | 
 | export UBUNTU_BASEURL="http://mirror.mirantis.com/${BINARY_MCP_VERSION}/ubuntu/" | 
 | export SALTSTACK_REPO="http://mirror.mirantis.com/${BINARY_MCP_VERSION}/saltstack-2017.7/xenial xenial main" | 
 | export SALTSTACK_GPG="http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub" | 
 | export APT_MIRANTIS_SALT_GPG="http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial/archive-salt-formulas.key" | 
 | export APT_MIRANTIS_SALT_REPO="http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial xenial main" | 
 | # | 
 | export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts" | 
 | export SCRIPTS_REF="master" | 
 | # | 
 | # Openstack-related variables | 
 | #export VM_FLAVOR="3c4fe514-3eb6-464d-a419-7be09d72cf1e" | 
 | #export VM_FLOATING_IP_POOL="095f43ed-65ba-48ce-8185-d4080e430a88" | 
 | #export IMAGE_NAME="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')" | 
 | #export VM_IMAGE="9953a40d-1fa2-4f26-b146-0507dbc912dc" # ubuntu cloud img | 
 | # May be need, if cloud with keystone v3 used | 
 | #export OS_TENANT_ID=$OS_PROJECT_ID | 
 | #export OS_DOMAIN_NAME="xxxx" | 
 | #export OS_TENANT_NAME="xxxxx" | 
 |  | 
 | # Hard-coded folder in template | 
 | 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/ |