Module: Ec2onrails::CapistranoUtils

Defined in:
lib/ec2onrails/capistrano_utils.rb

Instance Method Summary collapse

Instance Method Details

#hostnames_for_role(role_sym, options = {}) ⇒ Object

return hostnames for the role named role_sym that has the specified options



25
26
27
28
29
30
31
# File 'lib/ec2onrails/capistrano_utils.rb', line 25

def hostnames_for_role(role_sym, options = {})
  role = roles[role_sym]
  unless role
    return []
  end
  role.select{|s| s.options == options}.collect{|s| s.host}
end

#make_admin_role_for(role) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/ec2onrails/capistrano_utils.rb', line 13

def make_admin_role_for(role)
  newrole = "#{role.to_s}_admin".to_sym
  roles[role].each do |srv_def|
    options = srv_def.options.dup
    options[:user] = "admin"
    options[:port] = srv_def.port
    options[:no_release] = true
    role newrole, srv_def.host, options
  end
end

#run_init_script(script, arg) ⇒ Object



8
9
10
11
# File 'lib/ec2onrails/capistrano_utils.rb', line 8

def run_init_script(script, arg)
  # since init scripts might have the execute bit unset by the set_roles script we need to check
  sudo "sh -c 'if [ -x /etc/init.d/#{script} ] ; then /etc/init.d/#{script} #{arg}; fi'"
end

#run_local(command) ⇒ Object



3
4
5
6
# File 'lib/ec2onrails/capistrano_utils.rb', line 3

def run_local(command)
  result = system command
  raise("error: #{$?}") unless result
end