Skip to content

Instantly share code, notes, and snippets.

cloud "frontend-app" do
using :ec2
user_data File.read('instance_data/frontend_app_qa_user_data.json')
#image_id AMI_32_BIT
image_id AMI_64_BIT
instance_type "m1.large"
instances 1..25
security_group do
authorize :from_port => 22, :to_port => 22, :ip_protocol => 'tcp',:group_name => "admin-server-group" ,:owner_id => xx, :network => ""
authorize :from_port => 80, :to_port => 80
cron "add chef-client to crontab to run every 5min" do
command "chef-client >> /etc/sv/chef-client/log/main/current"
user "root"
minute "*/5"
end
#!/usr/bin/ruby
# == Synopsis
# This is a tool to help poolpartyrb and chef set haproxy.conf file.
# It also can list clouds and add the new clouds to the chef server i
# security group in order to let the chef clients connect to the chef server
# TODO: list all the ips of a given cloud and list the passenger process(run
# passenger-status remotly on each server).
# Note: At the moment the script would work only if there is a cloud.rb in
# your cwd.
#
#!/usr/bin/ruby
instances = `ec2-describe-instances --show-empty-fields`
lines = instances.split(/\n/)
running_instances = []
lines.each do |lines|
if lines =~ /^INSTANCE/
fields = lines.split(/\t/)
if fields[5] == 'running'
running_instances << fields[1]
root@domU-12-31-39-09-C4-F4:~# chef-solo -c ~/solo.rb -j ~/chef.json
[Tue, 09 Mar 2010 12:00:03 -0800] INFO: Starting Chef Solo Run
[Tue, 09 Mar 2010 12:00:07 -0800] INFO: Installing package[runit] version 2.0.0-1ubuntu2
[Tue, 09 Mar 2010 12:00:07 -0800] INFO: remote_file[/tmp/chef-solo/preseed/runit/runit-2.0.0-1ubuntu2.seed]: Creating /tmp/chef-solo/preseed/runit/runit-2.0.0-1ubuntu2.seed
[Tue, 09 Mar 2010 12:00:07 -0800] INFO: Pre-seeding package[runit] with package installation instructions.
[Tue, 09 Mar 2010 12:00:13 -0800] INFO: package[runit] sending run action to execute[start-runsvdir] (immediate)
[Tue, 09 Mar 2010 12:00:13 -0800] INFO: Ran execute[start-runsvdir] successfully
[Tue, 09 Mar 2010 12:00:13 -0800] INFO: package[runit] sending nothing action to execute[runit-hup-init] (immediate)
[Tue, 09 Mar 2010 12:00:13 -0800] INFO: Creating directory[/etc/sv/chef-client] at /etc/sv/chef-client
[Tue, 09 Mar 2010 12:00:13 -0800] INFO: Setting mode to 755 for directory[/etc/sv/chef-client]
@Aslan
Aslan / client.rb
Created March 9, 2010 03:57 — forked from fujin/client.rb
# Chef Client Config File
# Automatically grabs configuration from ohai ec2 metadata.
require 'ohai'
require 'json'
o = Ohai::System.new
o.all_plugins
chef_config = JSON.parse(o[:ec2][:userdata])
if chef_config.kind_of?(Array)
#
# Chef Client Config File
#
# Dynamically generated by Chef - local modifications will be replaced
#
require 'ohai'
require 'json'
o = Ohai::System.new
class Company < ActiveRecord::Base
has_many :stocks
validates_uniqueness_of :symbol
attr_accessor :sdata, :formula, :method_name, :m_keys
def load_sdata
if !@sdata or @sdata.empty?
@sdata = Array.new
stocks = self.stocks
stocks.each_with_index do |s,i|
AppUser Load (44.0ms) SELECT * FROM `app_users` WHERE (id = 17480)
AppUserContribution Load (44.9ms)
select sum(direct_amount + karmic_amount) as total
from app_user_contributions
where app_charity_goal_id = 244 and app_user_id in (17480)
AppUser Load (33.7ms) SELECT * FROM `app_users` WHERE (id = 17480)
AppUserContribution Load (46.9ms)
select sum(app_user_contributions.direct_amount + app_user_contributions.karmic_amount) as total
from app_user_contributions inner join app_charity_goals on app_user_contributions.app_charity_goal_id = app_charity_goals.id
where app_charity_goals.app_charity_id = 10 and app_user_contributions.app_user_id in (17480)
pool "cornice" do
cloud "app" do
using :ec2
user_data File.read('app_server_user_data.json')
image_id 'ami-879d71ee'
instances 1..1
security_group "cornice-security" do
authorize :from_port => 22, :to_port => 22
authorize :from_port => 80, :to_port => 80
authorize :from_port => 0, :to_port => 65535, :protocol => 'tcp', :group_name => 'default'