-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Only project- and language-specific ignores in here. Use global .gitignore for editors etc | ||
|
||
# Vagrant | ||
.vagrant/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: java | ||
|
||
jdk: | ||
- oraclejdk7 | ||
|
||
script: | ||
./ci/lint.bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Vagrant.configure("2") do |config| | ||
|
||
config.vm.box = "ubuntu/trusty64" | ||
config.ssh.forward_agent = true | ||
|
||
config.vm.provider :virtualbox do |vb| | ||
vb.name = Dir.pwd().split("/")[-1] + "-" + Time.now.to_f.to_i.to_s | ||
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | ||
vb.customize [ "guestproperty", "set", :id, "--timesync-threshold", 10000 ] | ||
# We don't need much memory for working with schemas | ||
vb.memory = 512 | ||
end | ||
|
||
# Requires Vagrant 1.7.0+ | ||
config.push.define "binary", strategy: "local-exec" do |push| | ||
push.script = "vagrant/push.bash" | ||
end | ||
|
||
config.vm.provision :shell do |sh| | ||
sh.path = "vagrant/up.bash" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Constants | ||
install_dir="/tmp" | ||
validator_v="2.2.6" | ||
validator_uri="https://bintray.com/artifact/download/fge/maven/com/github/fge/json-schema-validator/${validator_v}" | ||
validator_jar="json-schema-validator-${validator_v}-lib.jar" | ||
jsonschema_glob="schemas/*/*/jsonschema" | ||
|
||
# Similar to Perl die | ||
function die() { | ||
echo "$@" 1>&2 ; exit 1; | ||
} | ||
|
||
# Go to parent dir of this script | ||
function cd_script_parent() { | ||
source="${BASH_SOURCE[0]}" | ||
while [ -h "${source}" ] ; do source="$(readlink "${source}")"; done | ||
dir="$( cd -P "$( dirname "${source}" )/.." && pwd )" | ||
cd ${dir} | ||
} | ||
|
||
# Downloads and installs the full-fat XXX jarfile | ||
function install_validator() { | ||
if [ ! -f ${install_dir}/${validator_jar} ] ; then | ||
wget ${validator_uri}/${validator_jar} -P ${install_dir} | ||
fi | ||
echo "... done" | ||
} | ||
|
||
# Checks a single JSON Schema's syntax. | ||
# | ||
# Arguments: | ||
# 1. schema_path | ||
# 2. sucesses | ||
# 3. failures | ||
# 4. out_successes (out parameter) | ||
# 5. out_failures (out parameter) | ||
function check_syntax() { | ||
[ "$#" -eq 5 ] || die "5 arguments required, $# provided" | ||
local __schema_path=$1 | ||
local __successes=$2 | ||
local __failures=$3 | ||
local __out_successes=$4 | ||
local __out_failures=$5 | ||
|
||
set +e | ||
lint_out=`java -jar ${install_dir}/${validator_jar} --syntax ${1}` | ||
local lint_ok=${?} | ||
set -e | ||
if [ ${lint_ok} == "0" ] ; then | ||
echo "[ $(tput setaf 2)+$(tput sgr0) ] ${1}" | ||
eval $__out_successes="$((__successes+1))" | ||
else | ||
echo "[ $(tput setaf 1)x$(tput sgr0) ] ${1}" | ||
echo "" | ||
echo ${lint_out} | ||
echo "" | ||
eval ${__out_failures}="$((__failures+1))" | ||
fi | ||
} | ||
|
||
# Checks all schemas | ||
# | ||
# Arguments: | ||
# 1. out_status (out parameter) | ||
function check_schemas() { | ||
[ "$#" -eq 1 ] || die "1 argument required, $# provided" | ||
local __out_status=$1 | ||
|
||
successes=0 | ||
failures=0 | ||
schemas=`find ${jsonschema_glob} -type f` | ||
while read schema; do | ||
check_syntax ${schema} ${successes} ${failures} "successes" "failures" | ||
done <<< "${schemas}" | ||
echo "" | ||
echo "... JSON Schema syntax tests: $(tput setaf 2)${successes}$(tput sgr0) passed; $(tput setaf 1)${failures}$(tput sgr0) failed" | ||
if (( ${failures} > 0 )); then | ||
eval ${__out_status}="'1'" | ||
else | ||
eval ${__out_status}="'0'" | ||
fi | ||
} | ||
|
||
|
||
cd_script_parent | ||
|
||
echo "================================" | ||
echo "INSTALLING JSON SCHEMA VALIDATOR" | ||
echo "--------------------------------" | ||
|
||
install_validator | ||
|
||
echo "===================================" | ||
echo "CHECKING SYNTAX OF ALL JSON SCHEMAS" | ||
echo "-----------------------------------" | ||
|
||
check_schemas "check_status" | ||
exit ${check_status} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.peru | ||
oss-playbooks | ||
ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[vagrant] | ||
127.0.0.1:2222 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
imports: | ||
ansible: ansible | ||
ansible_playbooks: oss-playbooks | ||
|
||
curl module ansible: | ||
# Equivalent of git cloning tags/v1.6.6 but much, much faster | ||
url: https://codeload.github.com/ansible/ansible/zip/69d85c22c7475ccf8169b6ec9dee3ee28c92a314 | ||
build: unzip ansible-69d85c22c7475ccf8169b6ec9dee3ee28c92a314.zip | ||
export: ansible-69d85c22c7475ccf8169b6ec9dee3ee28c92a314 | ||
|
||
git module ansible_playbooks: | ||
url: https://github.com/snowplow/ansible-playbooks.git | ||
# Comment out to fetch a specific rev instead of master: | ||
# rev: xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
s3_bucket=iglucentral.com | ||
|
||
# Get the parent directory of where this script is. | ||
source="${BASH_SOURCE[0]}" | ||
while [ -h "${source}" ] ; do source="$(readlink "${source}")"; done | ||
dir="$( cd -P "$( dirname "${source}" )/.." && pwd )" | ||
cd ${dir} | ||
|
||
# Note - this runs on HOST: https://groups.google.com/forum/#!topic/vagrant-up/LgqE-JFAqZc | ||
aws s3 cp schemas/ s3://${s3_bucket}/schemas/ --include "*.*" --recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
vagrant_dir=/vagrant/vagrant | ||
bashrc=/home/vagrant/.bashrc | ||
|
||
echo "========================================" | ||
echo "INSTALLING PERU AND ANSIBLE DEPENDENCIES" | ||
echo "----------------------------------------" | ||
apt-get update | ||
apt-get install -y language-pack-en git unzip libyaml-dev python3-pip python-yaml python-paramiko python-jinja2 | ||
|
||
echo "===============" | ||
echo "INSTALLING PERU" | ||
echo "---------------" | ||
sudo pip3 install peru | ||
|
||
echo "=======================================" | ||
echo "CLONING ANSIBLE AND PLAYBOOKS WITH PERU" | ||
echo "---------------------------------------" | ||
cd ${vagrant_dir} && peru sync -v | ||
echo "... done" | ||
|
||
env_setup=${vagrant_dir}/ansible/hacking/env-setup | ||
hosts=${vagrant_dir}/ansible.hosts | ||
|
||
echo "===================" | ||
echo "CONFIGURING ANSIBLE" | ||
echo "-------------------" | ||
touch ${bashrc} | ||
echo "source ${env_setup}" >> ${bashrc} | ||
echo "export ANSIBLE_HOSTS=${hosts}" >> ${bashrc} | ||
echo "... done" | ||
|
||
echo "==========================================" | ||
echo "RUNNING PLAYBOOKS WITH ANSIBLE*" | ||
echo "* no output while each playbook is running" | ||
echo "------------------------------------------" | ||
while read pb; do | ||
su - -c "source ${env_setup} && ${vagrant_dir}/ansible/bin/ansible-playbook ${vagrant_dir}/${pb} --connection=local --inventory-file=${hosts}" vagrant | ||
done <${vagrant_dir}/up.playbooks | ||
|
||
guidance=${vagrant_dir}/up.guidance | ||
|
||
if [ -f ${guidance} ]; then | ||
echo "===========" | ||
echo "PLEASE READ" | ||
echo "-----------" | ||
cat $guidance | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
To get started: | ||
vagrant ssh | ||
cd /vagrant | ||
xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
oss-playbooks/java7.yml |