cluster_management 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -0
- data/lib/cluster_management/package.rb +39 -0
- data/lib/cluster_management/rake.rb +11 -0
- data/lib/cluster_management.rb +12 -0
- data/readme.md +46 -0
- metadata +68 -0
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Ros
|
2
|
+
class Package < Hash
|
3
|
+
class Dsl
|
4
|
+
attr_reader :package
|
5
|
+
|
6
|
+
def initialize package
|
7
|
+
@package = package
|
8
|
+
end
|
9
|
+
|
10
|
+
def version version; package.version = version end
|
11
|
+
def applied? &b; package.applied = b end
|
12
|
+
def apply &b; package.apply = b end
|
13
|
+
def verify &b; package.verify = b end
|
14
|
+
def after_applying &b; package.after_applying = b end
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_accessor :applied, :apply, :verify, :after_applying, :name, :version
|
18
|
+
|
19
|
+
def initialize name
|
20
|
+
@name = name
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure_with &b
|
24
|
+
dsl = Dsl.new self
|
25
|
+
b.call dsl
|
26
|
+
end
|
27
|
+
|
28
|
+
def apply_to box
|
29
|
+
package_applied = applied && applied.call(box)
|
30
|
+
if apply and !package_applied
|
31
|
+
print "applying '#{name}#{version}' to '#{box}'\n"
|
32
|
+
apply.call box
|
33
|
+
end
|
34
|
+
raise "invalid '#{name}' package for '#{box}'!" if verify and !verify.call(box)
|
35
|
+
after_applying && after_applying.call(box)
|
36
|
+
# print "done\n" if apply and !package_applied
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Simple cluster management tools
|
2
|
+
|
3
|
+
It may be **usefull if Your claster has about 1-10 boxes**, and tools like Chef, Puppet, Capistrano are too complex and proprietary for your needs.
|
4
|
+
**It's extremely easy**, there are only 3 methods.
|
5
|
+
|
6
|
+
Define your packages, they are just rake tasks, so you probably know how to work with them:
|
7
|
+
|
8
|
+
namespace :os do
|
9
|
+
package :ruby do
|
10
|
+
applied?{|box| box.has_mark? :ruby}
|
11
|
+
apply do |box|
|
12
|
+
box.bash 'apt-get install ruby'
|
13
|
+
box.mark :ruby
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
package :rails => :ruby do
|
18
|
+
applied?{|box| box.has_mark? :rails}
|
19
|
+
apply do |box|
|
20
|
+
box.bash 'gem install rails'
|
21
|
+
box.mark :rails
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Define to what it should be applied:
|
27
|
+
|
28
|
+
def each_box &b
|
29
|
+
host = ENV['host'] || raise(":host not defined!")
|
30
|
+
box = Rsh::Box.new host: host, ssh: {user: 'root', password: 'secret'}
|
31
|
+
b.call box
|
32
|
+
end
|
33
|
+
|
34
|
+
Run it:
|
35
|
+
|
36
|
+
$ rake os:rails host=webapp.com
|
37
|
+
|
38
|
+
**You can use it also for deployment**, exactly the same way, configure it the way you like, it's just rake
|
39
|
+
tasks. And by the way, the *box.mark ...* is just an example check, you can use anything there.
|
40
|
+
|
41
|
+
It checks if the package already has been applied to box, so you can evolve your configuration and apply
|
42
|
+
it multiple times, it will apply only missing packages (or drop the *applied?* clause and it will be applied every run).
|
43
|
+
|
44
|
+
- small
|
45
|
+
- uses well known tools (rake and anytingh ssh-enabled)
|
46
|
+
- support iterative development
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cluster_management
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Alexey Petrushin
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-01 00:00:00 +03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email:
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- Rakefile
|
31
|
+
- readme.md
|
32
|
+
- lib/cluster_management/package.rb
|
33
|
+
- lib/cluster_management/rake.rb
|
34
|
+
- lib/cluster_management.rb
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/alexeypetrushin/cluster_management
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.3.7
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Simple cluster management tools
|
67
|
+
test_files: []
|
68
|
+
|