cloudbuilder 0.1.0 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/README.md +14 -0
- data/Rakefile +1 -0
- data/TODO.md +8 -0
- data/bin/cloudbuilder +147 -0
- data/cloudbuilder.gemspec +28 -0
- data/lib/cloudbuilder.rb +4 -4
- data/lib/cloudbuilder/create.rb +3 -0
- data/lib/cloudbuilder/version.rb +3 -0
- data/sample.cloud +12 -0
- data/sample.yml +8 -0
- data/staging.yml +9 -0
- metadata +44 -10
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
cloudbuilder
|
2
|
+
============
|
3
|
+
|
4
|
+
ruby gem to easily bootstrap a multi server application
|
5
|
+
all you have to do is define the servers that you need with a yaml file
|
6
|
+
and cloudbuilder will create the servers on the desired cloud
|
7
|
+
|
8
|
+
note, all the servers do not need to be on the same cloud
|
9
|
+
|
10
|
+
one of the main uses of this is to allow developers to easily create a developer or staging version of their production application
|
11
|
+
|
12
|
+
a deployment tool that can be used with puppet or chef scripts
|
13
|
+
|
14
|
+
The idea for cloudbuilder was borne out of a furstration between using vagrant locally on my developer machine and then trying to deploy the application to a cloud
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
1. read a YAML file into a data structure
|
2
|
+
2. use fog to create servers
|
3
|
+
3. use vagrant puppet provisioning to add software
|
4
|
+
4. use capistranto to deploy apps?
|
5
|
+
|
6
|
+
|
7
|
+
-convert YAML to a DSL
|
8
|
+
http://obiefernandez.com/presentations/obie_fernandez-agile_dsl_development_in_ruby.pdf
|
data/bin/cloudbuilder
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# require 'optparse'
|
4
|
+
#require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'cloudbuilder'))
|
5
|
+
|
6
|
+
require 'cloudbuilder'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
require 'fog/bin'
|
10
|
+
require 'fog/providers'
|
11
|
+
require 'fog/compute'
|
12
|
+
|
13
|
+
|
14
|
+
#make sure output is not buffered
|
15
|
+
$stdout.sync = true
|
16
|
+
$stderr.sync = true
|
17
|
+
|
18
|
+
options = {}
|
19
|
+
|
20
|
+
debugger
|
21
|
+
|
22
|
+
# OptionParser.new do |opts|
|
23
|
+
|
24
|
+
# opts.banner = "Usage: cloudbuilder [command]"
|
25
|
+
# opts.separator ""
|
26
|
+
# opts.separator "Commands:"
|
27
|
+
|
28
|
+
# usage+= " create - create a cloud solution"
|
29
|
+
# usage+= " version - what version of clouldbuilder this is"
|
30
|
+
# usage+= " help - print this summary\n"
|
31
|
+
|
32
|
+
# opts.on("-v", "--version", "print version") do |v|
|
33
|
+
# puts "version #{clouldBuilder::VERSION}"
|
34
|
+
# exit
|
35
|
+
# end
|
36
|
+
|
37
|
+
# end.parse!
|
38
|
+
|
39
|
+
|
40
|
+
if (ARGV.include?("help")) || (ARGV.count == 0)
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
|
44
|
+
if ARGV.include?("create")
|
45
|
+
|
46
|
+
puts "reading default yaml file and creating servers"
|
47
|
+
|
48
|
+
#read config file
|
49
|
+
#if have name use it, else assume 'default.yml'
|
50
|
+
if (ARGV.count == 1)
|
51
|
+
config_file = "sample.yml"
|
52
|
+
else
|
53
|
+
config_file = ARGV[1]
|
54
|
+
end
|
55
|
+
|
56
|
+
solution = begin
|
57
|
+
YAML.load(File.open(config_file))
|
58
|
+
rescue ArgumentError => e
|
59
|
+
puts "Could not parse solution file - #{e.message}"
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
#validate
|
64
|
+
#make sure have needed credentials
|
65
|
+
clouds = Fog.available_providers
|
66
|
+
servers = solution[:servers]
|
67
|
+
servers.each do |server|
|
68
|
+
desired_cloud = server[:cloud]
|
69
|
+
if (clouds.index{|cloud| cloud.downcase == desired_cloud.downcase} == nil)
|
70
|
+
#shoud really see if even a valid cloud fog supports
|
71
|
+
if (Fog::Compute.providers.index( desired_cloud.to_sym) == nil)
|
72
|
+
puts "#{desired_cloud} is not supported (by fog)"
|
73
|
+
else
|
74
|
+
puts "credentials needed for #{server[:cloud]}"
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
#solution[:name]
|
81
|
+
puts "building #{solution[:name]}"
|
82
|
+
|
83
|
+
servers = solution[:servers]
|
84
|
+
puts "solution has #{servers.length} servers"
|
85
|
+
|
86
|
+
servers.each do |server|
|
87
|
+
puts "-building #{server[:name]} on #{server[:cloud]}"
|
88
|
+
|
89
|
+
provider = server[:cloud].to_s.downcase.to_sym
|
90
|
+
|
91
|
+
#get connection to cloud
|
92
|
+
attributes = {}
|
93
|
+
attributes[:provider]= provider
|
94
|
+
if (server[:region])
|
95
|
+
#:region = ['us-east-1', 'us-west-1', 'etc']
|
96
|
+
attributes[:region] = server[:region]
|
97
|
+
end
|
98
|
+
|
99
|
+
# instance based (rather than EBS)
|
100
|
+
if (server[:os].downcase == 'ubuntu-12.04') {
|
101
|
+
if (provider == :aws) {
|
102
|
+
image_id = case :region
|
103
|
+
when 'us-east-1'
|
104
|
+
'ami-3c994355'
|
105
|
+
when 'us-west-1'
|
106
|
+
'ami-e7712aa2'
|
107
|
+
when 'us-west-2'
|
108
|
+
'ami-38800c08'
|
109
|
+
when 'sa-east-1'
|
110
|
+
'ami-96d8068b'
|
111
|
+
when 'eu-west-1'
|
112
|
+
'ami-1de8d369'
|
113
|
+
when 'ap-southeast-1'
|
114
|
+
'ami-a0ca8df2'
|
115
|
+
when 'ap-northeast-1'
|
116
|
+
'ami-2cc7772d'
|
117
|
+
else
|
118
|
+
end
|
119
|
+
attributes[:image_id] = image_id
|
120
|
+
}
|
121
|
+
|
122
|
+
#do we need to enable swap?
|
123
|
+
}
|
124
|
+
if (provider == :aws) &&
|
125
|
+
cloud = Fog::Compute.new(attributes)
|
126
|
+
|
127
|
+
#:image_id - if don't specify an AMI, get Ubuntu 10.04 LTS - 64bit
|
128
|
+
# should be able to specify 'ubuntu-12.04'
|
129
|
+
attributes = {}
|
130
|
+
# attributes[:security_group_ids]
|
131
|
+
# 't1.micro'
|
132
|
+
server = cloud.servers.new
|
133
|
+
#get instance id
|
134
|
+
|
135
|
+
#is it ready?
|
136
|
+
#server.wait_for{ready?}
|
137
|
+
|
138
|
+
server.destroy
|
139
|
+
|
140
|
+
#question - to bootstrap or not?
|
141
|
+
#
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
exit 1
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "cloudbuilder/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
s.name = "cloudbuilder"
|
8
|
+
s.version = CloudBuilder::VERSION
|
9
|
+
s.date = '2012-04-29'
|
10
|
+
s.rubyforge_project = "cloudbuilder"
|
11
|
+
|
12
|
+
s.summary = %q{tool to bootstrap a number of servers on a cloud}
|
13
|
+
s.description = %q{the peanut butter to puppet or chef's jelly}
|
14
|
+
|
15
|
+
s.authors = ["Athir Nuaimi"]
|
16
|
+
s.email = ["athir@nuaimi.com"]
|
17
|
+
s.homepage = "https://github.com/anuaimi/cloudbuilder"
|
18
|
+
|
19
|
+
s.executables = ["cloudbuilder"]
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
s.add_dependency('fog')
|
26
|
+
|
27
|
+
s.add_development_dependency('ruby-debug19')
|
28
|
+
end
|
data/lib/cloudbuilder.rb
CHANGED
data/sample.cloud
ADDED
data/sample.yml
ADDED
data/staging.yml
ADDED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cloudbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Athir Nuaimi
|
@@ -10,19 +10,53 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-04-
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
date: 2012-04-29 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: fog
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: ruby-debug19
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
description: the peanut butter to puppet or chef's jelly
|
38
|
+
email:
|
39
|
+
- athir@nuaimi.com
|
40
|
+
executables:
|
41
|
+
- cloudbuilder
|
20
42
|
extensions: []
|
21
43
|
|
22
44
|
extra_rdoc_files: []
|
23
45
|
|
24
46
|
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- TODO.md
|
52
|
+
- bin/cloudbuilder
|
53
|
+
- cloudbuilder.gemspec
|
25
54
|
- lib/cloudbuilder.rb
|
55
|
+
- lib/cloudbuilder/create.rb
|
56
|
+
- lib/cloudbuilder/version.rb
|
57
|
+
- sample.cloud
|
58
|
+
- sample.yml
|
59
|
+
- staging.yml
|
26
60
|
homepage: https://github.com/anuaimi/cloudbuilder
|
27
61
|
licenses: []
|
28
62
|
|
@@ -45,10 +79,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
79
|
version: "0"
|
46
80
|
requirements: []
|
47
81
|
|
48
|
-
rubyforge_project:
|
82
|
+
rubyforge_project: cloudbuilder
|
49
83
|
rubygems_version: 1.8.17
|
50
84
|
signing_key:
|
51
85
|
specification_version: 3
|
52
|
-
summary: tool to
|
86
|
+
summary: tool to bootstrap a number of servers on a cloud
|
53
87
|
test_files: []
|
54
88
|
|