the-maestro 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/README.rdoc +28 -13
- data/VERSION +1 -1
- data/lib/maestro/cloud.rb +10 -2
- data/lib/maestro/operating_system.rb +3 -1
- data/lib/maestro/operating_system/ubuntu.rb +21 -44
- data/test/integration/test_ubuntu.rb +20 -0
- data/the-maestro.gemspec +1 -1
- metadata +1 -1
data/.gitignore
CHANGED
@@ -20,6 +20,12 @@ tmtags
|
|
20
20
|
coverage
|
21
21
|
rdoc
|
22
22
|
pkg
|
23
|
+
test/integration/fixtures/log/*
|
24
|
+
test/integration/fixtures/log/**/*
|
25
|
+
test/unit/fixtures/rails/*
|
26
|
+
test/unit/fixtures/rails/**/*
|
27
|
+
test/unit/fixtures/standalone/*
|
28
|
+
test/unit/fixtures/standalone/**/*
|
23
29
|
|
24
30
|
## PROJECT::SPECIFIC
|
25
31
|
.loadpath
|
data/README.rdoc
CHANGED
@@ -8,7 +8,7 @@ Maestro currently supports the Amazon Web Services cloud. Support for other clou
|
|
8
8
|
|
9
9
|
Maestro currently supports the following Linux distributions:
|
10
10
|
|
11
|
-
Ubuntu (9.10, 9.04, 8.10, 8.04)
|
11
|
+
Ubuntu (10.04, 9.10, 9.04, 8.10, 8.04)
|
12
12
|
Debian (6.0, 5.0)
|
13
13
|
Fedora (8)
|
14
14
|
CentOS (5.4)
|
@@ -22,14 +22,24 @@ Add the following gem dependency to your Rails project's <code>config/environmen
|
|
22
22
|
|
23
23
|
Rails::Initializer.run do |config|
|
24
24
|
|
25
|
-
config.gem "the-maestro", :version =>
|
25
|
+
config.gem "the-maestro", :lib => "maestro", :version => "0.3.0", :source => "http://gemcutter.org"
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
+
Then run the following to install the Maestro gem:
|
30
|
+
|
31
|
+
sudo rake gems:install
|
32
|
+
|
33
|
+
You may optionally unpack Maestro into vendor/gems by running:
|
34
|
+
|
35
|
+
sudo rake gems:unpack:dependencies
|
36
|
+
|
29
37
|
You'll interact with Maestro through custom Rake tasks that Maestro adds to your Rails project. Until {this}[https://rails.lighthouseapp.com/projects/8994/tickets/59] Rails issue is resolved, you'll need to add this to your Rails project's Rakefile:
|
30
38
|
|
31
39
|
require 'maestro/tasks'
|
32
40
|
|
41
|
+
Make sure the Maestro gem in successfully installed before adding this line to your Rails project's Rakefile.
|
42
|
+
|
33
43
|
=== Configuration
|
34
44
|
|
35
45
|
To create the Maestro configuration directory structure, run the following Rake task:
|
@@ -106,17 +116,21 @@ that these capabilities are enabled in your Amazon Web Services account. See the
|
|
106
116
|
|
107
117
|
Let's look at each of these sections in more detail:
|
108
118
|
|
109
|
-
|
119
|
+
==== aws_cloud <i>cloud_name</i>
|
110
120
|
|
111
121
|
The aws_cloud method declares an Amazon Web Services cloud with the given name. The cloud name can be either a symbol or a string.
|
112
122
|
|
113
123
|
aws_cloud :dev do
|
124
|
+
...
|
125
|
+
end
|
114
126
|
|
115
127
|
aws_cloud "dev" do
|
128
|
+
...
|
129
|
+
end
|
116
130
|
|
117
131
|
A cloud name may only contain alphanumerics and dashes.
|
118
132
|
|
119
|
-
|
133
|
+
==== aws_cloud attributes
|
120
134
|
|
121
135
|
The following attributes must be present after your aws_cloud declaration:
|
122
136
|
|
@@ -128,10 +142,11 @@ The following attributes must be present after your aws_cloud declaration:
|
|
128
142
|
- <b>chef_bucket</b>: The name of the Amazon S3 Bucket where you want your Chef recipes and roles stored. If this Bucket does not exist, Maestro will create it for you. Please note that the Bucket itself, and all objects stored within the Bucket use the canned 'private' access policy, meaning no one but the Bucket owner (i.e. you) may access the Bucket or the objects within it. Maestro uses query string authentication when accessing the objects to ensure the integrity of your data.
|
129
143
|
|
130
144
|
|
131
|
-
|
145
|
+
==== roles
|
132
146
|
The <code>roles</code> method allows you to apply configuration to all of the nodes in your cloud which are in a given role, rather than repeating that configuration for all nodes individually.
|
133
147
|
|
134
|
-
|
148
|
+
==== role <i>role_name</i>
|
149
|
+
|
135
150
|
A role corresponds to a Chef role that the configurable nodes in your Cloud can play. A role name may either be a symbol or a string.
|
136
151
|
|
137
152
|
role "web" do
|
@@ -140,21 +155,21 @@ A role corresponds to a Chef role that the configurable nodes in your Cloud can
|
|
140
155
|
|
141
156
|
A role name may only contain alphanumerics and dashes.
|
142
157
|
|
143
|
-
|
158
|
+
==== role attributes
|
144
159
|
|
145
160
|
A role may configure the following attributes:
|
146
161
|
|
147
162
|
- <b>public_ports</b>: The ports that should be open to the public internet, for example ports 80 and 443 for a web role. The value of this attribute must be an array of integers.
|
148
163
|
|
149
164
|
|
150
|
-
|
165
|
+
==== nodes
|
151
166
|
The <code>nodes</code> method is where you define the nodes (servers, machine, VMs, devices, etc…) in your cloud.
|
152
167
|
|
153
|
-
|
168
|
+
==== AWS Node types
|
154
169
|
|
155
170
|
The following are the AWS node types supported by Maestro:
|
156
171
|
|
157
|
-
|
172
|
+
==== ec2_node <i>node-name</i>
|
158
173
|
|
159
174
|
Creates an Elastic Cloud Compute (EC2) node. An EC2 node name may only contain alphanumerics and dashes.
|
160
175
|
|
@@ -186,7 +201,7 @@ An example ec2_node:
|
|
186
201
|
end
|
187
202
|
|
188
203
|
|
189
|
-
|
204
|
+
==== elb_node <i>node-name</i>
|
190
205
|
|
191
206
|
Creates an Elastic Load Balancer (ELB) node. An ELB node name may only contain alphanumerics and dashes.
|
192
207
|
|
@@ -207,7 +222,7 @@ An example elb_node:
|
|
207
222
|
end
|
208
223
|
|
209
224
|
|
210
|
-
|
225
|
+
==== rds_node <i>node-name</i>
|
211
226
|
|
212
227
|
Creates a Relational Database Service (RDS) node. An RDS node name may only contain alphanumerics and dashes.
|
213
228
|
|
@@ -247,7 +262,7 @@ An example rds_node:
|
|
247
262
|
end
|
248
263
|
|
249
264
|
|
250
|
-
|
265
|
+
==== A note about node definitions
|
251
266
|
|
252
267
|
If your cloud has a large number of nodes which are identical other than their name, defining each node individually with a node method would be tedious.
|
253
268
|
Don't forget that your cloud definition files are Ruby, which allows you to do things like the following:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/maestro/cloud.rb
CHANGED
@@ -323,9 +323,17 @@ module Maestro
|
|
323
323
|
def open_ssh_session(cnodes=[])
|
324
324
|
handler = Proc.new do |server|
|
325
325
|
server[:connection_attempts] ||= 0
|
326
|
-
if server[:connection_attempts] <
|
326
|
+
if server[:connection_attempts] < 6
|
327
327
|
server[:connection_attempts] += 1
|
328
|
-
|
328
|
+
the_node = nil
|
329
|
+
@configurable_nodes.each_pair {|name, node| the_node = node if server.host.eql? node.hostname}
|
330
|
+
if the_node.nil?
|
331
|
+
@logger.error "Could not find node matching hostname #{server.host}. This should not happen."
|
332
|
+
throw :go, :raise
|
333
|
+
else
|
334
|
+
@logger.info "Could not connect to Node #{the_node.name}. Trying again in 10 seconds..."
|
335
|
+
end
|
336
|
+
sleep 10
|
329
337
|
throw :go, :retry
|
330
338
|
else
|
331
339
|
throw :go, :raise
|
@@ -5,7 +5,9 @@ module Maestro
|
|
5
5
|
# if the operating system cannot be determined or is unsupported by Maestro.
|
6
6
|
def self.create_from_etc_issue(etc_issue_str)
|
7
7
|
raise StandardError, "Invalid etc_issue_str" if (etc_issue_str.nil? || etc_issue_str.empty?)
|
8
|
-
if etc_issue_str.include?("Ubuntu
|
8
|
+
if etc_issue_str.include?("Ubuntu 10.04")
|
9
|
+
Ubuntu1004.new(etc_issue_str)
|
10
|
+
elsif etc_issue_str.include?("Ubuntu 9.10")
|
9
11
|
Ubuntu910.new(etc_issue_str)
|
10
12
|
elsif etc_issue_str.include?("Ubuntu 9.04")
|
11
13
|
Ubuntu904.new(etc_issue_str)
|
@@ -21,22 +21,32 @@ module Maestro
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
# The Ubuntu 10.04 Linux distro
|
25
|
+
class Ubuntu1004 < Ubuntu
|
26
|
+
def initialize(etc_issue_str)
|
27
|
+
super(etc_issue_str)
|
28
|
+
# http://alestic.com/2009/11/ec2-karmic-desktop#comment-237
|
29
|
+
@chef_install_script =
|
30
|
+
["sh -c 'export DEBIAN_FRONTEND=noninteractive; sudo apt-get update -y'",
|
31
|
+
"sh -c 'export DEBIAN_FRONTEND=noninteractive; sudo -E apt-get upgrade -y'",
|
32
|
+
"sh -c 'export DEBIAN_FRONTEND=noninteractive; sudo apt-get install -y ruby irb ri rdoc libyaml-ruby and libzlib-ruby build-essential libopenssl-ruby ruby1.8-dev wget'",
|
33
|
+
"sudo mkdir -p /usr/local/src",
|
34
|
+
"sudo wget -P /usr/local/src http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz",
|
35
|
+
"sudo tar zxf /usr/local/src/rubygems-1.3.6.tgz -C /usr/local/src",
|
36
|
+
"sudo ruby /usr/local/src/rubygems-1.3.6/setup.rb",
|
37
|
+
"sudo rm /usr/local/src/rubygems-1.3.6.tgz",
|
38
|
+
"sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem",
|
39
|
+
"sudo gem sources -a http://gems.opscode.com",
|
40
|
+
"sudo gem install rake --no-rdoc --no-ri",
|
41
|
+
"sudo gem install chef --no-rdoc --no-ri --version '= 0.8.14'",
|
42
|
+
"sudo ln -sfv $(gem environment gemdir)/gems/chef-0.8.14/bin/chef-solo /usr/bin/chef-solo"]
|
43
|
+
end
|
44
|
+
end
|
24
45
|
|
25
46
|
# The Ubuntu 9.10 Linux distro
|
26
47
|
class Ubuntu910 < Ubuntu
|
27
48
|
def initialize(etc_issue_str)
|
28
49
|
super(etc_issue_str)
|
29
|
-
# Package install (0.7!)
|
30
|
-
# The native package installs install Chef 0.7, not the newest 0.8. Must use rubygem install for now
|
31
|
-
# @chef_install_script =
|
32
|
-
# ["sudo apt-get -y dist-upgrade",
|
33
|
-
# "sudo sh -c \"echo deb http://apt.opscode.com/ karmic universe > /etc/apt/sources.list.d/opscode.list\"",
|
34
|
-
# "curl http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -",
|
35
|
-
# "sudo apt-get -y update",
|
36
|
-
# "sudo aptitude -y install ruby ri rdoc libyaml-ruby libzlib-ruby build-essential libopenssl-ruby ruby1.8-dev rubygems ohai chef",
|
37
|
-
# "sudo gem install rake --no-rdoc --no-ri",
|
38
|
-
# "sudo /etc/init.d/chef-client stop",
|
39
|
-
# "sudo chef-solo"]
|
40
50
|
end
|
41
51
|
end
|
42
52
|
|
@@ -45,17 +55,6 @@ module Maestro
|
|
45
55
|
class Ubuntu904 < Ubuntu
|
46
56
|
def initialize(etc_issue_str)
|
47
57
|
super(etc_issue_str)
|
48
|
-
# Package install (0.7!)
|
49
|
-
# The native package installs install Chef 0.7, not the newest 0.8. Must use rubygem install for now
|
50
|
-
# @chef_install_script =
|
51
|
-
# ["sudo apt-get -y dist-upgrade",
|
52
|
-
# "sudo sh -c \"echo deb http://apt.opscode.com/ jaunty universe > /etc/apt/sources.list.d/opscode.list\"",
|
53
|
-
# "curl http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -",
|
54
|
-
# "sudo apt-get -y update",
|
55
|
-
# "sudo aptitude -y install ruby ri rdoc libyaml-ruby libzlib-ruby build-essential libopenssl-ruby ruby1.8-dev rubygems ohai chef",
|
56
|
-
# "sudo gem install rake --no-rdoc --no-ri",
|
57
|
-
# "sudo /etc/init.d/chef-client stop",
|
58
|
-
# "sudo chef-solo"]
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
@@ -64,17 +63,6 @@ module Maestro
|
|
64
63
|
class Ubuntu810 < Ubuntu
|
65
64
|
def initialize(etc_issue_str)
|
66
65
|
super(etc_issue_str)
|
67
|
-
# Package install (0.7!)
|
68
|
-
# The native package installs install Chef 0.7, not the newest 0.8. Must use rubygem install for now
|
69
|
-
# @chef_install_script =
|
70
|
-
# ["sudo apt-get -y dist-upgrade",
|
71
|
-
# "sudo sh -c \"echo deb http://apt.opscode.com/ intrepid universe > /etc/apt/sources.list.d/opscode.list\"",
|
72
|
-
# "curl http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -",
|
73
|
-
# "sudo apt-get -y update",
|
74
|
-
# "sudo aptitude -y install ruby ri rdoc libyaml-ruby libzlib-ruby build-essential libopenssl-ruby ruby1.8-dev rubygems ohai chef",
|
75
|
-
# "sudo gem install rake --no-rdoc --no-ri",
|
76
|
-
# "sudo /etc/init.d/chef-client stop",
|
77
|
-
# "sudo chef-solo"]
|
78
66
|
end
|
79
67
|
end
|
80
68
|
|
@@ -83,17 +71,6 @@ module Maestro
|
|
83
71
|
class Ubuntu804 < Ubuntu
|
84
72
|
def initialize(etc_issue_str)
|
85
73
|
super(etc_issue_str)
|
86
|
-
# Package install (0.7!)
|
87
|
-
# The native package installs install Chef 0.7, not the newest 0.8. Must use rubygem install for now
|
88
|
-
# @chef_install_script =
|
89
|
-
# ["sudo apt-get -y dist-upgrade",
|
90
|
-
# "sudo sh -c \"echo deb http://apt.opscode.com/ hardy universe > /etc/apt/sources.list.d/opscode.list\"",
|
91
|
-
# "curl http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -",
|
92
|
-
# "sudo apt-get -y update",
|
93
|
-
# "sudo aptitude -y install ruby ri rdoc libyaml-ruby libzlib-ruby build-essential libopenssl-ruby ruby1.8-dev rubygems ohai chef",
|
94
|
-
# "sudo gem install rake --no-rdoc --no-ri",
|
95
|
-
# "sudo /etc/init.d/chef-client stop",
|
96
|
-
# "sudo chef-solo"]
|
97
74
|
end
|
98
75
|
end
|
99
76
|
end
|
@@ -13,6 +13,8 @@ class TestUbuntu < Test::Unit::TestCase
|
|
13
13
|
#######################
|
14
14
|
|
15
15
|
setup do
|
16
|
+
ENV[Maestro::MAESTRO_DIR_ENV_VAR] = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures')
|
17
|
+
Maestro.create_log_dirs
|
16
18
|
credentials = @credentials
|
17
19
|
@cloud = aws_cloud :maestro_ubuntu_itest do
|
18
20
|
keypair_name credentials[:keypair_name]
|
@@ -79,6 +81,9 @@ class TestUbuntu < Test::Unit::TestCase
|
|
79
81
|
cloud_security_groups.each do |group_name|
|
80
82
|
@ec2.delete_security_group(:group_name => group_name)
|
81
83
|
end
|
84
|
+
|
85
|
+
FileUtils.rm_rf([Maestro.maestro_log_directory], :secure => true) if File.exists?(Maestro.maestro_log_directory)
|
86
|
+
ENV.delete Maestro::MAESTRO_DIR_ENV_VAR
|
82
87
|
end
|
83
88
|
|
84
89
|
|
@@ -86,6 +91,21 @@ class TestUbuntu < Test::Unit::TestCase
|
|
86
91
|
# Tests
|
87
92
|
#######################
|
88
93
|
|
94
|
+
context "Ubuntu 10.04" do
|
95
|
+
should "install chef-solo" do
|
96
|
+
@node.ami "ami-2d4aa444"
|
97
|
+
@node.ssh_user "ubuntu"
|
98
|
+
assert_nothing_raised do
|
99
|
+
@cloud.connect!
|
100
|
+
@cloud.start
|
101
|
+
@cloud.get_configurable_node_hostnames
|
102
|
+
assert !@cloud.chef_solo_installed?[0]
|
103
|
+
@cloud.install_chef_solo
|
104
|
+
assert @cloud.chef_solo_installed?[0]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
89
109
|
context "Ubuntu 9.10" do
|
90
110
|
should "install chef-solo" do
|
91
111
|
@node.ami "ami-bb709dd2"
|
data/the-maestro.gemspec
CHANGED