farmstead 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e1df587d3b56929d7653dce3390aa4f922b22ef
4
- data.tar.gz: 8fb5e6d98a604de22b7a3c5c2875b21e285e4b22
3
+ metadata.gz: a48f6cae9255db1d2658632a100ca2b688fafc36
4
+ data.tar.gz: b23ff09549e56cc94d3765336d5cfd0ca5e02db9
5
5
  SHA512:
6
- metadata.gz: 6035576a3faa7e02b27830876c5e099c63069cfd9c1d7a046642cd45613985aac0416ed0ad70b99d71ba5aa93bd74a0cb534d20a8e9815b935f2c464028ba2ab
7
- data.tar.gz: 79603605c005d7d95641760b9ac8463a1d283915da71a73979d9c51a10c2bf7c196a664a6644f62f36cf5774ae3e4333b89afb5e6335d158161201aa5e6411c4
6
+ metadata.gz: 3700ca6b90332438f66eeacde37900b582aafa8259a2621422f34421575ac30a54acdf17a59e2797d527bef10b0bf3feb4360336d835b50278b7e08fd3c4f535
7
+ data.tar.gz: 2fdf27cfbd1c15833acc2f096f8e129326fca7795e6f7a0a9a760b6e29f5234346e9cc5f644147323404cb82cabd065c1143179eea7f4c26b1c989361be284e5
data/README.md CHANGED
@@ -12,6 +12,7 @@ Farmstead is a modular data pipeline platform. Farmstead makes creating and depl
12
12
 
