-
Notifications
You must be signed in to change notification settings - Fork 11
EN.03.09.Vagrant Share
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.
Install Vagrant an Virtualbox. If MacOS, recommend to install by homebrew.
- Vagrant >= 1.5
- VirtualBox >= 4.3
Install the following plugins.
sahara is plugin to roll back VM to specific snapshot, please use if necessary.
$ vagrant plugin install sahara
vagrant-hostsupdater is plugin to add internal IP address to /etc/hosts
on localhost when startup VM by Vagrant.
$ vagrant plugin install vagrant-hostsupdater
Necessary to signup to Vagrant Cloud.
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 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
~/.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
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
If without errors, has finished provisioning and startup.
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
.
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.
Access to published URL.
Send siglnal of Ctrl+C
on terminal to finish publication.
Run the following command to shut down VM.
$ vagrant halt
Please refer to Official about various configuration of Vagrant.
- 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.
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.