class Chake::ConfigManager
Attributes
node[R]
Public Class Methods
accept?(_node)
click to toggle source
# File lib/chake/config_manager.rb, line 64 def self.accept?(_node) false end
all()
click to toggle source
# File lib/chake/config_manager.rb, line 68 def self.all @subclasses end
get(node)
click to toggle source
# File lib/chake/config_manager.rb, line 55 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)
click to toggle source
Calls superclass method
# File lib/chake/config_manager.rb, line 49 def self.inherited(klass) super @subclasses ||= [] @subclasses << klass end
init()
click to toggle source
# File lib/chake/config_manager.rb, line 72 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
new(node)
click to toggle source
# File lib/chake/config_manager.rb, line 7 def initialize(node) @node = node end
priority(new_priority = nil)
click to toggle source
# File lib/chake/config_manager.rb, line 45 def self.priority(new_priority = nil) @priority ||= new_priority || 50 end
short_name()
click to toggle source
# File lib/chake/config_manager.rb, line 37 def self.short_name name.split('::').last.gsub(/([[:lower:]])([[:upper:]])/) do first = Regexp.last_match(1) last = Regexp.last_match(2).downcase "#{first}-#{last}" end.downcase end
Public Instance Methods
apply(config)
click to toggle source
# File lib/chake/config_manager.rb, line 13 def apply(config); end
bootstrap_steps()
click to toggle source
# 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()
click to toggle source
# File lib/chake/config_manager.rb, line 11 def converge; end
name()
click to toggle source
# File lib/chake/config_manager.rb, line 19 def name self.class.short_name end
needs_upload?()
click to toggle source
# File lib/chake/config_manager.rb, line 33 def needs_upload? true end
path()
click to toggle source
# File lib/chake/config_manager.rb, line 15 def path "/var/tmp/#{name}.#{node.username}" end
to_s()
click to toggle source
# File lib/chake/config_manager.rb, line 23 def to_s name end