blob: 4ad15c5bb7a017539346837f9d8dc2e5dd834e74 [file] [log] [blame]
Jiri Broulik4ea221c2018-04-10 13:48:06 +02001#!/bin/bash
2
3# pre-requirments:
4# apt-get install cloud-localds
azvyagintsevffa75b42018-06-06 20:38:54 +03005# Cloudimg: wget https://cloud-images.ubuntu.com/xenial/XXXX/xenial-server-cloudimg-amd64-disk1.img
Jiri Broulik4ea221c2018-04-10 13:48:06 +02006# 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#
azvyagintsev0adfe682018-06-13 16:29:40 +030014export IMAGE_NAME="cfg01"
azvyagintsevffa75b42018-06-06 20:38:54 +030015#
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040016export CLUSTER_MODEL="http://gerrit.mcp.mirantis.com/mcp/mcp-drivetrain-model"
17export CLUSTER_MODEL_REF="master"
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040018export CLUSTER_NAME="mcp-day01"
19export MCP_VERSION="proposed"
20export SALTSTACK_REPO="http://mirror.mirantis.com/${MCP_VERSION}/saltstack-2017.7/xenial xenial main"
azvyagintsev0f697cf2018-06-22 11:44:13 +030021export 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"
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040024export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts"
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040025export SCRIPTS_REF="master"
26export UBUNTU_BASEURL="http://mirror.mirantis.com/${MCP_VERSION}/ubuntu/"
azvyagintsevffa75b42018-06-06 20:38:54 +030027###
azvyagintsev0f697cf2018-06-22 11:44:13 +030028# Hard-coded folder in template
29export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/"
30mkdir -p "${PACKER_IMAGES_CACHE}"
Jiri Broulik4ea221c2018-04-10 13:48:06 +020031
32export PACKER_LOG=1
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040033pushd config-drive
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040034 if [ ! -e model ]; then
35 git clone ${CLUSTER_MODEL} model/
36 pushd model
37 git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD
38 pushd classes/system
39 git submodule init
40 git submodule update
41 popd
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040042 popd
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040043 fi
44 if [ ! -e salt_scripts ]; then
45 git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/
46 pushd salt_scripts
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040047 git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD
Ivan Berezovskiyc3224e52018-11-19 16:52:32 +040048 popd
49 fi
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040050popd
51
52[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
53mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
54
Jiri Broulik4ea221c2018-04-10 13:48:06 +020055# For qemu test-build:
azvyagintsevffa75b42018-06-06 20:38:54 +030056packer build -only=qemu -parallel=false -on-error=ask template.json
57#rm -rf ~/.packer.d/