Skip to content

Commit 0d12544

Browse files
committed
expanded sandbox capabilities
1 parent e65c5d6 commit 0d12544

File tree

26 files changed

+280
-148
lines changed

26 files changed

+280
-148
lines changed

Vagrantfile

+110-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,116 @@
11
# -*- mode: ruby -*-
22
# vi: set ft=ruby :
33

4-
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
54
VAGRANTFILE_API_VERSION = "2"
5+
VAGRANT_OS = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
6+
VAGRANT_SYNC_FOLDER = "../"
7+
VAGRANT_HOSTNAME = "sandbox"
8+
VAGRANT_MEMORY = "1024"
9+
10+
PHP_IP = "192.168.56.200"
11+
JAVA_IP = "192.168.56.201"
12+
NODEJS_IP = "192.168.56.202"
13+
PYTHON_IP = "192.168.56.203"
14+
RUBY_IP = "192.168.56.204"
15+
616

717
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8-
config.vm.box = "ubuntu64-trusty"
9-
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
10-
config.vm.network :private_network, ip: "192.168.56.200"
11-
config.vm.synced_folder "../", "/home/vagrant/workspace/"
12-
config.vm.hostname = "sandbox"
13-
config.vbguest.no_remote = false
14-
15-
config.vm.provider :virtualbox do |vb|
16-
vb.name = "Sandbox"
17-
vb.gui = false
18-
vb.customize ["modifyvm", :id, "--memory", "1024"]
19-
end
20-
21-
# Enable Ansible
22-
config.vm.provision "ansible" do |ansible|
23-
ansible.verbose = "v"
24-
ansible.playbook = "provisioning/playbook.yml"
25-
ansible.inventory_path = "vagrant-inventory"
26-
ansible.host_key_checking = "false"
27-
ansible.limit = 'all'
28-
end
29-
end
18+
config.vm.box = "ubuntu64-trusty"
19+
config.vm.box_url = VAGRANT_OS
20+
config.vm.synced_folder VAGRANT_SYNC_FOLDER, "/home/vagrant/workspace/"
21+
config.vm.hostname = VAGRANT_HOSTNAME
22+
config.vbguest.no_remote = false
23+
24+
config.vm.provider :virtualbox do |vb|
25+
vb.name = "Sandbox"
26+
vb.gui = false
27+
vb.customize ["modifyvm", :id, "--memory", VAGRANT_MEMORY]
28+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
29+
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
30+
end
31+
32+
config.vm.define "php" do |php|
33+
php.vm.box = "php"
34+
php.vm.network :private_network, ip: PHP_IP
35+
36+
php.vm.provider :virtualbox do |vb|
37+
vb.name = "Sandbox-PHP"
38+
end
39+
40+
php.vm.provision "ansible" do |ansible|
41+
ansible.verbose = "v"
42+
ansible.playbook = "provisioning/playbook-php.yml"
43+
ansible.inventory_path = "vagrant-inventory"
44+
ansible.host_key_checking = false
45+
ansible.limit = "php"
46+
end
47+
end
48+
49+
config.vm.define "nodejs" do |nodejs|
50+
nodejs.vm.box = "nodejs"
51+
nodejs.vm.network :private_network, ip: PHP_IP
52+
53+
nodejs.vm.provider :virtualbox do |vb|
54+
vb.name = "Sandbox-NodeJS"
55+
end
56+
57+
nodejs.vm.provision "ansible" do |ansible|
58+
ansible.verbose = "v"
59+
ansible.playbook = "provisioning/playbook-nodejs.yml"
60+
ansible.inventory_path = "vagrant-inventory"
61+
ansible.host_key_checking = false
62+
ansible.limit = "nodejs"
63+
end
64+
65+
end
66+
config.vm.define "java" do |java|
67+
java.vm.box = "java"
68+
java.vm.network :private_network, ip: JAVA_IP
69+
70+
java.vm.provider :virtualbox do |vb|
71+
vb.name = "Sandbox-Java"
72+
end
73+
74+
java.vm.provision "ansible" do |ansible|
75+
ansible.verbose = "v"
76+
ansible.playbook = "provisioning/playbook-java.yml"
77+
ansible.inventory_path = "vagrant-inventory"
78+
ansible.host_key_checking = false
79+
ansible.limit = "java"
80+
end
81+
end
82+
83+
config.vm.define "python" do |python|
84+
python.vm.box = "python"
85+
python.vm.network :private_network, ip: PYTHON_IP
86+
87+
python.vm.provider :virtualbox do |vb|
88+
vb.name = "Sandbox-Python"
89+
end
90+
91+
python.vm.provision "ansible" do |ansible|
92+
ansible.verbose = "v"
93+
ansible.playbook = "provisioning/playbook-python.yml"
94+
ansible.inventory_path = "vagrant-inventory"
95+
ansible.host_key_checking = false
96+
ansible.limit = "python"
97+
end
98+
end
99+
100+
config.vm.define "ruby" do |ruby|
101+
ruby.vm.box = "python"
102+
ruby.vm.network :private_network, ip: PYTHON_IP
103+
104+
ruby.vm.provider :virtualbox do |vb|
105+
vb.name = "Sandbox-Ruby"
106+
end
107+
108+
ruby.vm.provision "ansible" do |ansible|
109+
ansible.verbose = "v"
110+
ansible.playbook = "provisioning/playbook-ruby.yml"
111+
ansible.inventory_path = "vagrant-inventory"
112+
ansible.host_key_checking = false
113+
ansible.limit = "ruby"
114+
end
115+
end
116+
end

