Module: Awsborn::Chef::Rake

Defined in:
lib/awsborn/rake.rb

Overview

Just add a ‘Rakefile` in the same directory as your server definition file.

require 'awsborn'
include Awsborn::Chef::Rake
require './servers'

You are now able to run ‘rake` to start all servers and run Chef on each of them. Other rake tasks include:

  • ‘rake chef` - Run chef on all servers, or the ones specified with `host=name1,name2`.

  • ‘rake chef:debug` - Ditto, but with chef’s log level set to ‘debug`.

  • ‘rake start` - Start all servers (or host=name1,name2) but don’t run ‘chef`.

You can use ‘server=name1,name2` as a synonym for `host=…`

Instance Method Summary collapse

Instance Method Details

#create_cookbook(dir) ⇒ Object

:nodoc:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/awsborn/rake.rb', line 92

def create_cookbook(dir) #:nodoc:
  raise "Must provide a cookbook=" unless ENV["cookbook"]
  puts "** Creating cookbook #{ENV["cookbook"]}"
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "attributes")}" 
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "recipes")}" 
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "definitions")}" 
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "libraries")}" 
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "files", "default")}" 
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "templates", "default")}" 

  unless File.exists?(File.join(dir, ENV["cookbook"], "recipes", "default.rb"))
    open(File.join(dir, ENV["cookbook"], "recipes", "default.rb"), "w") do |file|
      file.puts <<-EOH
#
# Cookbook Name:: #{ENV["cookbook"]}
# Recipe:: default
#
EOH
    end
  end
end

#default_clusterObject

:nodoc:



20
21
22
23
# File 'lib/awsborn/rake.rb', line 20

def default_cluster #:nodoc:
  default_klass = Awsborn::Server.children.first
  default_klass.clusters.first
end

#framed(message) ⇒ Object

:nodoc:



118
119
120
# File 'lib/awsborn/rake.rb', line 118

def framed (message) #:nodoc:
  '*' * (4 + message.length) + "\n* #{message} *\n" + '*' * (4 + message.length)
end

#get_hosts(args) ⇒ Object

:nodoc:



114
115
116
# File 'lib/awsborn/rake.rb', line 114

def get_hosts (args) #:nodoc:
  args[:host] && args[:host].split(',') || args[:server] && args[:server].split(',')
end