blob: 8a51c737557ad56a5d7a80dcaa9a932575b3bbd0 [file] [log] [blame]
azvyagintsev6d453852018-02-26 16:56:37 +02001#!/bin/bash
2
3# pre-requirments:
4# apt-get install cloud-localds
5# Cloudimg: wget https://cloud-images.ubuntu.com/xenial/current/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
azvyagintsev29410ee2018-07-12 20:02:30 +030015export IMAGE_NAME="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')"
azvyagintsev0f697cf2018-06-22 11:44:13 +030016export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/"
17#
azvyagintsev6d453852018-02-26 16:56:37 +020018export CLUSTER_MODEL="https://github.com/Mirantis/mcp-offline-model.git"
19export CLUSTER_MODEL_REF="master"
20export CLUSTER_NAME="mcp-offline"
21
azvyagintsev017bef82018-07-25 13:38:53 +030022export MCP_VERSION="proposed"
23export FORMULA_VERSION="proposed"
azvyagintsev6d453852018-02-26 16:56:37 +020024
azvyagintsev017bef82018-07-25 13:38:53 +030025BINARY_MCP_VERSION="proposed"
azvyagintsev6d453852018-02-26 16:56:37 +020026export UBUNTU_BASEURL="http://mirror.mirantis.com/${BINARY_MCP_VERSION}/ubuntu/"
azvyagintsev41bc80d2018-07-12 13:46:56 +030027export SALTSTACK_REPO="http://mirror.mirantis.com/${BINARY_MCP_VERSION}/saltstack-2017.7/xenial xenial main"
28export SALTSTACK_GPG="http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"
azvyagintsev6d453852018-02-26 16:56:37 +020029export APT_MIRANTIS_GPG="http://apt.mirantis.com/public.gpg"
azvyagintsev6d453852018-02-26 16:56:37 +020030export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ ${BINARY_MCP_VERSION} salt "
31#
32export GIT_SALT_FORMULAS_SCRIPTS="https://github.com/salt-formulas/salt-formulas-scripts.git"
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040033export SCRIPTS_REF="master"
azvyagintsev6d453852018-02-26 16:56:37 +020034#
35export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
36export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG}
37
38# Openstack-related variables
azvyagintsev0f697cf2018-06-22 11:44:13 +030039#export VM_FLAVOR="3c4fe514-3eb6-464d-a419-7be09d72cf1e"
40#export VM_FLOATING_IP_POOL="095f43ed-65ba-48ce-8185-d4080e430a88"
41#export IMAGE_NAME="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')"
42#export VM_IMAGE="9953a40d-1fa2-4f26-b146-0507dbc912dc" # ubuntu cloud img
azvyagintsevc86fbaf2018-03-02 18:57:03 +020043# May be need, if cloud with keystone v3 used
44#export OS_TENANT_ID=$OS_PROJECT_ID
45#export OS_DOMAIN_NAME="xxxx"
46#export OS_TENANT_NAME="xxxxx"
azvyagintsev6d453852018-02-26 16:56:37 +020047
azvyagintsev0f697cf2018-06-22 11:44:13 +030048# Hard-coded folder in template
49mkdir -p "${PACKER_IMAGES_CACHE}"
50
azvyagintsev6d453852018-02-26 16:56:37 +020051export PACKER_LOG=1
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040052pushd config-drive
53 [ -d model ] && rm -rf model
54 git clone ${CLUSTER_MODEL} model/
55 pushd model
56 git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD
57 pushd classes/system
58 git submodule init
59 git submodule update
60 popd
61 popd
62 [ -d salt_scripts ] && rm -rf salt_scripts
63 git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/
64 pushd salt_scripts
65 git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD
66 popd
67popd
68
69[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
70mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
azvyagintsevc86fbaf2018-03-02 18:57:03 +020071# For qemu test-build:
azvyagintsev0f697cf2018-06-22 11:44:13 +030072packer build -only=qemu -parallel=false -on-error=ask template.json
azvyagintsevc86fbaf2018-03-02 18:57:03 +020073# rm -rf ~/.packer.d/