13
13
  - [Getting started](#getting-started)
14
14
  - [Configuration](#configuration)
15
+ + [Configuration Options](#config-options)
15
16
  - [Environment Variables](#env)
16
17
  - [Deployment Methods](#deployment)
17
18
  - [Architecture](#architecture)
@@ -57,6 +58,34 @@ farmstead new myproject -c myproject.yml
57
58
 
58
59
  An example configuration file is included.
59
60
 
61
+ #### Configuration Options
62
+
63
+ **Rails Authentication**
64
+
65
+ There is optional Rails Authentication with AUTH0.
66
+
67
+ **Rails Environment**
68
+
69
+ The default environment is development but can be set to production (if you're ready).
70
+
71
+ **Database**
72
+
73
+ The default database is MySQL but can be set to anything that Rails can handle.
74
+
75
+ **Kafka**
76
+
77
+ The default is to advertise the IP address assigned to the host. If you're behind a firewall or a load-balancer and want to change it you anything you want. Here's an example:
78
+
79
+ ```yaml
80
+ kafka:
81
+ - advertise_from_local_ip: false
82
+ - advertised_ip: 192.168.1.2
83
+ ```
84
+
85
+ You can use a custom Zookeeper cluster if you have one. Just set the zookeeper_address in the config.
86
+
87
+ You can also create custom topics outside of the default Wood, Field, Forest, and Road.
88
+
60
89
  ### Environment Variables
61
90
 
62
91
  Farmstead builds projects on Docker. In order to keep secrets out of the Rails code we use environment varibles. These are read from the .env file at the root of the project. This is IGNORED in Git, so be sure to keep these safe in a deployment/build system (i.e. Jenkins).
data/bin/farmstead CHANGED
File without changes
@@ -1,23 +1,26 @@
1
1
  - name: My Project
2
- hosts: 127.0.0.1
3
- connection: local
4
- gather_facts: False
5
- remote_user: root
6
- roles:
7
- - create
8
-
9
- AUTH0_CLIENT_ID={CLIENT_ID}
10
- AUTH0_CLIENT_SECRET={CLIENT_SECRET}
11
- AUTH0_DOMAIN={DOMAIN}
12
- AUTH0_CALLBACK_URL=http://localhost:3000/auth/auth0/callback
13
- AUTH0_AUDIENCE=
14
- MYSQL_ROOT_PASSWORD=Rc2$NE99p5%^
15
- MYSQL_DATABASE=farmstead
16
- MYSQL_USER=farmstead
17
- MYSQL_PASSWORD=farmstead
18
- MYSQL_HOST=mysql
19
- RAILS_ENV=development
20
- KAFKA_ADVERTISED_HOST_NAME=192.168.1.13
21
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
22
- KAFKA_CREATE_TOPICS=Wood:1:1,Field:1:1,Forest:1:1,Road:1:1
23
-
2
+ rails:
3
+ - authentication:
4
+ - enable: true
5
+ - AUTH0_CLIENT_ID: myclientid
6
+ - AUTH0_CLIENT_SECRET: myclientsecret
7
+ - AUTH0_DOMAIN: myauth0domain
8
+ - AUTH0_DOMAIN: http://localhost:3000/auth/auth0/callback
9
+ - AUTH0_AUDIENCE:
10
+ - environment: development
11
+ database:
12
+ - type: mysql
13
+ - MYSQL_ROOT_PASSWORD: Rc2$NE99p5%^
14
+ - MYSQL_DATABASE: farmstead
15
+ - MYSQL_USER: farmstead
16
+ - MYSQL_PASSWORD: farmstead
17
+ - MYSQL_HOST: mysql
18
+ kafka:
19
+ - advertise_from_local_ip: false
20
+ - advertised_ip: 192.168.1.2
21
+ - zookeeper_address: "zookeeper:2181"
22
+ - topics
23
+ - "Wood:1:1"
24
+ - "Field:1:1"
25
+ - "Forest:1:1"
26
+ - "Road:1:1"
@@ -1,4 +1,5 @@
1
1
  require "erb"
2
+ require "net/http"
2
3
 
3
4
  module Farmstead
4
5
  # creates a Farmstead Project
@@ -16,6 +17,7 @@ module Farmstead
16
17
 
17
18
  def start_deploy
18
19
  Dir.chdir @name
20
+ File.chmod(0755, "exec.sh")
19
21
  system ("bash exec.sh")
20
22
  end
21
23
 
@@ -27,30 +29,36 @@ module Farmstead
27
29
 
28
30
  # Generate from templates in scaffold
29
31
  def generate_files
30
- erbfiles = File.join("**", "*.erb")
31
- scaffold = Dir.glob(erbfiles, File::FNM_DOTMATCH)
32
+ ip = get_ip_address_from_locals
33
+ scaffold_path = "#{File.dirname __FILE__}/scaffold"
34
+ scaffold = Dir.glob("#{scaffold_path}/**/*.erb", File::FNM_DOTMATCH)
32
35
  scaffold.each do |file|
33
- filename = file.match('lib\/farmstead\/scaffold\/(.*)')[1]
34
- foldername = File.dirname(filename)
35
- # Create folder structure of subdirectories
36
- if foldername != "."
37
- create_recursive(foldername)
36
+ basename = File.basename(file)
37
+ folderstruct = file.match("#{scaffold_path}/(.*)")[1]
38
+ if basename != folderstruct
39
+ foldername = File.dirname(folderstruct)
40
+ create_recursive("#{@name}/#{foldername}")
38
41
  end
39
- projectpath = "#{@name}/#{filename}".chomp(".erb")
40
- scaffoldpath = "lib/farmstead/scaffold/#{filename}"
41
- template = File.read(scaffoldpath)
42
+ projectpath = "#{@name}/#{folderstruct}".chomp(".erb")
43
+ template = File.read(file)
42
44
  results = ERB.new(template).result(binding)
43
45
  copy_to_directory(results, projectpath)
44
46
  end
45
47
  end
46
48
 
49
+ def get_ip_address_from_local
50
+ response = Net::HTTP.get(URI("http://v4.ifconfig.co/json"))
51
+ json = eval(response)
52
+ json[:ip]
53
+ end
54
+
47
55
  # Recursive Create
48
56
  def create_recursive(path)
49
57
  recursive = path.split("/")
50
58
  directory = ""
51
59
  recursive.each do |sub_directory|
52
60
  directory += sub_directory + "/"
53
- Dir.mkdir("#{@name}/#{directory}") unless (File.directory? directory)
61
+ Dir.mkdir("#{directory}") unless (File.directory? directory)
54
62
  end
55
63
  end
56
64
 
@@ -4,6 +4,6 @@ MYSQL_USER=farmstead
4
4
  MYSQL_PASSWORD=farmstead
5
5
  MYSQL_HOST=mysql
6
6
  RAILS_ENV=development
7
- KAFKA_ADVERTISED_HOST_NAME=192.168.1.139
7
+ KAFKA_ADVERTISED_HOST_NAME={%= ip %}
8
8
  KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
9
9
  KAFKA_CREATE_TOPICS=Wood:1:1,Field:1:1,Forest:1:1,Road:1:1
@@ -4,8 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
6
6
 
7
- gemspec
8
-
9
7
  gem "coffee-rails", "~> 4.2"
10
8
  gem "httparty", "~> 0.15.6"
11
9
  gem "jbuilder", "~> 2.5"
@@ -8,6 +8,12 @@ docker-compose rm -f > /dev/null 2>&1
8
8
 
9
9
  echo "Building new environment"
10
10
  docker-compose build > /dev/null 2>&1
11
+ if [ $? -eq 0 ]; then
12
+ printf "\tBuild successsful"
13
+ else
14
+ printf "\tBuild failed"
15
+ exit 1
16
+ fi
11
17
 
12
18
  echo "Starting MySQL and Zookeeper"
13
19
  docker-compose up -d mysql zookeeper > /dev/null 2>&1
@@ -1,3 +1,3 @@
1
1
  module Farmstead
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farmstead
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Jenney
@@ -105,7 +105,6 @@ files:
105
105
  - lib/farmstead/scaffold/app/controllers/application_controller.rb.erb
106
106
  - lib/farmstead/scaffold/docker-compose.yml.erb
107
107
  - lib/farmstead/scaffold/exec.sh.erb
108
- - lib/farmstead/scaffold/exec.sh.erb.old
109
108
  - lib/farmstead/scaffold/supervisord.conf.erb
110
109
  - lib/farmstead/scarecrow.rb
111
110
  - lib/farmstead/service.rb
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Script to start Farmstead on Docker
4
-
5
- trap mytrap ERR #0 #EXIT 0 HUP INT QUIT PIPE TERM
6
-
7
- mytrap() {
8
- excode=$?
9
- if [ $excode -ne 0 ]; then
10
- printf "\tFailed!\n"
11
- exit 1
12
- fi
13
- }
14
-
15
- success() {
16
- printf "\tSucceeded\n"
17
- }
18
-
19
- # Counts down a number of seconds
20
- countdown() {
21
- secs=$1
22
- while [ $secs -gt 0 ]; do
23
- echo -ne "$secs\033[0K\r"
24
- sleep 1
25
- : $((secs--))
26
- done
27
- }
28
-
29
- echo "Cleaning up old environment"
30
- docker-compose stop > /dev/null 2>&1
31
- docker-compose rm -f > /dev/null 2>&1
32
- #docker stop $(docker ps -a -q) > /dev/null 2>&1
33
- #docker rm $(docker ps -a -q) > /dev/null 2>&1
34
- success
35
-
36
- echo "Building new environment"
37
- docker-compose build > /dev/null 2>&1
38
- success
39
-
40
- echo "Starting MySQL and Zookeeper"
41
- docker-compose up -d mysql zookeeper > /dev/null 2>&1
42
- success
43
-
44
- echo "Sleeping"
45
- countdown 10
46
-
47
- echo "Starting dorothy"
48
- docker-compose up -d dorothy > /dev/null 2>&1
49
- success
50
-
51
- echo "Create and Seed MySQL DB"
52
- docker-compose exec dorothy rails db:setup > /dev/null 2>&1
53
- success
54
-
55
- echo "Starting everything else"
56
- docker-compose up -d > /dev/null 2>&1
57
- success