Module: Rig::Capistrano

Defined in:
lib/rig/capistrano.rb

Instance Method Summary collapse

Instance Method Details

#serversObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rig/capistrano.rb', line 11

def servers
  env     = Rig.config[:environment]
  role    = Rig.config[:role]
  servers = Rig::Model::Environment.find(env).servers
  list    = role == 'all' ? servers : servers.select { |s| (s.tags['Roles']||"").split(",").include?(role) }

  raise "Rig could not find any servers matching environment=#{env} and role=#{role}" unless list && list.count > 0
  list.each do |s|
    server "#{s.tags['Name']}.#{Rig.get_config(:dns_zone)}", :web, :app
  end
rescue => e
  puts "*** servers not found: #{e.message}"
end