Skip to content

Commit

Permalink
Merge pull request #21 from iRail/development
Browse files Browse the repository at this point in the history
Berkshelf provisioning - Fix #13 #14
  • Loading branch information
brechtvdv committed Jun 2, 2015
2 parents 672f5b5 + 0e290e1 commit 18e32f2
Show file tree
Hide file tree
Showing 50 changed files with 12,965 additions and 815 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/bootstrap/compiled.php
.env.*.php
.env.php
/cookbooks
/tmp
.vagrant/
Cheffile.lock
Berksfile.lock
berks-cookbooks/
/tdt/

12 changes: 12 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source "https://supermarket.getchef.com"

cookbook 'apache2', '~> 3.0.1'
cookbook 'apt', '~> 2.6.1'
cookbook 'build-essential', '~> 2.1.3'
cookbook 'composer', '~> 2.0.0'
cookbook 'git', '~> 4.1.0'
cookbook 'mysql', '~> 6.0.15'
cookbook 'nodejs', '~> 2.2.0'
cookbook 'npm', '~> 0.1.2'
cookbook 'php', '~> 1.5.0'
cookbook 'python', '~> 1.4.6'
19 changes: 0 additions & 19 deletions Cheffile

This file was deleted.

53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,59 @@
# gtfs-tdt
Loads GTFS into MySQL and serves next departures and arrivals at a certain stop from The DataTank
GTFS-TDT
========

# Setup Vagrant
Loads GTFS into MySQL and serves next departures and arrivals at a certain stop from The DataTank.

First step is to install Vagrant and Virtualbox.
See: http://docs.vagrantup.com/v2/getting-started/index.html
Requirements:
-------------

Also Chef Development Kit is needed:
See: https://downloads.chef.io/
* Virtualbox
* Vagrant >= 1.7.0
* vagrant-omnibus plugin

Next, install Vagrant Librarian so Chef runs automatically
Installation:
-------------

`vagrant plugin install vagrant-librarian-chef`
Download and install [VirtualBox](http://www.virtualbox.org/)

Our custom cookbooks are located in vendor/cookbooks.
Librarian fetches all the community cookbook dependencies into it's own directory cookbooks.
Download and install [vagrant](http://vagrantup.com/)

Add The Datatank-ip and -hostname to your hosts-file:
Install [vagrant-omnibus](https://github.com/chef/vagrant-omnibus) plugin

192.168.70.70 tdt.hub.dev
$ vagrant plugin install vagrant-omnibus

Clone this repository

# Run
Go to the repository folder and launch the box

`vagrant up [ tdt | db ]`
$ cd [repo]
$ berks vendor
$ vagrant up

# Acces server
Add The Datatank-ip and -hostname to your hosts-file:

`vagrant ssh db`
192.168.70.70 tdt.hub.dev

`vagrant ssh tdt`
Load datasources:
-----------------

# Load Datasources
Currently are De Lijn and MivbStib included.
Datasources are located in the datasources-folder.

For this example we're going to add De Lijn-datasource. Same principle for MivbStib.

## Run script
This will load all the data.
### Acces server

`vagrant ssh`

SSH into the db-environment:
`vagrant ssh db`
### Load data

Go to De Lijn datasources-folder:
`cd /vagrant/datasources/delijn`

Execute init.sh:
`./init.sh`

## Install resource into TDT
### Install resource into The DataTank
Go to tdt.hub.dev/api/admin in your favourite browser.
Default credentials are:
user: admin
Expand Down
130 changes: 38 additions & 92 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,105 +3,51 @@

tdt_ip = "192.168.70.70"
tdt_hostname = "tdt.hub.dev"
db_ip = "192.168.70.71"

VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.7.0"

WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) ? true : false
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "chef/ubuntu-14.04"

# This is the machine containing the databases
config.vm.define "db" do |db|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
db.vm.box = "ubuntu/trusty64"

# Configurate the virtual machine to use 2GB of RAM
db.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end

db.vm.network :private_network, ip: db_ip
db.vm.hostname = "db"

# Use Chef Solo to provision our virtual machine
db.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "vendor/cookbooks"]

chef.add_recipe "apt"
chef.add_recipe "curl"
chef.add_recipe "tmux"
chef.add_recipe "vim"
chef.add_recipe "git"
chef.add_recipe "build-essential"

chef.add_recipe "db"

# chef debug level, start vagrant like this to debug:
# $ CHEF_LOG_LEVEL=debug vagrant <provision or up>
chef.log_level = ENV['CHEF_LOG'] || "info"

host_ip = db_ip[/(.*\.)\d+$/, 1] + "1"

chef.json = {
:host_ip => host_ip,
:xdebug_enabled => true,
:xdebug_remote_enable => "1",
:xdebug_remote_port => "9000",
:xdebug_profiler_output_dir => "/vagrant/xdebug",
:xdebug_trace_output_dir => "/vagrant/xdebug",
}
end
if Vagrant.has_plugin? 'vagrant-omnibus'
# Set Chef version for Omnibus
config.omnibus.chef_version = :latest
else
raise Vagrant::Errors::VagrantError.new,
"vagrant-omnibus missing, please install the plugin:\n" +
"vagrant plugin install vagrant-omnibus"
end

# This is the machine container a The DataTank installation
config.vm.define "tdt" do |tdt|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
tdt.vm.box = "ubuntu/trusty64"

# Configurate the virtual machine to use 2GB of RAM
tdt.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end

# tdt.vm.synced_folder ".", "/vagrant", :nfs => !WINDOWS
tdt.vm.synced_folder ".", "/vagrant", type: "nfs"

tdt.vm.network :private_network, ip: tdt_ip
tdt.vm.hostname = tdt_hostname

# Use Chef Solo to provision our virtual machine
tdt.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "vendor/cookbooks"]

