Skip to content

Commit fa819c0

Browse files
alexanderdeanfblundun
authored andcommitted
Added dedicated Vagrant setup (closes snowplow#312)
1 parent 3831528 commit fa819c0

9 files changed

Lines changed: 110 additions & 8 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ tags/tag.min.js
2525

2626
# creds for Grunt
2727
aws.json
28+
29+
# Vagrant
30+
.vagrant

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ With this tracker you can collect user event data (page views, e-commerce transa
2323

2424
### Contributing quickstart
2525

26+
Assuming git, [Vagrant] [vagrant-install] and [VirtualBox] [virtualbox-install] installed:
27+
2628
```
27-
git clone --recursive https://github.com/snowplow/dev-environment.git && cd dev-environment
28-
vagrant up && vagrant ssh
29-
ansible-playbook /vagrant/ansible-playbooks/snowplow-javascript-tracker.yml --inventory-file=/home/vagrant/ansible_hosts --connection=local
30-
cd /vagrant
31-
git clone https://github.com/snowplow/snowplow-javascript-tracker.git
32-
cd snowplow-javascript-tracker
33-
sudo npm install
29+
host$ git clone https://github.com/snowplow/snowplow-javascript-tracker.git
30+
host$ cd snowplow-javascript-tracker
31+
host$ vagrant up && vagrant ssh
32+
guest$ cd /vagrant
33+
guest$ sudo npm install
3434
```
3535

3636
Set up an `./aws.json` file using the example `./aws.sample.json`. If you just want to concat + minify without uploading then you don't need to fill out the `aws.json` file with valid credentials.
@@ -49,7 +49,11 @@ Significant portions of the Snowplow JavaScript Tracker copyright 2010 Anthon Pa
4949

5050
Licensed under the [Simplified BSD] [bsd] license.
5151

52-
[snowplow]: http://www.keplarllp.com/blog/2012/02/introducing-snowplow-the-worlds-most-powerful-web-analytics-platform
52+
[snowplow]: http://snowplowanalytics.com/
53+
54+
[vagrant-install]: http://docs.vagrantup.com/v2/installation/index.html
55+
[virtualbox-install]: https://www.virtualbox.org/wiki/Downloads
56+
5357
[piwik]: http://piwik.org/
5458
[piwikjs]: https://github.com/piwik/piwik/blob/master/js/piwik.js
5559
[piwikphp]: https://github.com/piwik/piwik/blob/master/piwik.php

Vagrantfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Vagrant.configure("2") do |config|
2+
3+
config.vm.box = "ubuntu/trusty64"
4+
config.vm.hostname = "snowplow-javascript-tracker"
5+
config.ssh.forward_agent = true
6+
7+
config.vm.provider :virtualbox do |vb|
8+
vb.name = Dir.pwd().split("/")[-1] + "-" + Time.now.to_f.to_i.to_s
9+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
10+
vb.customize [ "guestproperty", "set", :id, "--timesync-threshold", 10000 ]
11+
# node is not particularly memory hungry
12+
vb.memory = 1024
13+
end
14+
15+
config.vm.provision :shell do |sh|
16+
sh.path = "vagrant/up.bash"
17+
end
18+
19+
end

vagrant/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.peru
2+
oss-playbooks
3+
ansible

vagrant/ansible.hosts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[vagrant]
2+
127.0.0.1:2222

vagrant/peru.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
imports:
2+
ansible: ansible
3+
ansible_playbooks: oss-playbooks
4+
5+
curl module ansible:
6+
# Equivalent of git cloning tags/v1.6.6 but much, much faster
7+
url: https://codeload.github.com/ansible/ansible/zip/69d85c22c7475ccf8169b6ec9dee3ee28c92a314
8+
build: unzip ansible-69d85c22c7475ccf8169b6ec9dee3ee28c92a314.zip
9+
export: ansible-69d85c22c7475ccf8169b6ec9dee3ee28c92a314
10+
11+
git module ansible_playbooks:
12+
url: https://github.com/snowplow/ansible-playbooks.git
13+
# Comment out to fetch a specific rev instead of master:
14+
# rev: xxx

vagrant/up.bash

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e
3+
4+
vagrant_dir=/vagrant/vagrant
5+
bashrc=/home/vagrant/.bashrc
6+
7+
echo "========================================"
8+
echo "INSTALLING PERU AND ANSIBLE DEPENDENCIES"
9+
echo "----------------------------------------"
10+
apt-get update
11+
apt-get install -y language-pack-en git unzip libyaml-dev python3-pip python-yaml python-paramiko python-jinja2
12+
13+
echo "==============="
14+
echo "INSTALLING PERU"
15+
echo "---------------"
16+
sudo pip3 install peru
17+
18+
echo "======================================="
19+
echo "CLONING ANSIBLE AND PLAYBOOKS WITH PERU"
20+
echo "---------------------------------------"
21+
cd ${vagrant_dir} && peru sync -v
22+
echo "... done"
23+
24+
env_setup=${vagrant_dir}/ansible/hacking/env-setup
25+
hosts=${vagrant_dir}/ansible.hosts
26+
27+
echo "==================="
28+
echo "CONFIGURING ANSIBLE"
29+
echo "-------------------"
30+
touch ${bashrc}
31+
echo "source ${env_setup}" >> ${bashrc}
32+
echo "export ANSIBLE_HOSTS=${hosts}" >> ${bashrc}
33+
echo "... done"
34+
35+
echo "=========================================="
36+
echo "RUNNING PLAYBOOKS WITH ANSIBLE*"
37+
echo "* no output while each playbook is running"
38+
echo "------------------------------------------"
39+
while read pb; do
40+
su - -c "source ${env_setup} && ${vagrant_dir}/ansible/bin/ansible-playbook ${vagrant_dir}/${pb} --connection=local --inventory-file=${hosts}" vagrant
41+
done <${vagrant_dir}/up.playbooks
42+
43+
guidance=${vagrant_dir}/up.guidance
44+
45+
if [ -f ${guidance} ]; then
46+
echo "==========="
47+
echo "PLEASE READ"
48+
echo "-----------"
49+
cat $guidance
50+
fi

vagrant/up.guidance

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
To get started:
2+
vagrant ssh
3+
cd /vagrant
4+
sudo npm install

vagrant/up.playbooks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
oss-playbooks/java7.yml
2+
oss-playbooks/nodejs.yml
3+
oss-playbooks/grunt.yml

0 commit comments

Comments
 (0)