Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # pre-requirments: |
| 4 | # apt-get install cloud-localds |
| 5 | # Cloudimg: wget https://cloud-images.ubuntu.com/xenial/XXXX/xenial-server-cloudimg-amd64-disk1.img |
| 6 | # Packer: https://releases.hashicorp.com/packer/1.1.3/packer_1.1.3_linux_amd64.zip |
| 7 | |
| 8 | # Those script - only example for variables, which should be passed to packer and |
| 9 | # overwrite variables under /scripts/ directory |
| 10 | |
| 11 | # External script sources: |
| 12 | # http/bootstrap.saltstack.com.sh https://github.com/saltstack/salt-bootstrap |
| 13 | # |
| 14 | export IMAGE_NAME="trymcp" |
| 15 | # |
| 16 | export APT_MIRANTIS_GPG="http://apt.mirantis.com/public.gpg" |
| 17 | export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ nightly salt" |
| 18 | export APT_REPOSITORY="deb [arch=amd64] http://apt.mirantis.com/xenial/ proposed salt" |
| 19 | export APT_REPOSITORY_GPG="http://apt.mirantis.com/public.gpg" |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 20 | export CLUSTER_MODEL="https://gerrit.mcp.mirantis.com/trymcp/drivetrain-model" |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 21 | export CLUSTER_MODEL_REF="master" |
| 22 | export CLUSTER_NAME="try-mcp" |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 23 | export FORMULA_VERSION="proposed" |
| 24 | export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts" |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 25 | export MCP_VERSION="proposed" |
| 26 | export SALTSTACK_GPG="https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub" |
| 27 | export SALTSTACK_REPO="http://mirror.mirantis.com/proposed/saltstack-2017.7/xenial xenial main" |
| 28 | export SCRIPTS_REF="master" |
| 29 | export UBUNTU_BASEURL="http://mirror.mirantis.com/proposed/ubuntu/" |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 30 | |
| 31 | ### |
| 32 | # Hard-coded folder in template |
| 33 | export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/" |
| 34 | mkdir -p "${PACKER_IMAGES_CACHE}" |
| 35 | |
| 36 | export PACKER_LOG=1 |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 37 | pushd config-drive |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame^] | 38 | if [ ! -e model ]; then |
| 39 | git clone ${CLUSTER_MODEL} model/ |
| 40 | pushd model |
| 41 | git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD |
| 42 | pushd classes/system |
| 43 | git submodule init |
| 44 | git submodule update |
| 45 | popd |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 46 | popd |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame^] | 47 | fi |
| 48 | if [ ! -e salt_scripts ]; then |
| 49 | git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/ |
| 50 | pushd salt_scripts |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 51 | git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame^] | 52 | popd |
| 53 | fi |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 54 | popd |
| 55 | |
| 56 | [ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso |
| 57 | mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 58 | # For qemu test-build: |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 59 | packer build -only=qemu -parallel=false -on-error=ask template.json |
| 60 | #rm -rf ~/.packer.d/ |