Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # pre-requirments: |
| 4 | # apt-get install cloud-localds |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 5 | # Cloudimg: wget https://cloud-images.ubuntu.com/xenial/XXXX/xenial-server-cloudimg-amd64-disk1.img |
Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 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 | # |
azvyagintsev | 0adfe68 | 2018-06-13 16:29:40 +0300 | [diff] [blame] | 14 | export IMAGE_NAME="cfg01" |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 15 | # |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 16 | export CLUSTER_MODEL="http://gerrit.mcp.mirantis.com/mcp/mcp-drivetrain-model" |
| 17 | export CLUSTER_MODEL_REF="master" |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 18 | export MCP_VERSION=proposed |
| 19 | export SCRIPTS_REF=master |
| 20 | export CLUSTER_NAME=mcp-day01 |
| 21 | export FORMULA_VERSION=proposed |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 22 | export UBUNTU_BASEURL="http://mirror.mirantis.com/proposed/ubuntu/" |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 23 | export SALTSTACK_REPO="http://mirror.mirantis.com/proposed/saltstack-2017.7/xenial xenial main" |
Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 24 | export APT_MIRANTIS_GPG="http://apt.mirantis.com/public.gpg" |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 25 | export SALTSTACK_GPG="https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub" |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 26 | export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ proposed salt" |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 27 | export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts" |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 28 | export APT_REPOSITORY="deb [arch=amd64] http://apt.mirantis.com/xenial/ proposed salt" |
| 29 | export APT_REPOSITORY_GPG=http://apt.mirantis.com/public.gpg |
| 30 | ### |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 31 | # Hard-coded folder in template |
| 32 | export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/" |
| 33 | mkdir -p "${PACKER_IMAGES_CACHE}" |
Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 34 | |
| 35 | export PACKER_LOG=1 |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 36 | pushd config-drive |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame^] | 37 | if [ ! -e model ]; then |
| 38 | git clone ${CLUSTER_MODEL} model/ |
| 39 | pushd model |
| 40 | git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD |
| 41 | pushd classes/system |
| 42 | git submodule init |
| 43 | git submodule update |
| 44 | popd |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 45 | popd |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame^] | 46 | fi |
| 47 | if [ ! -e salt_scripts ]; then |
| 48 | git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/ |
| 49 | pushd salt_scripts |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 50 | git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame^] | 51 | popd |
| 52 | fi |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 53 | popd |
| 54 | |
| 55 | [ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso |
| 56 | mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive |
| 57 | |
Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 58 | # For qemu test-build: |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 59 | packer build -only=qemu -parallel=false -on-error=ask template.json |
| 60 | #rm -rf ~/.packer.d/ |