Class: ClassifyCluster::Writers::Capistrano

Inherits:
Object
  • Object
show all
Defined in:
lib/classify_cluster/writers/capistrano.rb

Constant Summary collapse

CLUSTER_ROLE_2_CAP_ROLE =
{
  'db' => 'db',
  'queue' => 'queue',
  'cron' => 'cron',
  'app' => 'app',
  'worker' => 'worker',
  'munin' => 'munin',
  'web' => 'web',
  'push' => 'push',
  'puppet_master' => 'puppet_master',
  'search' => 'elasticsearch',
  'file' => 'file',
  'scheduler' => 'scheduler',
  'sso' => 'sso'
}

Class Method Summary collapse

Class Method Details

.export!(capistrano_configurator, cluster, config_file = ClassifyCluster::Base.default_config_file) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/classify_cluster/writers/capistrano.rb', line 19

def self.export!(capistrano_configurator, cluster, config_file=ClassifyCluster::Base.default_config_file)
  config = ClassifyCluster::Configurator::Configuration.new(config_file).clusters[cluster]
  config.variables.each_pair do |name, value|
    capistrano_configurator.set("puppet_#{name}".to_sym, value)
  end
  config.nodes.each_pair do |name, node|
    roles = node.roles
    next if roles.empty?
    
    roles.each do |role|
      role_name = (CLUSTER_ROLE_2_CAP_ROLE[role.type.to_s] || role.type.to_s)
      capistrano_configurator.role(role_name, node.fqdn, role.options)
      if role_name == 'puppet_master'
        capistrano_configurator.set("puppet_role_puppet_master_fqdn", node.fqdn)
        capistrano_configurator.set("puppet_role_puppet_master_private_ip", node.private_ip)
      end
    end
  end
end