provisioning/playbook-java.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- hosts: java
3+
user: vagrant
4+
sudo: yes
5+
roles:
6+
- common
7+
- mariadb
8+
- java
9+
- apache

provisioning/playbook-nodejs.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- hosts: nodejs
3+
user: vagrant
4+
sudo: yes
5+
roles:
6+
- common
7+
- mariadb
8+
- nodejs
9+
- apache

provisioning/playbook-php.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- hosts: php
3+
user: vagrant
4+
sudo: yes
5+
roles:
6+
- common
7+
- mariadb
8+
- php
9+
- apache

provisioning/playbook-python.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- hosts: python
3+
user: vagrant
4+
sudo: yes
5+
roles:
6+
- common
7+
- mariadb
8+
- python
9+
- apache

provisioning/playbook-ruby.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- hosts: ruby
3+
user: vagrant
4+
sudo: yes
5+
roles:
6+
- common
7+
- mariadb
8+
- ruby
9+
- nginx

provisioning/playbook.yml

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- name: restart apache
3+
service: name=apache2 state=restarted enable=yes
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
3+
- name: Install Sandbox Packages
4+
apt: pkg={{ item }} state=latest update_cache=yes
5+
with_items:
6+
- apache2
7+
- libapache2-mod-gnutls
8+
9+
- name: Disable mod_ssl
10+
command: a2dismod ssl
11+
12+
- name: Activate Apache modules
13+
command: a2enmod rewrite deflate expires env headers setenvif gnutls
14+
15+
- name: Generate SnakeOil Certificates
16+
command: make-ssl-cert generate-default-snakeoil --force-overwrite
17+
18+
- name: Deactivate default vhost
19+
command: a2dissite 000-default.conf
20+
21+
- name: Copy Apache Default Server conf over
22+
copy: src=server dest=/etc/apache2/conf-available/server.conf
23+
24+
- name: Activate Server Conf
25+
command: a2enconf server.conf
26+
27+
- name: Set Apache Runtime Envvars
28+
lineinfile: dest=/etc/apache2/envvars regexp='(export APACHE_RUN_{{item}}=www-data|export APACHE_RUN_{{item}}=vagrant)' line='export APACHE_RUN_{{item}}=vagrant' state=present
29+
with_items:
30+
- USER
31+
- GROUP
32+
notify:
33+
- restart apache
34+
35+
- name: Copy sandbox site control
36+
copy: src={{item}} dest=/usr/local/bin/ owner=root mode=0755
37+
with_items:
38+
- attach-site
39+
- detach-site
40+
41+
- name: Create Locate DB
42+
command: updatedb
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
- name: Add Vagrant User to Admin Group
3+
command: usermod -aG adm vagrant
4+
5+
- name: Update Server Package List
6+
apt: update_cache=yes
7+
8+
- name: Upgrade Server Packages
9+
apt: upgrade=full
10+
11+
- name: Add Postfix setting to Set Selections
12+
command: debconf-set-selections <<< "{{item}}"
13+
with_items:
14+
- postfix postfix/mailname string sandbox.creatingit.co.uk
15+
- postfix postfix/main_mailer_type string 'Internet Site'
16+
17+
18+
- name: Install Commoon Packages
19+
apt: pkg={{ item }} state=latest update_cache=yes
20+
with_items:
21+
- ruby-sass
22+
- nodejs
23+
- python-nltk
24+
- python-sphinx
25+
- python-software-properties
26+
- libpcre3-dev
27+
- libcv2.4
28+
- libcv-dev
29+
- build-essential
30+
- vim
31+
- git
32+
- subversion
33+
- tree
34+
- postfix
35+
- curl
36+
37+
- name: Create Locate DB
38+
command: updatedb
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- name: Install Java Packages
3+
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Add apt repository
3+
apt_repository: repo='ppa:nginx/stable' update_cache=yes
4+
apt-key: id=C300EE8C url=https://keyserver.ubuntu.com state=present
5+
6+
7+
- name: Install Nginx
8+
apt: pkg={{ item }} state=latest update_cache=yes
9+
with_items:
10+
- nginx
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Install NodeJS Packages
3+
apt: pkg={{ item }} state=latest update_cache=yes
4+
with_items:
5+
- npm
6+