chef.add_recipe "apt"
chef.add_recipe "curl"
chef.add_recipe "git"
chef.add_recipe "vim"
chef.add_recipe "php"
chef.add_recipe "nodejs"
chef.add_recipe "memcached"
chef.add_recipe "apache2"
chef.add_recipe "build-essential"
chef.add_recipe "openssl"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network :private_network, ip: tdt_ip
config.vm.hostname = tdt_hostname

# Use NFS for the shared folder
config.vm.synced_folder ".", "/vagrant", type: "nfs"

# Provider-specific configuration so you can fine-tune VirtualBox for Vagrant.
# These expose provider-specific options.
config.vm.provider :virtualbox do |vb|
# Use VBoxManage to customize the VM.
# For example to change memory or number of CPUs:
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
end

chef.add_recipe "tdt"
# Enable provisioning with chef zero, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
config.vm.provision :chef_zero do |chef|
chef.cookbooks_path = ["berks-cookbooks", "cookbooks"]

# chef debug level, start vagrant like this to debug:
# $ CHEF_LOG_LEVEL=debug vagrant <provision or up>
chef.log_level = ENV['CHEF_LOG'] || "info"

host_ip = tdt_ip[/(.*\.)\d+$/, 1] + "1"

chef.json = {
:host_ip => host_ip,
:host_name => tdt_hostname,
:xdebug_enabled => true,
:xdebug_remote_enable => "1",
:xdebug_remote_port => "9000",
:xdebug_profiler_output_dir => "/vagrant/xdebug",
:xdebug_trace_output_dir => "/vagrant/xdebug"
}
end
# List of recipes to run
chef.add_recipe "the_datatank"
# chef.add_recipe "the_datatank::nodejs"
end
end
12 changes: 12 additions & 0 deletions cookbooks/the_datatank/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Description
===========

Requirements
============

Attributes
==========

Usage
=====

22 changes: 22 additions & 0 deletions cookbooks/the_datatank/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
override['mysql']['version'] = '5.5'
override['mysql']['port'] = '3306'
override['mysql']['socket'] = '/var/run/mysqld/mysqld.sock'
override['mysql']['initial_root_password'] = 'root'

default['tdt']['user'] = 'root'
default['tdt']['group'] = 'root'

default['tdt']['name'] = 'tdt'
default['tdt']['config'] = 'tdt.conf'

default['apache']['docroot_dir'] = '/vagrant/tdt/public'

override['nodejs']['install_method'] = 'binary'
override['nodejs']['version'] = '0.12.0'
override['nodejs']['source']['checksum'] = '9700e23af4e9b3643af48cef5f2ad20a1331ff531a12154eef2bfb0bb1682e32'
override['nodejs']['binary']['checksum']['linux_x64'] = '3bdb7267ca7ee24ac59c54ae146741f70a6ae3a8a8afd42d06204647fe9d4206'
override['nodejs']['binary']['checksum']['linux_x86'] = 'd4130512228439bf9115b7057fe145b095c1e49fa8e62c8d3e192b3dd3fe821b'

override['npm']['version'] = '2.7.4'

include_attribute 'the_datatank::php'
7 changes: 7 additions & 0 deletions cookbooks/the_datatank/attributes/php.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 14.04
override['php']['ext_conf_dir'] = '/etc/php5/mods-available'
end
else
end
18 changes: 18 additions & 0 deletions cookbooks/the_datatank/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name "the_datatank"
maintainer "brechtvdv"
maintainer_email "[email protected]"
license "MIT"
description "Configures vagrant virtual machine with the datatank installed"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.1"

depends "apache2"
depends "apt"
depends "build-essential"
depends "composer"
depends "git"
depends "mysql"
depends "nodejs"
depends "npm"
depends "php"
depends "python"
Loading

0 comments on commit 18e32f2

Please sign in to comment.