Vagrant UBUNTU 16.04 lamp using Ansible playbook + Orchard QA, API, ALW Ansible deploy roles
=================================================

# Create OA, ALW, API Ansible for Orchard Dev Box 

1. Install Ansible on your local machine (or use vagrant box, see  LAMP setup. Ansible already installed on box)
2. Сopy your ssh key into ansible\files\ssh\aws\ with name: private
3. Copy your private git key into ansible\files\ssh\git\ with name: git_key
4. Create config file in folder config\ with name: config_dev.yml as example you can use \config\config_dev_example.yml
5. Copy dev.shadow into dev in ansible\hosts\ and update your host where you want the environment to be installed.
6. In folder ansible\ run: ansible-playbook -i hosts/dev webserver_dev.yml -vv

# LAMP setup with Vagrant & Ansible #

----------

An out of the box solution for a Apache2 + PHP + MySQL, Ubuntu 16.04 is installed with the following packages:

- Apache2
- Composer
- Git
- PHP5.6-FPM
- PHP7-FPM
- All common packages
- Orchard OA, Workstation, VAPI, API and their configuration

## Vagrant First Run ##

Important, before start working with your machine do next steps:

### WINDOWS ###
0. Install softwarte on your general OS:
- Vagrant 1.6.*
- Virtualbox 4.3.*
- Rsync (better to install cygwin with rsync, ssh packages, don't forget to add in OS PATH variable folder with packages)
1. Open folder share and clone API (https://github.com/theorchard/api) repository, Orchard (https://github.com/theorchard/orchard) repository into it. You should have 
orchard, api folders inside share with all code from repositories.
2. Add your git key into (./ansible/files/ssh/git/) with name "git_key"
3. Fill in your config file  (./config/config_local_dev.yml) with using example ./config/config_local_dev_example.yml , see sections with // name of config value //
5. Open folder where this README file is and run in CMD:
vagrant up
If you see something in red in console output - please, right down responsible for env persons.
6. add in c:\windows\system32\drivers\etc\hosts new line:  
10.0.0.10 ws.orchard oa.orchard orchardvapi.192.168.99.100.xip.io 
7. Open in your browser 10.0.0.10  if you see phpinfo page - it's a good sign.
9. Try to open ws.orchard, oa.orchard links.

### MACOS ###

0. Install softwarte on your general OS:
- Vagrant 1.6.*
- Virtualbox 4.3.*
- Rsync (better to install cygwin with rsync, ssh packages, don't forget to add in OS PATH variable folder with packages)
1. Open folder share and clone API (https://github.com/theorchard/api) repository, Orchard (https://github.com/theorchard/orchard) repository into it. You should have 
orchard, api folders inside share with all code from repositories.
2. Add your git key into (./ansible/files/ssh/git/) with name "git_key"
3. Fill in your config file  (./config/config_local_dev.yml) with using example ./config/config_local_dev_example.yml , see sections with // name of config value //
5. Open folder where this README file is and run in terminal:
vagrant up
If you see something in red in console output - please, right down responsible for env persons.
6. add in /etc/hosts new line:  
10.0.0.10 ws.orchard oa.orchard orchardvapi.192.168.99.100.xip.io 
7. Open in your browser 10.0.0.10  if you see phpinfo page - it's a good sign.
9. Try to open ws.orchard, oa.orchard links.

### UBUNTU ###
0. create folder /var/www/html
1. git clone API (https://github.com/theorchard/api) repository, Orchard (https://github.com/theorchard/orchard) repository into /var/www/html. 
You should have orchard, api folders inside /var/www/html with all code from repositories.
2. Open folder where this README file is and run this command:  
2. Add your git key into (./ansible/files/ssh/git/) with name "git_key"
3. Fill in your config file  (./config/config_local_dev.yml) with using example ./config/config_local_dev_example.yml , see sections with // name of config value //
5. Open folder where this README file is, cd ansibl, run in terminal:
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml 
6. add in /etc/hosts new line:  
127.0.0.1 ws.orchard oa.orchard orchardvapi.192.168.99.100.xip.io 
7. Open in your browser 127.0.0.1  if you see phpinfo page - it's a good sign.
9. Try to open ws.orchard, oa.orchard links.

## Notes ##
To ssh your local machine, to see IP and port, type in console vagrant ssh.

# Ansible
To start any script from your VM, ssh your vm. and run inside /vagrant/ansible (in case of the ubuntu cd folder where this readme is, cd ansible)
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml

## Folders
- config 

This folder used for configuration files per environment and global config (e.g. xdebug)

- ansible

In this folder you should start running playbooks. Playbooks can be found in this folder, check needed for your environment.

- ansible/roles

This folder contain roles that will be started during deploy or server install process 

- ansible/files/vhost

Here located vhost templates for nginx

- ansible/files/ssh

Folder for ssh keys.

!IMPORTANT: Keys shouldn't be pushed in git repository!

# Useful commands:
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml --tags="orchard-app-init"
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml --tags="orchard-api-init"
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml --tags="orchard-app-init-configs"
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml --tags="orchard-api-init-configs"
sudo ansible-playbook -i hosts/local ubuntu_webserver_local_dev.yml --tags="vhost"
## UPDATE orchard oa, alw
sudo ansible-playbook -i hosts/dev webserver_dev.yml --tags="orchard-api-git,orchard-app-git,orchard-app-init-configs,orchard-app-init-configs"
## UPDATE frontend-accounting-reserves
sudo ansible-playbook -i hosts/dev microservices_dev.yml --tags="orchard-frontend-accounting-reserves-git,orchard-frontend-accounting-reserves-init"

