Class: Cuoco::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/cuoco/runner.rb

Constant Summary collapse

SERVER_ROLES =

$CAPISTRANO:HOSTROLES$ is a magic Capistrano placeholder that gets replaced with a comma-delimited list of roles *for each specific server individually*. See Capistrano::Command#replace_placeholders The awk command translates “app,web,db” into “role,role,role” to pass them to Chef

%Q{`echo '$CAPISTRANO:HOSTROLES$' | awk '{sub(/^/,"role["); sub(/$/,"]"); gsub(/,/,"],role["); print}'`}

Instance Method Summary collapse

Constructor Details

#initialize(capistrano) ⇒ Runner

Returns a new instance of Runner.



9
10
11
# File 'lib/cuoco/runner.rb', line 9

def initialize(capistrano)
  @cap = capistrano
end

Instance Method Details

#runObject



13
14
15
# File 'lib/cuoco/runner.rb', line 13

def run
  run_list(SERVER_ROLES)
end

#run_list(roles_and_recipes) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/cuoco/runner.rb', line 17

def run_list(roles_and_recipes)
  if roles_and_recipes.is_a? Array
    roles_and_recipes = roles_and_recipes.join(',')
  end

  @cap.sudo(chef_command(roles_and_recipes), :shell => '/bin/bash')
end