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 ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
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
@@ -1,6 +1,6 @@
1
+ require "cloudbuilder/version"
2
+ require "cloudbuilder/create"
3
+
4
+ module CloudBuilder
1
5
 
2
- class CloudBuilder
3
- def self.hi
4
- puts "Hello world!"
5
- end
6
6
  end
@@ -0,0 +1,3 @@
1
+ module CloudBuilder
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ module CloudBuilder
2
+ VERSION = "0.1.6"
3
+ end
data/sample.cloud ADDED
@@ -0,0 +1,12 @@
1
+ solution surfeasy do
2
+
3
+ configuration development do
4
+ end
5
+
6
+ configuration staging do
7
+ end
8
+
9
+ configuration production do
10
+ end
11
+
12
+ end
data/sample.yml ADDED
@@ -0,0 +1,8 @@
1
+ # website on rackspace
2
+ ---
3
+ :name: development
4
+ :servers:
5
+ - :name: web
6
+ :cloud: aws
7
+ :os: ubuntu-12.04
8
+ :provisioner: puppet
data/staging.yml ADDED
@@ -0,0 +1,9 @@
1
+ ---
2
+ :name: development
3
+ :servers:
4
+ - :name: web
5
+ :cloud: rackspace
6
+ :provisioner: puppet
7
+ - :name: database
8
+ :cloud: aws
9
+ :provisioner: puppet
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudbuilder
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
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-28 00:00:00 Z
14
- dependencies: []
15
-
16
- description: A simple hello world gem
17
- email: athir@nuaimi.com
18
- executables: []
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 automate bootstrapping a mutli-server application
86
+ summary: tool to bootstrap a number of servers on a cloud
53
87
  test_files: []
54
88