Skip to content

EN.03.09.Vagrant Share

stormcat24 edited this page Aug 29, 2014 · 1 revision

This procedure is to publish Aeromock on localhost to external by using Vagrant Share temporarily. If want to immediately check behaviors on smartphone, very useful.

Setup

Install

Install Vagrant an Virtualbox. If MacOS, recommend to install by homebrew.

Install Vagrant plugin

Install the following plugins.

sahara

sahara is plugin to roll back VM to specific snapshot, please use if necessary.

$ vagrant plugin install sahara
vagrant-hostsupdater

vagrant-hostsupdater is plugin to add internal IP address to /etc/hosts on localhost when startup VM by Vagrant.

$ vagrant plugin install vagrant-hostsupdater

Signup to Vagrant Cloud

Necessary to signup to Vagrant Cloud.

Configuration of Vagrant

Firstlly, run initVagrant of aeromock-brew.

$ cd /path-to-path/aeromock-brew
$ ./gradlew initVagrant

Directory of ~/.aeromock/vagrant is created. the following files, directories are created in this directory.

  • Vagrantfile
  • ansible/
  • config.yaml
  • env.yaml

env.yaml

env.yaml is configuration file to specify system resources assigned to Vagrant, shared folders of Vagrant.

name content
memory memory size(MB) of VM
cpus number of cpu core of VM
private_ip private IP address of VM
basic_user user name of BASIC authentication
basic_pass password of BASIC authentication
share_dir mounted directory to VM(should include things you need in Aeromock)
mount_dir path of VM mount share_dir

For example, configure to see ~/path-to-path/aeromock/tutorial on VM. The important settings is share_dir and mount_dir.

Configure share_dir to mount ~/path-to-path/aeromock/tutorial to VM as follows.

share_dir: ~/path-to-path/aeromock/tutorial

mount_dir For mount_dir, use share_dir of last statement is good idea.

mount_dir: /tutorial

Finally, it as follows.

memory: 1024
cpus: 1
private_ip: 192.168.33.30
basic_user: vagrant
basic_pass: aeromock
share_dir: ~/path-to-path/aeromock/tutorial
mount_dir: /tutorial

config.yaml

~/.aeromock/vagrant/config.yaml is config.yaml is used by Aeromock on VM. project_config_path on config.yaml is specified project.yaml in mount_dir at env.yaml.

project_config_path: /tutorial/freemarker/project.yaml

Start up VM

Run vagrant up to startup VM at ~/.aeromock/vagrant. Provisioning by Ansible is executed at first time, then install required software. hosts file is changed by vagrant-hostsupdater, so it's required sudo on the way.

$ cd ~/.aeromock/vagrant
$ vagrant up

image

If without errors, has finished provisioning and startup. image

Check behaviors on VM

When start up, Aeromock runs on VM. Then, be able to output HTML by using template files and data files on localhost(Host OS). The internal IP address of VM is 192.168.33.30, check page is showning at http://192.168.33.30/test . At this time, BASIC authentication is required, so please login by using user name and password defined at env.yaml.

Publish to external by Vagrant Share

Then, publish this state to external by Vagrant Share. Run vagrant share for Publication.

$ cd ~/.aeromock/vagrant
$ vagrant share

At this time, you must input user name and password of Vagrant Share. Green character and random sub domain of vagrantshare.com is displayed, this is published destination.

image

Access to published URL.

image

Send siglnal of Ctrl+C on terminal to finish publication.

Shut down VM

Run the following command to shut down VM.

$ vagrant halt

Please refer to Official about various configuration of Vagrant.

Notes

  • Do not use default password of BASIC authentication at env.yaml, change password only you can know. To change password, requires provisioning again, so the following command to start up VM.
$ vagrant up --provision
  • Published content by Vagrant Share must not include secure and confidential information. If uses SSL, refer to this link. Aeromock will not support SSL.

Initialize ~/.aeromock/vagrant

If initialize ~/.aeromock/vagrant, please run initVagrant again. Configuration files like Vagrantfile is stored to ~/.aeromock/vagrant_backup with timestamp. But, VM is removed physically.

If Vagrantfile or Ansible playbook in aeromock-brew is changed, this operation will be required.

Clone this wiki locally