Skip to content

Commit 42b5e5f

Browse files
fblundunalexanderdean
authored andcommitted
Added dedicated Vagrant setup (closes snowplow#127)
1 parent c4d1f40 commit 42b5e5f

11 files changed

Lines changed: 112 additions & 6 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ nosetests.xml
3636
.mr.developer.cfg
3737
.project
3838
.pydevproject
39+
40+
# Vagrant
41+
.vagrant

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Added integration tests using mocked POST requests (#122)
1212
Started preserving unicode characters in JSONs (#123)
1313
Used Travis CI image for master branch in README (#125)
1414
Added license button to README (#126)
15+
Added dedicated Vagrant setup (#127)
1516

1617
Version 0.5.0 (2014-08-13)
1718
--------------------------

README.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ Find out more
4949
Contributing quickstart
5050
#######################
5151

52+
Assuming Git, Vagrant_ and VirtualBox_ are installed:
53+
5254
::
55+
host$ git clone git@github.com:snowplow/snowplow-python-tracker.git
56+
host$ vagrant up && vagrant ssh
57+
guest$ cd /vagrant
58+
guest$ ./run-tests.sh
5359

54-
guest$ git clone --recursive https://github.com/snowplow/dev-environment.git && cd dev-environment
55-
guest$ vagrant up && vagrant ssh
56-
host$ ansible-playbook /vagrant/ansible-playbooks/snowplow-python-tracker.yml --inventory-file=/home/vagrant/ansible_hosts --connection=local
57-
host$ /vagrant/snowplow-python-tracker/run-tests.sh
60+
.. _Vagrant: http://docs.vagrantup.com/v2/installation/index.html
61+
.. _VirtualBox: https://www.virtualbox.org/wiki/Downloads
5862

5963
Copyright and license
6064
#####################

Vagrantfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Vagrant.configure("2") do |config|
2+
3+
config.vm.box = "ubuntu/trusty64"
4+
config.vm.hostname = "snowplow-python-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+
vb.memory = 2048
12+
end
13+
14+
config.vm.provision :shell do |sh|
15+
sh.path = "vagrant/up.bash"
16+
end
17+
18+
end

run-tests.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#!/bin/sh
22
# Run the Snowplow Tracker test suite.
33

4+
# Quit on failure
5+
set -e
6+
47
# Need to execute from this dir
58
cd $(dirname $0)
69

710
# pytest because it has a neat output
811

9-
/vagrant/snowplow-python-3.3-tracker-environment/bin/python3.3 -m pytest -s
12+
# Test against Python 3
13+
~/snowplow-python-3.3-tracker-environment/bin/python3.3 -m pytest -s
14+
15+
# Test against Python 2
16+
~/snowplow-python-2.7-tracker-environment/bin/python2.7 -m pytest -s
1017

11-
/vagrant/snowplow-python-2.7-tracker-environment/bin/python2.7 -m pytest -s

vagrant/.gitignore

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

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+
./run-tests.sh

0 commit comments

Comments
 (0)