Skip to content
Browse files

remove all chef/role stuff

  • Loading branch information...
1 parent f062cba commit 554bd79bacfbf098205dda8abd54522087512093 @adamwiggins committed
Showing with 2 additions and 101 deletions.
  1. +0 −42 bin/sumo
  2. +0 −3 lib/all.rb
  3. +0 −4 lib/config.rb
  4. +2 −52 lib/instance.rb
View
42 bin/sumo
@@ -15,15 +15,6 @@ class CLI < Thor
task("Wait for ssh") { inst.wait_for_ssh }
task("Attaching ip") { inst.attach_ip } if inst.elastic_ip
task("Attaching volumes") { inst.attach_volumes } if inst.has_volumes?
-
- if inst.has_roles?
- task("Bootstrap chef") { inst.bootstrap_chef }
- inst.roles.each do |role|
- task("Setup #{role}") { inst.setup_role(role) }
- end
- puts
- display_resources(inst)
- end
end
end
@@ -40,14 +31,6 @@ class CLI < Thor
end
end
- desc "resources [NAME]", "show resources exported by an instance"
- def resources(*names)
- Sumo::Instance.search(*names).each do |inst|
- inst.wait_for_ssh
- display_resources(inst)
- end
- end
-
desc "create NAME --opt1=value1 --opt2=value2", "create a persistent instance"
Sumo::Instance.attrs.each do |a|
method_option a, :type => :string, :default => nil, :required => false
@@ -85,21 +68,6 @@ class CLI < Thor
end
end
- desc "bootstrap [name]", "bootstrap chef and cookbooks"
- def bootstrap(name=nil)
- inst = find_instance(name)
- task("Bootstrap chef") { inst.bootstrap_chef }
- end
-
- desc "role ROLE [NAME]", "setup instance as a role"
- def role(role, name=nil)
- inst = find_instance(name)
- ## FIXME should record this
- task "Setup #{role}" do
- inst.setup_role
- end
- end
-
desc "set [NAMES] --opt1=value1 --opt2=value2", "set config var for an instance"
Sumo::Instance.attrs.each do |a|
method_option a, :type => :string, :default => nil, :required => false
@@ -226,16 +194,6 @@ class CLI < Thor
result
end
- def display_resources(inst)
- resources = inst.fetch_resources
- unless resources.empty?
- puts "Your instance is exporting the following resources:"
- resources.each do |resource|
- puts " #{resource}"
- end
- end
- end
-
def instance_id_to_sumo(instance_id)
result = "" if instance_id.nil?
result ||= Sumo::Instance.all.detect { |i| i.instance_id == instance_id }
View
3 lib/all.rb
@@ -1,13 +1,10 @@
-
require 'rubygems'
require 'aws'
require 'right_aws'
require 'sdb/active_sdb'
-#require 'simple_record'
require 'yaml'
require 'socket'
require 'json'
require File.dirname(__FILE__) + '/config'
require File.dirname(__FILE__) + '/instance'
-
View
4 lib/config.rb
@@ -15,10 +15,6 @@ def instance_defaults
}
end
- def cookbooks_url
- config["cookbooks_url"] || "git://github.com/adamwiggins/chef-cookbooks.git"
- end
-
def security_group
config["security_group"] || "sumo"
end
View
54 lib/instance.rb
@@ -29,7 +29,7 @@ def update_attributes!(args)
end
def all_attrs
- [:name, :ami32, :ami64, :instance_type, :instance_id, :state, :availability_zone, :key_name, :role_list, :security_group, :user, :volumes_json, :elastic_ip, :user_data]
+ [:name, :ami32, :ami64, :instance_type, :instance_id, :state, :availability_zone, :key_name, :security_group, :user, :volumes_json, :elastic_ip, :user_data]
end
def initialize(attrs={})
@@ -105,7 +105,6 @@ def launch
wait_for_ssh
attach_ip
attach_volumes
- setup_roles
end
def terminate
@@ -163,41 +162,6 @@ def wait_for_ssh
end
end
- def bootstrap_chef
- commands = [
- 'sudo apt-get update',
- 'sudo apt-get autoremove -y',
- 'sudo apt-get install -y ruby ruby-dev rubygems git-core',
- 'sudo gem sources -a http://gems.opscode.com',
- 'sudo gem install chef ohai --no-rdoc --no-ri',
- "git clone #{Config.cookbooks_url}",
- ]
- ssh(commands)
- end
-
- def roles
- @roles ||= role_list.split(",") rescue []
- end
-
- def has_roles?
- not roles.empty?
- end
-
- def setup_roles
- return [] unless has_roles?
- bootstrap_chef
- roles.each { |r| setup_role(r) }
- fetch_resources
- end
-
- def setup_role(r)
- commands = [
- "cd chef-cookbooks",
- "sudo /var/lib/gems/1.8/bin/chef-solo -c config.json -j roles/#{r}.json"
- ]
- ssh(commands)
- end
-
def ssh(cmds)
IO.popen("ssh -i #{Config.keypair_file} #{user}@#{hostname} > ~/.sumo/ssh.log 2>&1", "w") do |pipe|
pipe.puts cmds.join(' && ')
@@ -207,13 +171,6 @@ def ssh(cmds)
end
end
- def fetch_resources
- cmd = "ssh -i #{Config.keypair_file} #{user}@#{hostname} 'sudo cat /root/resources' 2>&1"
- out = IO.popen(cmd, 'r') { |pipe| pipe.read }
- abort "failed to read resources, output:\n#{out}" unless $?.success?
- parse_resources(out)
- end
-
def add_ip(public_ip)
## TODO - make sure its not in use
update_attributes! :elastic_ip => public_ip
@@ -242,12 +199,6 @@ def add_volume(volume_id, device)
Config.ec2.attach_volume(volume_id, instance_id, device) if running?
end
- def parse_resources(raw)
- raw.split("\n").map do |line|
- line.gsub(/localhost/, hostname)
- end
- end
-
def connect_ssh
system "ssh -i #{Sumo::Config.keypair_file} #{user}@#{hostname}"
if $?.success?
@@ -256,13 +207,12 @@ def connect_ssh
end
def self.attrs
- [:ami32, :ami64, :instance_type, :availability_zone, :key_name, :role_list, :security_group, :user, :user_data]
+ [:ami32, :ami64, :instance_type, :availability_zone, :key_name, :security_group, :user, :user_data]
end
def refresh
@ec2 = nil
@volumes = nil
- @roles = nil
reload
end

0 comments on commit 554bd79

Please sign in to comment.
Something went wrong with that request. Please try again.