azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 1 | #!/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 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 15 | export IMAGE_NAME="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')" |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 16 | export PACKER_IMAGES_CACHE="${HOME}/packer_images_cache/" |
| 17 | # |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame] | 18 | export CLUSTER_MODEL="https://gerrit.mcp.mirantis.com/mcp/mcp-offline-model" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 19 | export CLUSTER_MODEL_REF="master" |
| 20 | export CLUSTER_NAME="mcp-offline" |
| 21 | |
azvyagintsev | 017bef8 | 2018-07-25 13:38:53 +0300 | [diff] [blame] | 22 | export MCP_VERSION="proposed" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 23 | |
azvyagintsev | 017bef8 | 2018-07-25 13:38:53 +0300 | [diff] [blame] | 24 | BINARY_MCP_VERSION="proposed" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 25 | export UBUNTU_BASEURL="http://mirror.mirantis.com/${BINARY_MCP_VERSION}/ubuntu/" |
azvyagintsev | 41bc80d | 2018-07-12 13:46:56 +0300 | [diff] [blame] | 26 | export SALTSTACK_REPO="http://mirror.mirantis.com/${BINARY_MCP_VERSION}/saltstack-2017.7/xenial xenial main" |
| 27 | export SALTSTACK_GPG="http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 28 | export APT_MIRANTIS_GPG="http://apt.mirantis.com/public.gpg" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 29 | export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ ${BINARY_MCP_VERSION} salt " |
| 30 | # |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame] | 31 | export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts" |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 32 | export SCRIPTS_REF="master" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 33 | # |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 34 | # Openstack-related variables |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 35 | #export VM_FLAVOR="3c4fe514-3eb6-464d-a419-7be09d72cf1e" |
| 36 | #export VM_FLOATING_IP_POOL="095f43ed-65ba-48ce-8185-d4080e430a88" |
| 37 | #export IMAGE_NAME="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')" |
| 38 | #export VM_IMAGE="9953a40d-1fa2-4f26-b146-0507dbc912dc" # ubuntu cloud img |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 39 | # May be need, if cloud with keystone v3 used |
| 40 | #export OS_TENANT_ID=$OS_PROJECT_ID |
| 41 | #export OS_DOMAIN_NAME="xxxx" |
| 42 | #export OS_TENANT_NAME="xxxxx" |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 43 | |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 44 | # Hard-coded folder in template |
| 45 | mkdir -p "${PACKER_IMAGES_CACHE}" |
| 46 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 47 | export PACKER_LOG=1 |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 48 | pushd config-drive |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame] | 49 | if [ ! -e model ]; then |
| 50 | git clone ${CLUSTER_MODEL} model/ |
| 51 | pushd model |
| 52 | git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD |
| 53 | pushd classes/system |
| 54 | git submodule init |
| 55 | git submodule update |
| 56 | popd |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 57 | popd |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame] | 58 | fi |
| 59 | if [ ! -e salt_scripts ]; then |
| 60 | git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/ |
| 61 | pushd salt_scripts |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 62 | git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD |
Ivan Berezovskiy | c3224e5 | 2018-11-19 16:52:32 +0400 | [diff] [blame] | 63 | popd |
| 64 | fi |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 65 | popd |
| 66 | |
| 67 | [ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso |
| 68 | mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 69 | # For qemu test-build: |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 70 | packer build -only=qemu -parallel=false -on-error=ask template.json |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 71 | # rm -rf ~/.packer.d/ |