Skip to content

Instantly share code, notes, and snippets.

@danfrost
Created January 28, 2011 10:53
Show Gist options
  • Save danfrost/800109 to your computer and use it in GitHub Desktop.
Save danfrost/800109 to your computer and use it in GitHub Desktop.
module Forecast
# The farm is collected into this object.
class Farm
def initialize(name)
@name = name
@roles = []
end
def add_role(role)
@roles.push role
end
end
def farm(name, &block)
puts "Making a farm called #{name}"
# Set the currect farm
@farm = Farm.new(name)
block.call
end
def region(name)
puts "Region: #{name}"
end
def role(name, &block)
# where are we going to keep all the instance information ?? Some object?
#@role = Role.new(name) << this object is what all the methods will act on
puts "Role: #{@role.inspect}"
block.call
#@farm.add_role @role
#@role = nil
end
# These methods might need to be moved
def has_roles(*roles)
puts "Roles #{roles.join(',')}"
end
def ip(ipvalue)
puts "Role will have static IP: #{ipvalue}"
end
def size(size_value)
puts "Role instance will be of size: #{size_value}"
end
def ebs(path, size)
puts "Role will have EBS mounted on '#{path}' of size #{size}GB"
end
def minimum(number)
puts "Minimum instances will be #{number}"
end
def maximum(number)
puts "Minimum instances will be #{number}"
end
def disk(disksize)
puts "Disk size #{disksize}"
end
module AWS
def ec2(name, &block)
puts "EC2 #{name}"
block.call
end
def rds(name, &block)
puts "RDS #{name}"
end
end
module Rackspace
def cloudserver(name, &block)
puts "CloudServer #{name}"
end
end
module DynamicDNS
def domain(name, &block)
puts "Domain #{name}"
end
end
end
#-- example script --
include Forecast
farm "chem" do
include DynamicDNS
include AWS
region :eu_west_1
ec2 :proxy_varnish do
has_roles :proxy, :varnish
ip "79.79.79.79"
end
ec2 :site do
has_roles :webserver
size :m1small
ebs "/var/www/vhosts/chemical", 100
ebs "/var/www/vhosts/forum", 100
minimum 1
maximum 10
end
rds :ourdb do
size :massive
disk 20
domain "db.chems.3ev.info"
end
include Rackspace
cloudserver :backup do
has_roles :mirror_live
domain "www.12.23.34.123.com"
end
cloudserver :hydrogen do
has_roles :dev, :fullstackweb
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment