- VirtualBox (v5.1)
- Vagrant (v1.9.x)
- Ansible (Latest version)
# Virtual Box
yum install VirtualBox-5.1
# Vagrant
wget https://releases.hashicorp.com/vagrant/1.9.7/vagrant_1.9.7_x86_64.rpm?_ga=2.84851217.96389612.1501508263-357158161.1501087142
yum install vagrant_1.9.7_x86_64.rpm
# Ansible
yum install ansible
pacman -Syu ansible virtualbox vagrant
brew install virtualbox
brew install vagrant
brew install ansible
You can develop the app on your computer. Vagrant watch the changes in the dev/synced_folder
and notify nodemon
to restart the modified app.
git clone --recursive [email protected]:mangal-wg/mangal-vagrant.git
# If you haven't set your own SSH key
git clone --recursive https://github.com/mangal-wg/mangal-vagrant.git
cd mangal-vagrant/dev
Don't forget to install the npm
dependencies:
cd mangal-vagrant/dev/synced_folder
npm install ./mangal-api
npm install ./orcid-oauth2
cd mangal-vagrant/dev/
vagrant up --provision
# Ansible will ask the password to desencrypt ./vars/secret.yml
# and runs the procedure to setup the VM's environment and install dependencies
vagrant ssh # Reach the vm
cd mangal-vagrant/dev/
vagrant ssh
# The apps are running at the location /var/mangal/ which belongs to the user: mangal
# To monitor the apps (logs, status etc.)
sudo su - mangal
ls -la
pm2 status
pm2 logs
pm2 monit
# see other pm2 command line: http://pm2.keymetrics.io/docs/usage/quick-start/#cheat-sheet
# logs from nginx at /var/log/nginx
cd mangal-vagrant/dev/
vagrant ssh
## Connect to postgreSQL as postgres user
sudo su - postgres
psql -d mangal_dev
If you want to have direct access to the logs for each apps with nodemon
using tmux
:
cd mangal-vagrant/dev/
vagrant ssh
mux
The app will be deploy on the server directly from your computer
Make sure you install ansible on your own computer and registered your public key on the server (ssh-copy-id
). After that, you can run the following command lines:
cd mangal-vagrant/staging
ansible-playbook playbook.yml --user=tpoisot/sviss -i host.ini --vault-id .vault-pass --ask-sudo-pass
The host.ini
contains the address of the server and .vault-pass
file, the vault password used to desencrypt vars/secret.yml
(sensitive informations).
This command line will install and setup on the server:
- postgresql
- pm2
- nodejs
- nginx
- services and permissions
All about the procedure is describe in staging/playbook.yml
You can test the deployment script locally before sending it to the staging server.
git clone --recursive [email protected]:mangal-wg/mangal-vagrant.git
cd mangal-vagrant/staging
vagrant up --provision
cd mangal-vagrant/staging
ssh-copy-id username@addrsrv
ansible-playbook playbook.yml --user=username -i host.ini --vault-id .vault-pass --ask-sudo-pass