Update mirror-image

  * Allign to offline-build example

Change-Id: I96448007b75ef98dd8f658b0be14c0b56c8117ba
diff --git a/mirror-image/template.json b/mirror-image/template.json
index 79546ad..1bd1360 100644
--- a/mirror-image/template.json
+++ b/mirror-image/template.json
@@ -1,41 +1,93 @@
 {
   "variables": {
     "user": "root",
-    "password": "ho5uo7Uome5d",
+    "password": "r00tme",
     "do_api_token": "{{ env `DO_API_TOKEN` }}",
-    "distro": "mcp-mirror-image",
+    "image_name": "{{ env `IMAGE_NAME` }}",
+    "VM_IMAGE": "{{ env `VM_IMAGE` }}",
+    "floating_ip_pool": "{{ env `VM_FLOATING_IP_POOL` }}",
+    "VM_FLAVOR" : "{{ env `VM_FLAVOR` }}",
     "disk_size": "150000",
     "cluster_model": "{{ env `CLUSTER_MODEL` }}",
     "cluster_model_ref": "{{ env `CLUSTER_MODEL_REF` }}",
     "cluster_name": "{{ env `CLUSTER_NAME` }}",
     "formula_version": "{{ env `FORMULA_VERSION` }}",
-    "mcp_version": "{{ env `MCP_VERSION` }}"
+    "mcp_version": "{{ env `MCP_VERSION` }}",
+    "ubuntu_baseurl": "{{ env `UBUNTU_BASEURL` }}",
+    "saltstack_gpg": "{{ env `SALTSTACK_GPG` }}",
+    "saltstack_repo": "{{ env `SALTSTACK_REPO` }}",
+    "apt_mirantis_gpg": "{{ env `APT_MIRANTIS_GPG` }}",
+    "apt_mirantis_salt_repo": "{{ env `APT_MIRANTIS_SALT_REPO` }}",
+    "git_salt_formulas_scripts": "{{ env `GIT_SALT_FORMULAS_SCRIPTS` }}",
+    "apt_repository": "{{ env `APT_REPOSITORY` }}",
+    "apt_repository_gpg": "{{ env `APT_REPOSITORY_GPG` }}"
   },
   "provisioners": [
     {
+      "type": "file",
+      "source": "files/root/interfaces",
+      "destination": "/root/interfaces"
+    },
+    {
+      "type": "file",
+      "source": "files/root/minion.conf",
+      "destination": "/root/minion.conf"
+    },
+    {
       "environment_vars": [
         "CLUSTER_MODEL={{ user `cluster_model` }}",
         "CLUSTER_MODEL_REF={{ user `cluster_model_ref` }}",
         "CLUSTER_NAME={{ user `cluster_name` }}",
-        "FORMULA_VERSION={{ user `formula_version` }}"
+        "FORMULA_VERSION={{ user `formula_version` }}",
+        "UBUNTU_BASEURL={{ user `ubuntu_baseurl` }}",
+        "SALTSTACK_GPG={{ user `saltstack_gpg` }}",
+        "SALTSTACK_REPO={{ user `saltstack_repo` }}",
+        "APT_MIRANTIS_GPG={{ user `apt_mirantis_gpg` }}",
+        "APT_MIRANTIS_SALT_REPO={{ user `apt_mirantis_salt_repo` }}",
+        "GIT_SALT_FORMULAS_SCRIPTS={{ user `git_salt_formulas_scripts` }}",
+        "APT_REPOSITORY={{ user `apt_repository` }}",
+        "APT_REPOSITORY_GPG={{ user `apt_repository_gpg` }}",
+        "PACKER_OFFLINE_BUILD=true"
       ],
       "type": "shell",
       "expect_disconnect": "true",
       "override": {
+        "openstack": {
+          "scripts": [
+            "scripts/base.sh",
+            "scripts/network.sh",
+            "scripts/salt_bootstrap.sh",
+            "scripts/salt.sh"
+          ]
+        },
         "qemu": {
           "scripts": [
             "scripts/base.sh",
             "scripts/network.sh",
+            "scripts/salt_bootstrap.sh",
             "scripts/salt.sh"
           ]
         }
       }
     },
     {
+      "environment_vars": [
+        "APT_MIRANTIS_SALT_REPO={{ user `apt_mirantis_salt_repo` }}"
+      ],
       "type": "shell",
       "expect_disconnect": "true",
-      "execute_command": "sh '{{.Path}}'",
-      "script": "scripts/reboot.sh"
+      "override": {
+        "openstack": {
+          "scripts": [
+            "scripts/salt.sh"
+          ]
+        },
+        "qemu": {
+          "scripts": [
+            "scripts/salt.sh"
+          ]
+        }
+      }
     },
     {
       "environment_vars": [
@@ -45,6 +97,13 @@
       "type": "shell",
       "pause_before": "180s",
       "override": {
+        "openstack": {
+          "scripts": [
+            "scripts/mirrors.sh",
+            "scripts/security.sh",
+            "scripts/cleanup.sh"
+          ]
+        },
         "qemu": {
           "scripts": [
             "scripts/mirrors.sh",
@@ -56,77 +115,68 @@
     },
     {
       "type": "file",
-      "source": "configs/cloud/cloud.cfg.d/99_tcp.cfg",
+      "source": "files/etc/cloud/cloud.cfg.d/99_tcp.cfg",
       "destination": "/etc/cloud/cloud.cfg.d/99_tcp.cfg"
     },
     {
       "type": "file",
-      "source": "configs/cloud/cloud.cfg",
+      "source": "files/etc/cloud/cloud.cfg",
       "destination": "/etc/cloud/cloud.cfg"
     }
   ],
   "builders": [
     {
+      "type": "openstack",
+      "ssh_username": "{{user `user`}}",
+      "ssh_password": "{{user `password`}}",
+      "image_name": "{{user `image_name`}}",
+      "floating_ip_pool": "{{user `floating_ip_pool`}}",
+      "reuse_ips" : "true",
+      "security_groups": [
+        "open_all"
+      ],
+      "source_image": "{{ user `VM_IMAGE` }}",
+      "flavor": "{{ user `VM_FLAVOR` }}",
+      "user_data_file": "config-drive/user-data.yaml"
+    },
+    {
       "type": "qemu",
       "qemuargs": [
         [
           "-m",
-          "4096M"
+          "8096M"
+        ],
+        [
+          "-fda",
+          "config-drive/cloudata.iso"
         ],
         [
           "-smp",
           "4"
         ]
       ],
-      "vm_name": "{{ user `distro` }}-{{ isotime \"200601021504\"  }}",
-      "output_directory": "images/{{ user `distro` }}-qemu-{{ isotime \"200601021504\"  }}",
+      "vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\"  }}",
+      "output_directory": "images/{{ user `image_name`}}",
       "format": "qcow2",
       "accelerator": "kvm",
       "disk_size": "{{ user `disk_size`}}",
-      "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.3-server-amd64.iso",
+      "iso_url": "http://cloud-images.ubuntu.com/xenial/20180224/xenial-server-cloudimg-amd64-disk1.img",
+      "iso_target_path": "/root/isos/xenial-server-cloudimg-amd64-disk1.img",
       "iso_checksum_type": "md5",
-      "iso_checksum": "10fcd20619dce11fe094e960c85ba4a9",
+      "disk_image": true,
+      "iso_checksum": "697d8f9058ad118cea699d14ae414f8b",
       "http_directory": "http",
       "headless": true,
       "ssh_username": "{{user `user`}}",
       "ssh_password": "{{user `password`}}",
-      "shutdown_command": "shutdown -P now",
+      "shutdown_command": "sync; shutdown -P now",
+      "vnc_bind_address": "0.0.0.0",
+      "vnc_port_max": "5956",
+      "vnc_port_min": "5956",
+      "ssh_host_port_min": 2223,
+      "ssh_host_port_max": 2223,
       "boot_wait": "2s",
-      "ssh_wait_timeout": "10000s",
-      "boot_command": [
-        "<enter><wait>",
-        "<f6><esc>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
-        "<bs><bs><bs>",
-        "/install/vmlinuz<wait>",
-        " auto<wait>",
-        " console-setup/ask_detect=false<wait>",
-        " console-setup/layoutcode=us<wait>",
-        " console-setup/modelcode=pc105<wait>",
-        " debconf/frontend=noninteractive<wait>",
-        " debian-installer=en_US<wait>",
-        " fb=false<wait>",
-        " initrd=/install/initrd.gz<wait>",
-        " kbd-chooser/method=us<wait>",
-        " keyboard-configuration/layout=USA<wait>",
-        " keyboard-configuration/variant=USA<wait>",
-        " passwd/root-password={{user `password`}} ",
-        " passwd/root-password-again={{user `password`}} ",
-        " locale=en_US<wait>",
-        " netcfg/get_hostname=ubuntu-1604<wait>",
-        " netcfg/get_domain=changeme<wait>",
-        " noapic<wait>",
-        " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
-        " -- <wait>",
-        "<enter><wait>"
-      ]
+      "ssh_wait_timeout": "360s"
     }
   ]
-}
\ No newline at end of file
+}