Class: Chake::ConfigManager
- Inherits:
-
Object
- Object
- Chake::ConfigManager
show all
- Defined in:
- lib/chake/config_manager.rb,
lib/chake/config_manager/chef.rb,
lib/chake/config_manager/shell.rb,
lib/chake/config_manager/itamae.rb
Defined Under Namespace
Classes: Chef, Itamae, Shell
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ConfigManager.
7
8
9
|
# File 'lib/chake/config_manager.rb', line 7
def initialize(node)
@node = node
end
|
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
5
6
7
|
# File 'lib/chake/config_manager.rb', line 5
def node
@node
end
|
Class Method Details
.accept?(_node) ⇒ Boolean
60
61
62
|
# File 'lib/chake/config_manager.rb', line 60
def self.accept?(_node)
false
end
|
.all ⇒ Object
64
65
66
|
# File 'lib/chake/config_manager.rb', line 64
def self.all
@subclasses
end
|
.get(node) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/chake/config_manager.rb', line 51
def self.get(node)
available = @subclasses.sort_by(&:priority)
manager = available.find { |c| c.short_name == node.data['config_manager'] }
manager ||= available.find { |c| c.accept?(node) }
raise ArgumentError, "Can't find configuration manager class for node #{node.hostname}. Available: #{available}.join(', ')}" unless manager
manager.new(node)
end
|
.inherited(klass) ⇒ Object
45
46
47
48
49
|
# File 'lib/chake/config_manager.rb', line 45
def self.inherited(klass)
super
@subclasses ||= []
@subclasses << klass
end
|
.init ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/chake/config_manager.rb', line 68
def self.init
skel = Pathname(__FILE__).parent / 'config_manager' / 'skel' / short_name
skel.glob('**/*').each do |source|
target = source.relative_path_from(skel)
if target.exist?
puts "exists: #{target}"
else
if source.directory?
FileUtils.mkdir_p target
else
FileUtils.cp source, target
end
puts "create: #{target}"
end
end
end
|
.priority(new_prioriry = nil) ⇒ Object
41
42
43
|
# File 'lib/chake/config_manager.rb', line 41
def self.priority(new_prioriry = nil)
@priority ||= new_prioriry || 50
end
|
.short_name ⇒ Object
37
38
39
|
# File 'lib/chake/config_manager.rb', line 37
def self.short_name
name.split('::').last.downcase
end
|
Instance Method Details
#apply(config) ⇒ Object
13
|
# File 'lib/chake/config_manager.rb', line 13
def apply(config); end
|
#bootstrap_steps ⇒ Object
27
28
29
30
31
|
# File 'lib/chake/config_manager.rb', line 27
def bootstrap_steps
base = File.join(File.absolute_path(File.dirname(__FILE__)), 'bootstrap')
steps = Dir[File.join(base, '*.sh')] + Dir[File.join(base, name, '*.sh')]
steps.sort_by { |f| File.basename(f) }
end
|
#converge ⇒ Object
11
|
# File 'lib/chake/config_manager.rb', line 11
def converge; end
|
#name ⇒ Object
19
20
21
|
# File 'lib/chake/config_manager.rb', line 19
def name
self.class.short_name
end
|
#needs_upload? ⇒ Boolean
33
34
35
|
# File 'lib/chake/config_manager.rb', line 33
def needs_upload?
true
end
|
#path ⇒ Object
15
16
17
|
# File 'lib/chake/config_manager.rb', line 15
def path
"/var/tmp/#{name}.#{node.username}"
end
|
#to_s ⇒ Object
23
24
25
|
# File 'lib/chake/config_manager.rb', line 23
def to_s
name
end
|