Class: BuckKnife::Commands::Capistrano

Inherits:
Struct
  • Object
show all
Includes:
Base
Defined in:
lib/buckknife/commands/capistrano.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#base_run_list, #build_run_list, #command, #to_s

Instance Attribute Details

#projectObject

Returns the value of attribute project

Returns:

  • (Object)

    the current value of project



5
6
7
# File 'lib/buckknife/commands/capistrano.rb', line 5

def project
  @project
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/buckknife/commands/capistrano.rb', line 8

def call
  environments = []
  project.environments.each do |env|

    app_nodes = env.nodes.select { |n| n.group == "app" }.each { |n| n.address = fetch_ip(n.name) }
    job_nodes = env.nodes.select { |n| n.group == "job" }.each { |n| n.address = fetch_ip(n.name) }

    unless app_nodes.empty? && job_nodes.empty?
      environment               = {:app_servers => app_nodes, :job_servers => job_nodes}
      environment[:primary_db]  = ( job_nodes.empty? ? app_nodes.first : job_nodes.first )
      environment[:name]        = env.name
      environment[:domain_name] = env.domain_name
      environments << environment
    end
  end

  deploy_environments_template = BuckKnife.template_root.join("deploy_environments.rb.erb").read
  return ERB.new(deploy_environments_template, nil, '%>').result(binding)
end