provisioning/roles/sandbox/tasks/main.yml renamed to provisioning/roles/php/tasks/main.yml

+1-67
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
---
2-
- name: Add Vagrant User to Admin Group
3-
command: usermod -aG adm vagrant
4-
5-
- name: Update Server Package List
6-
apt: update_cache=yes
7-
8-
- name: Upgrade Server Packages
9-
apt: upgrade=full
10-
11-
- name: Install Sandbox Packages
2+
- name: Install PHP Packages
123
apt: pkg={{ item }} state=latest update_cache=yes
134
with_items:
14-
- apache2
15-
- libapache2-mod-gnutls
165
- php5
176
- php5-dev
187
- php5-cli
@@ -31,49 +20,6 @@
3120
- php5-memcache
3221
- php5-memcached
3322
- php-pear
34-
- ruby-sass
35-
- nodejs
36-
- python-nltk
37-
- python-sphinx
38-
- libpcre3-dev
39-
- libcv2.4
40-
- libcv-dev
41-
- build-essential
42-
- vim
43-
- git
44-
- subversion
45-
- memcached
46-
- tree
47-
48-
- name: Disable mod_ssl
49-
command: a2dismod ssl
50-
51-
- name: Activate Apache modules
52-
command: a2enmod rewrite deflate expires env headers setenvif gnutls
53-
54-
- name: Generate SnakeOil Certificates
55-
command: make-ssl-cert generate-default-snakeoil --force-overwrite
56-
57-
- name: Deactivate default vhost
58-
command: a2dissite 000-default.conf
59-
60-
- name: Copy Apache Default Server conf over
61-
copy: src=server dest=/etc/apache2/conf-available/server.conf
62-
63-
- name: Activate Server Conf
64-
command: a2enconf server.conf
65-
66-
- name: Set Apache Runtime Envvars
67-
lineinfile: dest=/etc/apache2/envvars regexp='(export APACHE_RUN_{{item}}=www-data|export APACHE_RUN_{{item}}=vagrant)' line='export APACHE_RUN_{{item}}=vagrant' state=present
68-
with_items:
69-
- USER
70-
- GROUP
71-
72-
- name: Copy sandbox site control
73-
copy: src={{item}} dest=/usr/local/bin/ owner=root mode=0755
74-
with_items:
75-
- attach-site
76-
- detach-site
7723

7824
- name: Set PHP timezone
7925
lineinfile: dest={{item}}.ini regexp='(;date.timezone =|date.timezone = "Europe/London")' line='date.timezone = "Europe/London"' state=present
@@ -173,15 +119,3 @@
173119
with_items:
174120
- wget http://codeception.com/codecept.phar
175121
- mv codecept.phar /usr/local/bin/codecept
176-
177-
- name: Add Postfix setting to Set Selections
178-
command: debconf-set-selections <<< "{{item}}"
179-
with_items:
180-
- postfix postfix/mailname string sandbox.creatingit.co.uk
181-
- postfix postfix/main_mailer_type string 'Internet Site'
182-
183-
- name: Install Postfix
184-
apt: pkg=postfix state=latest
185-
186-
- name: Create Locate DB
187-
command: updatedb

0 commit comments

Comments
 (0)