Update images build with repos checkout from gerrit

Change-Id: I27d19e248a1ded6b2a6a2a30b2955da57f23bc3f
diff --git a/trymcp-day01-image/config-drive/meta-data b/trymcp-day01-image/config-drive/meta-data
new file mode 100644
index 0000000..c7ba190
--- /dev/null
+++ b/trymcp-day01-image/config-drive/meta-data
@@ -0,0 +1 @@
+hostname: ubuntu
diff --git a/trymcp-day01-image/config-drive/user-data.yaml b/trymcp-day01-image/config-drive/user-data
similarity index 100%
rename from trymcp-day01-image/config-drive/user-data.yaml
rename to trymcp-day01-image/config-drive/user-data
diff --git a/trymcp-day01-image/files/etc/cloud/cloud.cfg b/trymcp-day01-image/files/etc/cloud/cloud.cfg
index 953ceb8..b0a87f9 100644
--- a/trymcp-day01-image/files/etc/cloud/cloud.cfg
+++ b/trymcp-day01-image/files/etc/cloud/cloud.cfg
@@ -96,3 +96,4 @@
   - salt-call state.sls gerrit
   - sleep 25
   - salt-call state.sls jenkins
+  - touch /done_cloud_init_bootstrap
diff --git a/trymcp-day01-image/run.example.sh b/trymcp-day01-image/run.example.sh
index 4fafb55..754a166 100755
--- a/trymcp-day01-image/run.example.sh
+++ b/trymcp-day01-image/run.example.sh
@@ -17,17 +17,16 @@
 export APT_MIRANTIS_SALT_REPO="http://apt.mirantis.com/xenial/ nightly salt"
 export APT_REPOSITORY="deb [arch=amd64] http://apt.mirantis.com/xenial/ proposed salt"
 export APT_REPOSITORY_GPG="http://apt.mirantis.com/public.gpg"
-export CLUSTER_MODEL="https://github.com/LotharKAtt/trymcp-drivetrain-model.git"
+export CLUSTER_MODEL="https://gerrit.mcp.mirantis.com/trymcp/drivetrain-model"
 export CLUSTER_MODEL_REF="master"
 export CLUSTER_NAME="try-mcp"
-export FORMULA_VERSION="nightly"
-export GIT_SALT_FORMULAS_SCRIPTS="https://github.com/salt-formulas/salt-formulas-scripts.git"
+export FORMULA_VERSION="proposed"
+export GIT_SALT_FORMULAS_SCRIPTS="https://gerrit.mcp.mirantis.com/salt-formulas/salt-formulas-scripts"
 export MCP_VERSION="proposed"
 export SALTSTACK_GPG="https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"
 export SALTSTACK_REPO="http://mirror.mirantis.com/proposed/saltstack-2017.7/xenial xenial main"
 export SCRIPTS_REF="master"
 export UBUNTU_BASEURL="http://mirror.mirantis.com/proposed/ubuntu/"
-export BINARY_MCP_VERSION="proposed"
 
 ###
 # Hard-coded folder in template
@@ -35,7 +34,25 @@
 mkdir -p "${PACKER_IMAGES_CACHE}"
 
 export PACKER_LOG=1
+pushd config-drive
+  [ -d model ] && rm -rf model
+  git clone ${CLUSTER_MODEL} model/
+  pushd model
+    git fetch ${CLUSTER_MODEL} ${CLUSTER_MODEL_REF} && git checkout FETCH_HEAD
+    pushd classes/system
+      git submodule init
+      git submodule update
+    popd
+  popd
+  [ -d salt_scripts ] && rm -rf salt_scripts
+  git clone ${GIT_SALT_FORMULAS_SCRIPTS} salt_scripts/
+  pushd salt_scripts
+    git fetch ${GIT_SALT_FORMULAS_SCRIPTS} ${SCRIPTS_REF} && git checkout FETCH_HEAD
+  popd
+popd
+
+[ -f config-drive/cloudata.iso ] && rm -v config-drive/cloudata.iso
+mkisofs -o config-drive/cloudata.iso -V cidata -r -J --quiet config-drive
 # For qemu test-build:
-cloud-localds  --hostname ubuntu --dsmode local config-drive/cloudata.iso  config-drive/user-data.yaml
 packer build -only=qemu -parallel=false -on-error=ask template.json
 #rm -rf ~/.packer.d/
diff --git a/trymcp-day01-image/scripts/salt.sh b/trymcp-day01-image/scripts/salt.sh
index 51eea35..b4137dd 100644
--- a/trymcp-day01-image/scripts/salt.sh
+++ b/trymcp-day01-image/scripts/salt.sh
@@ -22,18 +22,19 @@
 salt-call ${SALT_OPTS} state.sls docker.host
 salt-call ${SALT_OPTS} saltutil.sync_all
 
-docker pull docker-prod-local.artifactory.mirantis.com/mirantis/cicd/mysql:2018.8.0
-docker pull docker-prod-local.artifactory.mirantis.com/mirantis/cicd/gerrit:2018.8.0
-docker pull docker-prod-local.artifactory.mirantis.com/mirantis/cicd/jenkins:2018.8.0
-# FIXME: workaround for missing packages in jenkins slave image
-#docker pull docker-prod-local.artifactory.mirantis.com/mirantis/cicd/jnlp-slave:2018.8.0
-docker pull quay.io/lotharkatt/jenkins-slave:latest
-docker pull docker-prod-local.artifactory.mirantis.com/mirantis/cicd/phpldapadmin:2018.8.0
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/mysql:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/gerrit:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/jenkins:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/jnlp-slave:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/phpldapadmin:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/model-generator/operations-api:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/model-generator/operations-ui:${MCP_VERSION}"
+# Mirror images below into artifactory
 docker pull jboss/keycloak:4.5.0.Final
 docker pull jboss/keycloak-proxy:3.4.2.Final
-docker pull mirantis/python-operations-api:latest
-docker pull cockroachdb/cockroach:latest
-docker pull mirantis/operations-ui:latest
+docker pull cockroachdb/cockroach:v2.1.0
+# FIXME: setup build for images below with proper versions and publish to artifactory
+docker pull atengler/cockroach-init:latest
 echo "---------------------"
 docker images
 echo "---------------------"
diff --git a/trymcp-day01-image/template.json b/trymcp-day01-image/template.json
index 72ff9e0..aa63016 100644
--- a/trymcp-day01-image/template.json
+++ b/trymcp-day01-image/template.json
@@ -65,6 +65,7 @@
         "FORMULA_VERSION={{ user `formula_version` }}",
         "APT_MIRANTIS_SALT_REPO={{ user `apt_mirantis_salt_repo` }}",
         "BOOTSTRAP_SALTSTACK_COM=file:///opt/bootstrap.saltstack.com.sh",
+        "MCP_VERSION={{ user `mcp_version` }}",
         "PACKER_OFFLINE_BUILD=true"
       ],
       "type": "shell",
@@ -77,10 +78,6 @@
       ]
     },
     {
-      "environment_vars": [
-        "HOME=/root",
-        "MCP_VERSION={{ user `mcp_version` }}"
-      ],
       "type": "shell",
       "pause_before": "10s",
       "scripts": [
@@ -104,7 +101,7 @@
           "8096M"
         ],
         [
-          "-fda",
+          "-cdrom",
           "config-drive/cloudata.iso"
         ],
         [