spatula 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -2,7 +2,7 @@ h1. Spatula
2
2
 
3
3
  Spatula is a command line helper app for use with "Chef":http://www.opscode.com/chef. It currently lets you search and install cookbooks from http://cookbooks.opscode.com. It does not yet implement the full API, but that will be coming in future versions (as I need it). If you need it to support the full API *right now*, please make it do so and send me a pull request :-)
4
4
 
5
- Spatula is really, really alpha. It does not handle errors at all, but it works pretty well given that you hand it the correct input. Please give it a try and pretty please fork it and make it better.
5
+ Spatula is really, really alpha. It does not handle errors at all, but it works pretty well given that you hand it the correct input. Please give it a try and pretty please fork it and make it better.
6
6
 
7
7
  h1. Installation
8
8
 
@@ -11,12 +11,12 @@ You can get spatula from gemcutter.
11
11
  <pre>
12
12
  # Gemcutter:
13
13
  # Follow the instructions on http://gemcutter.org/ then...
14
- gem install spatula
14
+ gem install spatula
15
15
  </pre>
16
16
 
17
17
  h1. Usage
18
18
 
19
- Spatula currently supports 3 commands: search, show, and install.
19
+ Spatula currently supports 6 commands: search, show, install, prepare, and cook.
20
20
 
21
21
  <pre>
22
22
  $ spatula search apache2
@@ -25,19 +25,28 @@ apache2 Installs and configures all aspects of apache2 using Debian style symlin
25
25
 
26
26
  $ spatula show apache2
27
27
  name: apache2
28
- average_rating:
28
+ average_rating:
29
29
  category: Web Servers
30
30
  created_at: 2009-10-25T23:47:55Z
31
31
  updated_at: 2009-10-25T23:47:55Z
32
32
  maintainer: jtimberman
33
33
  latest_version: http://cookbooks.opscode.com/api/v1/cookbooks/apache2/versions/0_9_1
34
- external_url:
34
+ external_url:
35
35
  versions: http://cookbooks.opscode.com/api/v1/cookbooks/apache2/versions/0_9_1
36
36
  description: Installs and configures all aspects of apache2 using Debian style symlinks with helper definitions
37
37
 
38
38
  $ spatula install apache2
39
39
  ... downloads the apache2 cookbook and installs it into $(pwd)/cookbooks ...
40
40
  ... also creates a $(pwd)/cookbook_tarballs dir to store the download ...
41
+
42
+ $ spatula prepare user@192.168.1.101
43
+ ... installs ruby, chef and dependencies on 192.168.1.101
44
+ ... starts by adding your ssh public key to authorized_keys
45
+
46
+ $ spatula cook user@192.168.1.101 <node>
47
+ ... uploads all of the files in the current directory to /tmp/chef-solo/
48
+ ... expects solo.rb and <node>.json to live in ./config
49
+
41
50
  </pre>
42
51
 
43
52
  h1. About
data/lib/spatula.rb CHANGED
@@ -47,8 +47,9 @@ module Spatula
47
47
  method_options :port => nil
48
48
  method_options :login => nil
49
49
  method_options :identity => nil
50
+ method_options :upload_key => nil
50
51
  def prepare(server)
51
- Prepare.run(server, options[:port], options[:login], options[:identity])
52
+ Prepare.run(server, options[:port], options[:login], options[:identity], options[:upload_key])
52
53
  end
53
54
 
54
55
  private
@@ -2,15 +2,23 @@
2
2
  module Spatula
3
3
  class Prepare < SshCommand
4
4
  def run
5
+ upload_ssh_key if @upload_key
5
6
  send "run_for_#{os}"
6
7
  end
7
8
 
8
9
  def os
9
10
  etc_issue = `#{ssh_command("cat /etc/issue")}`
10
- if etc_issue =~ /ubuntu/i
11
+ case etc_issue
12
+ when /ubuntu/i
11
13
  "ubuntu"
14
+ when /debian/i
15
+ "debian"
16
+ when /fedora/i
17
+ "fedora"
18
+ when ""
19
+ raise "Couldn't get system info from /etc/issue. Please check your SSH credentials."
12
20
  else
