Windows user can use chocolatey to install the tools below
Install with cmd.exe:
$ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Mac user can use homebrew.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1. Vagrant
Visit website link above to install and check version:
$ chocolatey install vagrant
$ vagrant -v
$ brew install vagrant
$ vagrant -v
2. Packer
Visit website link above to install and check version:
$ chocolatey install packer
$ packer -v
$ brew install packer
$ packer -v
3. jq
Visit website link above to install and check version This will extract json variables specified in variables.json in step 3
$ chocolatey install jq
$ jq
$ brew install jq
$ jq
Clone this repository (copy/paste and run the command line below)
$ git clone https://github.com/jwang206/Interpret-Air.git && cd Interpret-Air/packer-vagrant-script/packer
Change directory to the packer folder
$ cd Interpret-Air/packer-vagrant-script/packer
Assuming you have generated ssh key with ssh-keygen command in ~/.ssh with default name id_rsa, and registered github deploy key with your public ssh key, copy your private ssh key to packer folder and rename it id_rsa_github_deploy_key
$ cp ~/.ssh/id_rsa . && mv id_rsa id_rsa_github_deploy_key
*Note: Make sure sensitive files are ignored in .gitignore file.
Create variables.json file using the template provided (variables-template.json)
$ cp variables-template.json variables.json
Edit the variables.json file with editor of your choice
$ nano variables.json
Your variables.json file should look like the following:
{
"database-name":"air-db",
"database-user-name":"", /* user-name of your choice for database */
"database-user-password":"", /*password for user of database*/
"database-root-password":"", /*password for root user of database*/
"databaseip":"", /*master databaseip*/
"databaseslaveip":"", /*slave databaseip*/
"webserverip":"", /*webserverip*/
"database-access-from-ip":"127.0.0.1",
"airdbmastervagrantboxname":"air-db-master",
"airwsvagrantboxname":"air-ws",
"airdbslavevagrantboxname":"air-db-slave"
}
As indicated above, don't forget to:
- Apecify user-name of your choice for database, password for that user of database, password for root user of database. Note: name of root user is 'root'
- Assign IP of webserver, master and slave databaseip
- Overall deploy time: ~ 50 minutes (over an hour in case of timeout or VBox Manager error)
- Build the slave database and add to vagrant box
$ packer build --var-file=./variables.json air-db-slave-ubuntu17101.json
...
$ vagrant box add ../build/Air-DB-Slave-virtualbox-[replace with your timestamp].box --name air-db-slave
- Build the master database and add master database to vagrant box
$ packer build --var-file=./variables.json air-db-master-ubuntu17101.json
...
$ vagrant box add ../build/Air-DB-Master-virtualbox-[replace with your timestamp].box --name air-db-master
- Build the webserver and add webserver to vagrant box
$ packer build --var-file=./variables.json air-ws-ubuntu17101.json
...
$ vagrant box add ../build/Air-WS-virtualbox-[replace with your timestamp].box --name air-ws
$ cd ../build/air-ws
$ vagrant up --provision