classify_cluster 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +3 -1
- data/examples/cluster.rb +28 -0
- data/lib/classify_cluster/configurator/cluster.rb +19 -0
- data/lib/classify_cluster/configurator/configuration.rb +15 -0
- data/lib/classify_cluster/configurator/node.rb +77 -0
- data/lib/classify_cluster/configurator/resource.rb +23 -0
- data/lib/classify_cluster/configurator/role.rb +19 -0
- data/lib/classify_cluster/configurator.rb +5 -103
- data/lib/classify_cluster/version.rb +1 -1
- metadata +10 -4
data/README
CHANGED
@@ -2,4 +2,6 @@ Classify Cluster
|
|
2
2
|
|
3
3
|
Useful if your wanting to have one location for specifying your capistrano and puppet configuration.
|
4
4
|
|
5
|
-
This is still extremely alpha, do not recommend use on production systems. More on documentation coming soon.
|
5
|
+
This is still extremely alpha, do not recommend use on production systems. More on documentation coming soon.
|
6
|
+
|
7
|
+
Check the examples directory for sample cluster configurations.
|
data/examples/cluster.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
cluster_common = %w{ ntp conary sysstat }
|
2
|
+
onpremise_common = %w{ sudo cron monit::disabled }
|
3
|
+
|
4
|
+
cluster :"appliance-cluster" do |cluster|
|
5
|
+
common_classes = cluster_common + onpremise_common
|
6
|
+
common_variables = {}
|
7
|
+
common_resources = {}
|
8
|
+
cluster.node :mylittlewebserver do |node|
|
9
|
+
common_classes.each do |common_class|
|
10
|
+
node.klass common_class
|
11
|
+
end
|
12
|
+
common_variables.each_pair do |key, value|
|
13
|
+
node.variable key, value
|
14
|
+
end
|
15
|
+
common_resources.each_pair do |key, value|
|
16
|
+
node.resource do |resource|
|
17
|
+
resource.type value[:type]
|
18
|
+
resource.name key
|
19
|
+
resource.options value[:options]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
node.klass "webserver"
|
23
|
+
node.variable :appservers, ['123.456.28.1']
|
24
|
+
node.role do |role|
|
25
|
+
role.type :web
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ClassifyCluster
|
2
|
+
module Configurator
|
3
|
+
class Cluster
|
4
|
+
attr_reader :nodes, :name
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@nodes = {}
|
7
|
+
@name = args.first
|
8
|
+
block.call self
|
9
|
+
end
|
10
|
+
def name(value=nil)
|
11
|
+
return @name unless value
|
12
|
+
@name = value
|
13
|
+
end
|
14
|
+
def node(node_name, &block)
|
15
|
+
@nodes[node_name] = ClassifyCluster::Configurator::Node.new(node_name, &block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ClassifyCluster
|
2
|
+
module Configurator
|
3
|
+
class Configuration
|
4
|
+
attr_reader :clusters
|
5
|
+
def initialize(config_path)
|
6
|
+
@clusters = {}
|
7
|
+
eval File.open(config_path).read
|
8
|
+
end
|
9
|
+
|
10
|
+
def cluster(cluster_name, &block)
|
11
|
+
@clusters[cluster_name] = ClassifyCluster::Configurator::Cluster.new(cluster_name, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module ClassifyCluster
|
2
|
+
module Configurator
|
3
|
+
class Node
|
4
|
+
attr_reader :fqdn, :variables, :resources, :classes, :public_ip, :private_ip, :roles, :default
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@variables = {}
|
7
|
+
@resources = []
|
8
|
+
@classes = []
|
9
|
+
@roles = []
|
10
|
+
@fqdn = (args.first.to_s == 'default' ? '' : args.first)
|
11
|
+
@default = args.first.to_s == 'default'
|
12
|
+
block.call self
|
13
|
+
end
|
14
|
+
def default?
|
15
|
+
return @default
|
16
|
+
end
|
17
|
+
def fqdn(value=nil)
|
18
|
+
return @fqdn unless value
|
19
|
+
@fqdn = value
|
20
|
+
end
|
21
|
+
def public_ip(value = nil)
|
22
|
+
return @public_ip unless value
|
23
|
+
@public_ip = value
|
24
|
+
end
|
25
|
+
def private_ip(value = nil)
|
26
|
+
return @private_ip unless value
|
27
|
+
@private_ip = value
|
28
|
+
end
|
29
|
+
def role(&block)
|
30
|
+
@roles << ClassifyCluster::Configurator::Role.new(&block)
|
31
|
+
end
|
32
|
+
def variable(name, value)
|
33
|
+
@variables[name] = value
|
34
|
+
end
|
35
|
+
def resource(&block)
|
36
|
+
@resources << ClassifyCluster::Configurator::Resource.new(&block)
|
37
|
+
end
|
38
|
+
def klass(name)
|
39
|
+
@classes << name
|
40
|
+
end
|
41
|
+
end
|
42
|
+
class Resource
|
43
|
+
attr_reader :type, :name, :options
|
44
|
+
def initialize(*args, &block)
|
45
|
+
@options = {}
|
46
|
+
block.call self
|
47
|
+
end
|
48
|
+
def type(value = nil)
|
49
|
+
return @type unless value
|
50
|
+
@type = value
|
51
|
+
end
|
52
|
+
def name(value = nil)
|
53
|
+
return @name unless value
|
54
|
+
@name = value
|
55
|
+
end
|
56
|
+
def options(value = nil)
|
57
|
+
return @options unless value
|
58
|
+
@options = value
|
59
|
+
end
|
60
|
+
end
|
61
|
+
class Role
|
62
|
+
attr_reader :type, :options
|
63
|
+
def initialize(*args, &block)
|
64
|
+
@options = {}
|
65
|
+
block.call self
|
66
|
+
end
|
67
|
+
def type(value = nil)
|
68
|
+
return @type unless value
|
69
|
+
@type = value
|
70
|
+
end
|
71
|
+
def options(value = nil)
|
72
|
+
return @options unless value
|
73
|
+
@options = value
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ClassifyCluster
|
2
|
+
module Configurator
|
3
|
+
class Resource
|
4
|
+
attr_reader :type, :name, :options
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@options = {}
|
7
|
+
block.call self
|
8
|
+
end
|
9
|
+
def type(value = nil)
|
10
|
+
return @type unless value
|
11
|
+
@type = value
|
12
|
+
end
|
13
|
+
def name(value = nil)
|
14
|
+
return @name unless value
|
15
|
+
@name = value
|
16
|
+
end
|
17
|
+
def options(value = nil)
|
18
|
+
return @options unless value
|
19
|
+
@options = value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ClassifyCluster
|
2
|
+
module Configurator
|
3
|
+
class Role
|
4
|
+
attr_reader :type, :options
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@options = {}
|
7
|
+
block.call self
|
8
|
+
end
|
9
|
+
def type(value = nil)
|
10
|
+
return @type unless value
|
11
|
+
@type = value
|
12
|
+
end
|
13
|
+
def options(value = nil)
|
14
|
+
return @options unless value
|
15
|
+
@options = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,103 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@clusters = {}
|
7
|
-
eval File.open(config_path).read
|
8
|
-
end
|
9
|
-
|
10
|
-
def cluster(cluster_name, &block)
|
11
|
-
@clusters[cluster_name] = ClassifyCluster::Configurator::Cluster.new(cluster_name, &block)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
class Cluster
|
15
|
-
attr_reader :nodes, :name
|
16
|
-
def initialize(*args, &block)
|
17
|
-
@nodes = {}
|
18
|
-
@name = args.first
|
19
|
-
block.call self
|
20
|
-
end
|
21
|
-
def name(value=nil)
|
22
|
-
return @name unless value
|
23
|
-
@name = value
|
24
|
-
end
|
25
|
-
def node(node_name, &block)
|
26
|
-
@nodes[node_name] = ClassifyCluster::Configurator::Node.new(node_name, &block)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
class Node
|
30
|
-
attr_reader :fqdn, :variables, :resources, :classes, :public_ip, :private_ip, :roles, :default
|
31
|
-
def initialize(*args, &block)
|
32
|
-
@variables = {}
|
33
|
-
@resources = []
|
34
|
-
@classes = []
|
35
|
-
@roles = []
|
36
|
-
@fqdn = (args.first.to_s == 'default' ? '' : args.first)
|
37
|
-
@default = args.first.to_s == 'default'
|
38
|
-
block.call self
|
39
|
-
end
|
40
|
-
def default?
|
41
|
-
return @default
|
42
|
-
end
|
43
|
-
def fqdn(value=nil)
|
44
|
-
return @fqdn unless value
|
45
|
-
@fqdn = value
|
46
|
-
end
|
47
|
-
def public_ip(value = nil)
|
48
|
-
return @public_ip unless value
|
49
|
-
@public_ip = value
|
50
|
-
end
|
51
|
-
def private_ip(value = nil)
|
52
|
-
return @private_ip unless value
|
53
|
-
@private_ip = value
|
54
|
-
end
|
55
|
-
def role(&block)
|
56
|
-
@roles << ClassifyCluster::Configurator::Role.new(&block)
|
57
|
-
end
|
58
|
-
def variable(name, value)
|
59
|
-
@variables[name] = value
|
60
|
-
end
|
61
|
-
def resource(&block)
|
62
|
-
@resources << ClassifyCluster::Configurator::Resource.new(&block)
|
63
|
-
end
|
64
|
-
def klass(name)
|
65
|
-
@classes << name
|
66
|
-
end
|
67
|
-
end
|
68
|
-
class Resource
|
69
|
-
attr_reader :type, :name, :options
|
70
|
-
def initialize(*args, &block)
|
71
|
-
@options = {}
|
72
|
-
block.call self
|
73
|
-
end
|
74
|
-
def type(value = nil)
|
75
|
-
return @type unless value
|
76
|
-
@type = value
|
77
|
-
end
|
78
|
-
def name(value = nil)
|
79
|
-
return @name unless value
|
80
|
-
@name = value
|
81
|
-
end
|
82
|
-
def options(value = nil)
|
83
|
-
return @options unless value
|
84
|
-
@options = value
|
85
|
-
end
|
86
|
-
end
|
87
|
-
class Role
|
88
|
-
attr_reader :type, :options
|
89
|
-
def initialize(*args, &block)
|
90
|
-
@options = {}
|
91
|
-
block.call self
|
92
|
-
end
|
93
|
-
def type(value = nil)
|
94
|
-
return @type unless value
|
95
|
-
@type = value
|
96
|
-
end
|
97
|
-
def options(value = nil)
|
98
|
-
return @options unless value
|
99
|
-
@options = value
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
1
|
+
require 'classify_cluster/configurator/configuration.rb'
|
2
|
+
require 'classify_cluster/configurator/cluster.rb'
|
3
|
+
require 'classify_cluster/configurator/node.rb'
|
4
|
+
require 'classify_cluster/configurator/resource.rb'
|
5
|
+
require 'classify_cluster/configurator/role.rb'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classify_cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Cashin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,9 +66,15 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- bin/classify
|
68
68
|
- classify_cluster.gemspec
|
69
|
+
- examples/cluster.rb
|
69
70
|
- lib/classify_cluster.rb
|
70
71
|
- lib/classify_cluster/base.rb
|
71
72
|
- lib/classify_cluster/configurator.rb
|
73
|
+
- lib/classify_cluster/configurator/cluster.rb
|
74
|
+
- lib/classify_cluster/configurator/configuration.rb
|
75
|
+
- lib/classify_cluster/configurator/node.rb
|
76
|
+
- lib/classify_cluster/configurator/resource.rb
|
77
|
+
- lib/classify_cluster/configurator/role.rb
|
72
78
|
- lib/classify_cluster/version.rb
|
73
79
|
- lib/classify_cluster/writers.rb
|
74
80
|
- lib/classify_cluster/writers/capistrano.rb
|