13
- 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."
21
+ raise "Sorry, we currently only support prepare on ubuntu, debian & fedora. Please fork http://github.com/trotter/spatula and add support for your OS. I'm happy to incorporate pull requests."
14
22
  end
15
23
  end
16
24
 
@@ -23,5 +31,36 @@ module Spatula
23
31
 
24
32
  ssh "sudo gem install rdoc chef ohai --no-ri --no-rdoc --source http://gems.opscode.com --source http://gems.rubyforge.org"
25
33
  end
34
+
35
+ def run_for_debian
36
+ ssh 'sudo apt-get update'
37
+ ssh 'sudo apt-get install -y build-essential zlib1g-dev libssl-dev libreadline5-dev curl rsync screen vim'
38
+ ssh 'curl -L http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz | tar xzvf -'
39
+ # install REE 1.8.7 (and rubygems and irb and rake) to /usr
40
+ ssh 'cd ruby-enterprise-1.8.7-2010.02 && sudo echo -e "\n/usr\n" | ./installer'
41
+
42
+ ssh "sudo gem install rdoc chef ohai --no-ri --no-rdoc --source http://gems.opscode.com --source http://gems.rubyforge.org"
43
+ end
44
+
45
+ def run_for_fedora
46
+ sudo = ssh('which sudo > /dev/null 2>&1') ? 'sudo' : ''
47
+ ssh "#{sudo} yum install -y make gcc rsync sudo openssl-devel rubygems ruby-devel ruby-shadow"
48
+ ssh "#{sudo} gem install chef --no-ri --no-rdoc --source http://gems.opscode.com --source http://gems.rubyforge.org"
49
+ end
50
+
51
+ def upload_ssh_key
52
+ authorized_file = "~/.ssh/authorized_keys"
53
+ key_file = nil
54
+ %w{rsa dsa}.each do |key_type|
55
+ filename = "#{ENV['HOME']}/.ssh/id_#{key_type}.pub"
56
+ if File.exists?(filename)
57
+ key_file = filename
58
+ break
59
+ end
60
+ end
61
+ key = File.open(key_file).read.split(' ')[0..1].join(' ')
62
+ ssh "mkdir -p .ssh && echo #{key} >> #{authorized_file}"
63
+ ssh "cat #{authorized_file} | sort | uniq > #{authorized_file}.tmp && mv #{authorized_file}.tmp #{authorized_file}"
64
+ end
26
65
  end
27
66
  end
@@ -4,12 +4,13 @@ module Spatula
4
4
  new(*args).run
5
5
  end
6
6
 
7
- def initialize(server, port=nil, login=nil, identity=nil)
7
+ def initialize(server, port=nil, login=nil, identity=nil, upload_key=nil)
8
8
  @server = server
9
9
  @port = port
10
10
  @port_switch = port ? " -p #{port}" : ''
11
11
  @login_switch = login ? "-l #{login}" : ''
12
12
  @identity_switch = identity ? %Q|-i "#{identity}"| : ''
13
+ @upload_key = upload_key
13
14
  end
14
15
 
15
16
  def ssh(command)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Trotter Cashion
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-05 00:00:00 -04:00
17
+ date: 2010-10-26 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: thor
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -35,6 +36,7 @@ dependencies:
35
36
  name: json
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
@@ -71,6 +73,7 @@ rdoc_options: []
71
73
  require_paths:
72
74
  - lib
73
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
74
77
  requirements:
75
78
  - - ">="
76
79
  - !ruby/object:Gem::Version
@@ -78,6 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
81
  - 0
79
82
  version: "0"
80
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
81
85
  requirements:
82
86
  - - ">="
83
87
  - !ruby/object:Gem::Version
@@ -87,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
91
  requirements: []
88
92
 
89
93
  rubyforge_project:
90
- rubygems_version: 1.3.6
94
+ rubygems_version: 1.3.7
91
95
  signing_key:
92
96
  specification_version: 3
93
97
  summary: Command line helper app for use with Chef