spatula 0.0.9 → 0.0.10
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.rb +2 -1
- data/lib/spatula/prepare.rb +24 -9
- data/lib/spatula/ssh_command.rb +2 -1
- metadata +2 -2
data/lib/spatula.rb
CHANGED
@@ -49,8 +49,9 @@ module Spatula
|
|
49
49
|
method_options :login => nil
|
50
50
|
method_options :identity => nil
|
51
51
|
method_options :upload_key => nil
|
52
|
+
method_options :keyfile => :string
|
52
53
|
def prepare(server)
|
53
|
-
Prepare.run(server, options[:port], options[:login], options[:identity], options[:upload_key])
|
54
|
+
Prepare.run(server, options[:port], options[:login], options[:identity], options[:upload_key], options[:keyfile])
|
54
55
|
end
|
55
56
|
|
56
57
|
private
|
data/lib/spatula/prepare.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
# Prepare :server: for chef solo to run on it
|
2
2
|
module Spatula
|
3
3
|
class Prepare < SshCommand
|
4
|
+
|
5
|
+
RUBYGEMS_VERSION = "1.6.2"
|
6
|
+
RUBY_PATH = "1.9/ruby-1.9.2-p180.tar.gz"
|
7
|
+
|
4
8
|
def run
|
9
|
+
|
10
|
+
if @key_file and !@upload_key
|
11
|
+
@upload_key = true
|
12
|
+
end
|
13
|
+
|
5
14
|
upload_ssh_key if @upload_key
|
6
15
|
send "run_for_#{os}"
|
7
16
|
end
|
@@ -50,12 +59,12 @@ module Spatula
|
|
50
59
|
end
|
51
60
|
|
52
61
|
def install_ruby_1_9_2
|
53
|
-
ssh "curl -L 'ftp://ftp.ruby-lang.org//pub/ruby
|
62
|
+
ssh "curl -L 'ftp://ftp.ruby-lang.org//pub/ruby/#{RUBY_PATH}' | tar xvzf -"
|
54
63
|
ssh "cd ruby-1.9.2-* && ./configure && make && #{sudo} make install"
|
55
64
|
end
|
56
65
|
|
57
66
|
def install_rubygems
|
58
|
-
ssh "curl -L 'http://
|
67
|
+
ssh "curl -L 'http://production.cf.rubygems.org/rubygems/rubygems-#{RUBYGEMS_VERSION}.tgz' | tar xvzf -"
|
59
68
|
ssh "cd rubygems* && #{sudo} ruby setup.rb --no-ri --no-rdoc"
|
60
69
|
ssh "#{sudo} ln -sfv /usr/bin/gem1.8 /usr/bin/gem"
|
61
70
|
end
|
@@ -70,15 +79,21 @@ module Spatula
|
|
70
79
|
|
71
80
|
def upload_ssh_key
|
72
81
|
authorized_file = "~/.ssh/authorized_keys"
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
82
|
+
|
83
|
+
unless @key_file
|
84
|
+
%w{rsa dsa}.each do |key_type|
|
85
|
+
filename = "#{ENV['HOME']}/.ssh/id_#{key_type}.pub"
|
86
|
+
if File.exists?(filename)
|
87
|
+
@key_file = filename
|
88
|
+
break
|
89
|
+
end
|
79
90
|
end
|
80
91
|
end
|
81
|
-
|
92
|
+
|
93
|
+
raise "Key file '#{@key_file}' not found: aborting." unless File.exists?(@key_file)
|
94
|
+
|
95
|
+
key = File.open(@key_file).read.split(' ')[0..1].join(' ')
|
96
|
+
|
82
97
|
ssh "mkdir -p .ssh && echo #{key} >> #{authorized_file}"
|
83
98
|
ssh "cat #{authorized_file} | sort | uniq > #{authorized_file}.tmp && mv #{authorized_file}.tmp #{authorized_file}"
|
84
99
|
end
|
data/lib/spatula/ssh_command.rb
CHANGED
@@ -4,13 +4,14 @@ module Spatula
|
|
4
4
|
new(*args).run
|
5
5
|
end
|
6
6
|
|
7
|
-
def initialize(server, port=nil, login=nil, identity=nil, upload_key=nil)
|
7
|
+
def initialize(server, port=nil, login=nil, identity=nil, upload_key=nil, key_file=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
13
|
@upload_key = upload_key
|
14
|
+
@key_file = key_file
|
14
15
|
end
|
15
16
|
|
16
17
|
def ssh(command)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: spatula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Trotter Cashion
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-21 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|