nebula 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in nebula.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/clean'
5
+ require 'rake/testtask'
6
+
7
+ task :default => [:test]
8
+
9
+ task :test do
10
+ Rake::TestTask.new do |t|
11
+ t.libs << "test"
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+ end
16
+
17
+ desc 'Measures test coverage'
18
+ task :coverage do
19
+ rm_f "coverage"
20
+ rm_f "coverage.data"
21
+ system "rcov -x /Users -Ilib:test test/**/*_test.rb"
22
+ system "open coverage/index.html" if PLATFORM['darwin']
23
+ end
@@ -0,0 +1,3 @@
1
+ module Nebula
2
+ autoload :Dsl, "nebula/dsl"
3
+ end
@@ -0,0 +1,82 @@
1
+ module Nebula
2
+ module Dsl
3
+ class Main
4
+ def self.evaluate(spec)
5
+ builder = new
6
+ builder.instance_eval(spec)
7
+ builder.to_definition
8
+ end
9
+
10
+ def cluster(name, &block)
11
+ @cluster = Cluster.new(name, &block)
12
+ end
13
+
14
+ def to_definition
15
+ @cluster
16
+ end
17
+ end
18
+
19
+ class Cluster
20
+ attr_reader :name, :nodes, :provider, :chef
21
+
22
+ def initialize(name, &block)
23
+ @name = name
24
+ @nodes = []
25
+ instance_eval(&block)
26
+ end
27
+
28
+ def provider(name)
29
+ @provider = name
30
+ end
31
+
32
+ def chef_solo(&block)
33
+ @chef = ChefSolo.new(&block)
34
+ end
35
+
36
+ def compute_node(name, &block)
37
+ @nodes << ComputeNode.new(name, &block)
38
+ end
39
+ end
40
+
41
+ class ChefSolo
42
+ attr_reader :repo_path, :bootstrap_template
43
+
44
+ def initialize(&block)
45
+ instance_eval(&block)
46
+ end
47
+
48
+ def repo(path)
49
+ @repo_path = path
50
+ end
51
+
52
+ def bootstrap(template)
53
+ @bootstrap_template = template
54
+ end
55
+ end
56
+
57
+ class ComputeNode
58
+ def initialize(name, &block)
59
+ @name = name
60
+ @run_list = []
61
+ @override_attributes = {}
62
+ instance_eval(&block)
63
+ end
64
+
65
+ def role(name)
66
+ @run_list << "role[#{name}]"
67
+ end
68
+
69
+ def recipe(name)
70
+ @run_list << "recipe[#{name}]"
71
+ end
72
+
73
+ def override_attributes(atts)
74
+ @override_attributes.merge!(atts)
75
+ end
76
+ end
77
+
78
+ def self.evaluate(spec)
79
+ Main.evaluate(spec)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,3 @@
1
+ module Nebula
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "nebula/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "nebula"
7
+ s.version = Nebula::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ben Marini"]
10
+ s.email = ["bmarini@gmail.com"]
11
+ s.homepage = "http://github.com/bmarini/nebula"
12
+ s.summary = %q{Tool for building server clusters with chef and fog}
13
+ s.description = %q{Tool for building server clusters with chef and fog}
14
+
15
+ s.rubyforge_project = "nebula"
16
+
17
+ s.add_dependency "fog", "~> 0.4.1"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,59 @@
1
+ cluster "myproject" do
2
+ provider "Rackspace"
3
+
4
+ chef_solo do
5
+ repo "/etc/chef-repo"
6
+ bootstrap "/etc/chef-repo/boostraps/ubuntu64-ree.erb"
7
+ end
8
+
9
+ compute_node("app1") do
10
+ role "app"
11
+ end
12
+
13
+ compute_node("app2") do
14
+ role "app"
15
+ end
16
+
17
+ compute_node("db1") do
18
+ role "db-master"
19
+ end
20
+
21
+ compute_node("db2") do
22
+ role "db-slave"
23
+
24
+ override_attributes :mysql => {
25
+ :master => "mysql.master.local"
26
+ }
27
+ end
28
+
29
+ compute_node("lb1") do
30
+ role "load-balancer"
31
+ end
32
+
33
+ compute_node("lb2") do
34
+ role "load-balancer"
35
+ end
36
+
37
+ compute_node("job") do
38
+ role "app"
39
+ recipe "resque"
40
+ end
41
+
42
+ # cdn do
43
+ # end
44
+ #
45
+ # storage do
46
+ # end
47
+ #
48
+ # dns do
49
+ # end
50
+
51
+ end
52
+
53
+ # foreach instance
54
+ # create instance
55
+ # bootstrap instance
56
+ # generate config file, attributes file
57
+ # rsync config file, attributes file
58
+ # rsync cookbooks and roles files if chef-solo
59
+ # run chef-solo/chef-client
@@ -0,0 +1,5 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require "test/unit"
5
+ require "nebula"
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class DslTest < Test::Unit::TestCase
4
+ def test_dsl
5
+ spec = File.read(File.expand_path("../../fixtures/simple.rb", __FILE__))
6
+ cluster = Nebula::Dsl.evaluate spec
7
+ p cluster
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nebula
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Ben Marini
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-22 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: fog
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 0
32
+ - 4
33
+ - 1
34
+ version: 0.4.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Tool for building server clusters with chef and fog
38
+ email:
39
+ - bmarini@gmail.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - Rakefile
50
+ - lib/nebula.rb
51
+ - lib/nebula/dsl.rb
52
+ - lib/nebula/version.rb
53
+ - nebula.gemspec
54
+ - test/fixtures/simple.rb
55
+ - test/test_helper.rb
56
+ - test/unit/dsl_test.rb
57
+ has_rdoc: true
58
+ homepage: http://github.com/bmarini/nebula
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options: []
63
+
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project: nebula
87
+ rubygems_version: 1.3.7
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Tool for building server clusters with chef and fog
91
+ test_files:
92
+ - test/fixtures/simple.rb
93
+ - test/test_helper.rb
94
+ - test/unit/dsl_test.rb