blob: 37907b2e5b8f4fd10765fe34089c2dd8bc2f081d [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#
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040016export CLUSTER_MODEL="https://gerrit.mcp.mirantis.com/trymcp/drivetrain-model"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040017export CLUSTER_MODEL_REF="master"
18export CLUSTER_NAME="try-mcp"
Denis Egorenko96e8b062019-04-03 18:05:50 +040019export MCP_VERSION="nightly"
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040020export SALTSTACK_REPO="http://mirror.mirantis.com/${MCP_VERSION}/saltstack-2017.7/xenial xenial main"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040021export SALTSTACK_GPG="https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040022export APT_MIRANTIS_SALT_REPO="http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial xenial main"
23export APT_MIRANTIS_SALT_GPG="http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial/archive-salt-formulas.key"
24export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040025export SCRIPTS_REF="master"
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040026export UBUNTU_BASEURL="http://mirror.mirantis.com/${MCP_VERSION}/ubuntu/"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040027
28###
29# Hard-coded folder in template
30export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/"
31mkdir -p "${PACKER_IMAGES_CACHE}"
32
33export PACKER_LOG=1
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040034pushd config-drive
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040035 if [ ! -e model ]; then
36 git clone ${CLUSTER_MODEL} model/
37 pushd model
38 git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD
39 pushd classes/system
40 git submodule init
41 git submodule update
42 popd
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040043 popd
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040044 fi
45 if [ ! -e salt_scripts ]; then
46 git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/
47 pushd salt_scripts
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040048 git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040049 popd
50 fi
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040051popd
52
53[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
54mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040055# For qemu test-build:
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040056packer build -only=qemu -parallel=false -on-error=ask template.json
57#rm -rf ~/.packer.d/