blob: 92ad38655171b31fbf0f45292ca8022c02b37ce5 [file] [log] [blame]
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +04001#!/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#
14export IMAGE_NAME="trymcp"
15#
16export APT_MIRANTIS_GPG="http://apt.mirantis.com/public.gpg"
17export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ nightly salt"
18export APT_REPOSITORY="deb [arch=amd64] http://apt.mirantis.com/xenial/ proposed salt"
19export APT_REPOSITORY_GPG="http://apt.mirantis.com/public.gpg"
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040020export CLUSTER_MODEL="https://gerrit.mcp.mirantis.com/trymcp/drivetrain-model"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040021export CLUSTER_MODEL_REF="master"
22export CLUSTER_NAME="try-mcp"
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040023export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040024export MCP_VERSION="proposed"
25export SALTSTACK_GPG="https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"
26export SALTSTACK_REPO="http://mirror.mirantis.com/proposed/saltstack-2017.7/xenial xenial main"
27export SCRIPTS_REF="master"
28export UBUNTU_BASEURL="http://mirror.mirantis.com/proposed/ubuntu/"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040029
30###
31# Hard-coded folder in template
32export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/"
33mkdir -p "${PACKER_IMAGES_CACHE}"
34
35export PACKER_LOG=1
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040036pushd config-drive
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040037 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 Berezovskiy23035a22018-11-14 13:25:51 +040045 popd
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040046 fi
47 if [ ! -e salt_scripts ]; then
48 git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/
49 pushd salt_scripts
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040050 git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040051 popd
52 fi
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040053popd
54
55[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
56mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040057# For qemu test-build:
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040058packer build -only=qemu -parallel=false -on-error=ask template.json
59#rm -rf ~/.packer.d/