classify_cluster 0.0.2 → 0.0.3
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/examples/cluster.rb +13 -16
- data/lib/classify_cluster/configurator/cluster.rb +10 -1
- data/lib/classify_cluster/configurator/node.rb +0 -34
- data/lib/classify_cluster/version.rb +1 -1
- data/lib/classify_cluster/writers/capistrano.rb +3 -0
- data/lib/classify_cluster/writers/puppet.rb +15 -0
- metadata +4 -4
data/examples/cluster.rb
CHANGED
@@ -2,23 +2,20 @@ cluster_common = %w{ ntp conary sysstat }
|
|
2
2
|
onpremise_common = %w{ sudo cron monit::disabled }
|
3
3
|
|
4
4
|
cluster :"appliance-cluster" do |cluster|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
node.resource do |resource|
|
17
|
-
resource.type value[:type]
|
18
|
-
resource.name key
|
19
|
-
resource.options value[:options]
|
20
|
-
end
|
5
|
+
(cluster_common + onpremise_common).each do |common_class|
|
6
|
+
cluster.klass common_class
|
7
|
+
end
|
8
|
+
{}.each_pair do |key, value|
|
9
|
+
cluster.variable key, value
|
10
|
+
end
|
11
|
+
{}.each_pair do |key, value|
|
12
|
+
cluster.resource do |resource|
|
13
|
+
resource.type value[:type]
|
14
|
+
resource.name key
|
15
|
+
resource.options value[:options]
|
21
16
|
end
|
17
|
+
end
|
18
|
+
cluster.node :"example.com" do |node|
|
22
19
|
node.klass "webserver"
|
23
20
|
node.variable :appservers, ['123.456.28.1']
|
24
21
|
node.role do |role|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ClassifyCluster
|
2
2
|
module Configurator
|
3
3
|
class Cluster
|
4
|
-
attr_reader :nodes, :name
|
4
|
+
attr_reader :nodes, :name, :classes, :variables, :resources
|
5
5
|
def initialize(*args, &block)
|
6
6
|
@nodes = {}
|
7
7
|
@name = args.first
|
@@ -14,6 +14,15 @@ module ClassifyCluster
|
|
14
14
|
def node(node_name, &block)
|
15
15
|
@nodes[node_name] = ClassifyCluster::Configurator::Node.new(node_name, &block)
|
16
16
|
end
|
17
|
+
def variable(name, value)
|
18
|
+
@variables[name] = value
|
19
|
+
end
|
20
|
+
def resource(&block)
|
21
|
+
@resources << ClassifyCluster::Configurator::Resource.new(&block)
|
22
|
+
end
|
23
|
+
def klass(name)
|
24
|
+
@classes << name
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
19
28
|
end
|
@@ -39,39 +39,5 @@ module ClassifyCluster
|
|
39
39
|
@classes << name
|
40
40
|
end
|
41
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
42
|
end
|
77
43
|
end
|
@@ -3,6 +3,9 @@ module ClassifyCluster
|
|
3
3
|
class Capistrano
|
4
4
|
def self.export!(capistrano_configurator, cluster, config_file=ClassifyCluster::Base.default_config_file)
|
5
5
|
config = ClassifyCluster::Configurator::Configuration.new(config_file).clusters[cluster]
|
6
|
+
config.variables.each_pair do |name, value|
|
7
|
+
capistrano_configurator.set("puppet-#{name}".to_sym, value)
|
8
|
+
end
|
6
9
|
config.nodes.each_pair do |name, node|
|
7
10
|
roles = node.roles
|
8
11
|
next if roles.empty?
|
@@ -9,9 +9,21 @@ module ClassifyCluster
|
|
9
9
|
File.open(File.join(export_to_folder, "#{cluster.name}.pp"), 'w') do |file|
|
10
10
|
cluster.nodes.each_pair do |fqdn, node|
|
11
11
|
file.write(output(%Q%node "#{node.default? ? 'default' : node.fqdn}" {%))
|
12
|
+
cluster.variables.each_pair do |key, value|
|
13
|
+
file.write(output("$#{key}=#{value.inspect}", :indent => 1))
|
14
|
+
end
|
12
15
|
node.variables.each_pair do |key, value|
|
13
16
|
file.write(output("$#{key}=#{value.inspect}", :indent => 1))
|
14
17
|
end
|
18
|
+
cluster.resources.each do |resource|
|
19
|
+
file.write(output("#{resource.type} { #{resource.name.inspect}:", :indent => 1))
|
20
|
+
count = 0
|
21
|
+
resource.options.each_pair do |key, value|
|
22
|
+
file.write(output("#{key} => #{value.inspect}#{"," if count >= resource.options.size}", :indent => 2))
|
23
|
+
count += 1
|
24
|
+
end
|
25
|
+
file.write(output("}", :indent => 1))
|
26
|
+
end
|
15
27
|
node.resources.each do |resource|
|
16
28
|
file.write(output("#{resource.type} { #{resource.name.inspect}:", :indent => 1))
|
17
29
|
count = 0
|
@@ -21,6 +33,9 @@ module ClassifyCluster
|
|
21
33
|
end
|
22
34
|
file.write(output("}", :indent => 1))
|
23
35
|
end
|
36
|
+
cluster.classes.each do |klass|
|
37
|
+
file.write(output("include #{klass}", :indent => 1))
|
38
|
+
end
|
24
39
|
node.classes.each do |klass|
|
25
40
|
file.write(output("include #{klass}", :indent => 1))
|
26
41
|
end
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
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-
|
18
|
+
date: 2010-11-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|