spatula 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/spatula/cook.rb CHANGED
@@ -18,11 +18,19 @@ module Spatula
18
18
  ok = sh "ruby -c #{recipe} >/dev/null 2>&1"
19
19
  raise "Syntax error in #{recipe}" if not ok
20
20
  end
21
- sh "rsync -rlP --rsh=\"ssh -p#@port\" --delete --exclude '.*' ./ #@server:#{REMOTE_CHEF_PATH}"
22
- sh "ssh -t -p #@port -A #@server \"cd #{REMOTE_CHEF_PATH}; sudo chef-solo -c config/solo.rb -j config/#@node.json \""
21
+ if @server =~ /^local$/i
22
+ sh chef_cmd
23
+ else
24
+ sh "rsync -rlP --rsh=\"ssh -p#@port\" --delete --exclude '.*' ./ #@server:#{REMOTE_CHEF_PATH}"
25
+ sh "ssh -t -p #@port -A #@server \"cd #{REMOTE_CHEF_PATH}; #{chef_cmd} \""
26
+ end
23
27
  end
24
28
 
25
29
  private
30
+ def chef_cmd
31
+ "sudo chef-solo -c config/solo.rb -j config/#@node.json"
32
+ end
33
+
26
34
  def sh(command)
27
35
  system command
28
36
  end
@@ -5,18 +5,38 @@ module Spatula
5
5
  new(*args).run
6
6
  end
7
7
 
8
- def initialize(server, port=22)
8
+ def initialize(server, port=nil, login=nil, identity=nil)
9
9
  @server = server
10
10
  @port = port
11
+ @port_switch = port ? " -p #{port}" : ''
12
+ @login_switch = login ? "-l #{login}" : ''
13
+ @identity_switch = identity ? %Q|-i "#{identity}"| : ''
11
14
  end
12
15
 
13
- def ssh command
14
- sh %Q|ssh -t -p #@port #@server "#{command.gsub('"', '\\"')}"|
16
+ def ssh(command)
17
+ sh ssh_command(command)
18
+ end
19
+
20
+ def ssh_command(command)
21
+ %Q|ssh -t#@port_switch #@login_switch #@identity_switch #@server "#{command.gsub('"', '\\"')}"|
15
22
  end
16
23
 
17
24
  def run
25
+ send "run_for_#{os}"
26
+ end
27
+
28
+ def os
29
+ etc_issue = `#{ssh_command("cat /etc/issue")}`
30
+ if etc_issue =~ /ubuntu/i
31
+ "ubuntu"
32
+ else
33
+ raise "Sorry, we currently only support ubuntu for preparing. Please fork http://github.com/trotter/spatula and add support for your OS. I'm happy to incorporate pull requests."
34
+ end
35
+ end
36
+
37
+ def run_for_ubuntu
18
38
  ssh "sudo apt-get update"
19
- ssh "sudo aptitude -y install ruby irb ri libopenssl-ruby1.8 libshadow-ruby1.8 ruby1.8-dev gcc g++ rsync"
39
+ ssh "sudo aptitude -y install ruby irb ri libopenssl-ruby1.8 libshadow-ruby1.8 ruby1.8-dev gcc g++ rsync curl"
20
40
  ssh "curl -L 'http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz' | tar xvzf -"
21
41
  ssh "cd rubygems* && sudo ruby setup.rb --no-ri --no-rdoc"
22
42
  ssh "sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem"
data/lib/spatula.rb CHANGED
@@ -35,16 +35,18 @@ module Spatula
35
35
  Search.run(query, options[:start], options[:count])
36
36
  end
37
37
 
38
- desc "cook SERVER NODE", "Cook SERVER with the specification in config/NODE.js"
38
+ desc "cook SERVER NODE", "Cook SERVER with the specification in config/NODE.js. Use local as the server to cook this box."
39
39
  method_options :port => 22
40
40
  def cook(server, node)
41
41
  Cook.run(server, node, options[:port])
42
42
  end
43
43
 
44
44
  desc "prepare SERVER", "Install software/libs required by chef on SERVER"
45
- method_options :port => 22
45
+ method_options :port => nil
46
+ method_options :login => nil
47
+ method_options :identity => nil
46
48
  def prepare(server)
47
- Prepare.run(server, port)
49
+ Prepare.run(server, options[:port], options[:login], options[:identity])
48
50
  end
49
51
 
50
52
  private
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Trotter Cashion
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-07 00:00:00 -05:00
17
+ date: 2010-03-18 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20