spatula 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spatula.rb +4 -3
- data/lib/spatula/cook.rb +13 -2
- data/lib/spatula/prepare.rb +36 -16
- metadata +4 -20
data/lib/spatula.rb
CHANGED
@@ -22,7 +22,7 @@ module Spatula
|
|
22
22
|
def install(name)
|
23
23
|
file = JSON.parse(get_version_info(name))["file"]
|
24
24
|
filename = File.basename(file)
|
25
|
-
# Use ENV['HOME'] as the base here
|
25
|
+
# Use ENV['HOME'] as the base here
|
26
26
|
tarball_dir = "#{ENV['HOME']}/.spatula/cookbook_tarballs"
|
27
27
|
FileUtils.mkdir_p(tarball_dir)
|
28
28
|
system "curl #{file} -o #{tarball_dir}/#{filename}"
|
@@ -36,11 +36,12 @@ module Spatula
|
|
36
36
|
end
|
37
37
|
|
38
38
|
desc "cook SERVER NODE", "Cook SERVER with the specification in config/NODE.js. Use local as the server to cook this box."
|
39
|
-
method_options :port => nil
|
39
|
+
method_options :port => nil
|
40
40
|
method_options :login => nil
|
41
41
|
method_options :identity => nil
|
42
|
+
method_options :log_level => nil
|
42
43
|
def cook(server, node)
|
43
|
-
Cook.run(server, node, options[:port], options[:login], options[:identity])
|
44
|
+
Cook.run(server, node, options[:port], options[:login], options[:identity], options[:log_level])
|
44
45
|
end
|
45
46
|
|
46
47
|
desc "prepare SERVER", "Install software/libs required by chef on SERVER"
|
data/lib/spatula/cook.rb
CHANGED
@@ -3,9 +3,10 @@ module Spatula
|
|
3
3
|
REMOTE_CHEF_PATH = "/tmp/chef-solo" # Where to find upstream cookbooks
|
4
4
|
|
5
5
|
class Cook < SshCommand
|
6
|
-
def initialize(server, node, port=nil, login=nil, identity=nil)
|
6
|
+
def initialize(server, node, port=nil, login=nil, identity=nil, log_level=nil)
|
7
7
|
super(server, port, login, identity)
|
8
8
|
@node = node
|
9
|
+
@log_level = log_level
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
@@ -14,6 +15,16 @@ module Spatula
|
|
14
15
|
raise "Syntax error in #{recipe}" if not ok
|
15
16
|
end
|
16
17
|
|
18
|
+
Dir["**/*.json"].each do |json|
|
19
|
+
begin
|
20
|
+
require 'json'
|
21
|
+
# parse without instantiating Chef classes
|
22
|
+
JSON.parse File.read(json), :create_additions => false
|
23
|
+
rescue => error
|
24
|
+
raise "Syntax error in #{json}: #{error.message}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
17
28
|
if @server =~ /^local$/i
|
18
29
|
sh chef_cmd
|
19
30
|
else
|
@@ -24,7 +35,7 @@ module Spatula
|
|
24
35
|
|
25
36
|
private
|
26
37
|
def chef_cmd
|
27
|
-
"sudo chef-solo -c config/solo.rb -j config/#@node.json"
|
38
|
+
"sudo chef-solo -c config/solo.rb -j config/#@node.json -l #{ @log_level || 'info'}"
|
28
39
|
end
|
29
40
|
end
|
30
41
|
end
|
data/lib/spatula/prepare.rb
CHANGED
@@ -15,6 +15,8 @@ module Spatula
|
|
15
15
|
"debian"
|
16
16
|
when /fedora/i
|
17
17
|
"fedora"
|
18
|
+
when /CentOS/i
|
19
|
+
"centos"
|
18
20
|
when ""
|
19
21
|
raise "Couldn't get system info from /etc/issue. Please check your SSH credentials."
|
20
22
|
else
|
@@ -23,29 +25,47 @@ module Spatula
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def run_for_ubuntu
|
26
|
-
ssh "sudo apt-get update"
|
27
|
-
ssh "sudo
|
28
|
-
|
29
|
-
|
30
|
-
ssh "sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem"
|
31
|
-
|
32
|
-
ssh "sudo gem install rdoc chef ohai --no-ri --no-rdoc --source http://gems.opscode.com --source http://gems.rubyforge.org"
|
28
|
+
ssh "#{sudo} apt-get update"
|
29
|
+
ssh "#{sudo} apt-get install -y ruby irb ri libopenssl-ruby1.8 libshadow-ruby1.8 ruby1.8-dev gcc g++ rsync curl"
|
30
|
+
install_rubygems
|
31
|
+
install_chef
|
33
32
|
end
|
34
33
|
|
35
34
|
def run_for_debian
|
36
|
-
ssh
|
37
|
-
ssh
|
38
|
-
|
39
|
-
|
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"
|
35
|
+
ssh "#{sudo} apt-get update"
|
36
|
+
ssh "#{sudo} apt-get install -y build-essential zlib1g-dev libssl-dev libreadline5-dev curl rsync"
|
37
|
+
install_rubygems
|
38
|
+
install_chef
|
43
39
|
end
|
44
40
|
|
45
41
|
def run_for_fedora
|
46
42
|
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
|
-
|
43
|
+
ssh "#{sudo} yum install -y make gcc rsync sudo openssl-devel rubygems ruby-devel ruby-shadow curl"
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_for_centos
|
47
|
+
ssh "#{sudo} yum install -y make gcc rsync sudo openssl-devel curl"
|
48
|
+
install_ruby_1_9_2
|
49
|
+
install_chef
|
50
|
+
end
|
51
|
+
|
52
|
+
def install_ruby_1_9_2
|
53
|
+
ssh "curl -L 'ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p136.tar.gz' | tar xvzf -"
|
54
|
+
ssh "cd ruby-1.9.2-* && ./configure && make && #{sudo} make install"
|
55
|
+
end
|
56
|
+
|
57
|
+
def install_rubygems
|
58
|
+
ssh "curl -L 'http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz' | tar xvzf -"
|
59
|
+
ssh "cd rubygems* && #{sudo} ruby setup.rb --no-ri --no-rdoc"
|
60
|
+
ssh "#{sudo} ln -sfv /usr/bin/gem1.8 /usr/bin/gem"
|
61
|
+
end
|
62
|
+
|
63
|
+
def install_chef
|
64
|
+
ssh "#{sudo} gem install rdoc chef ohai --no-ri --no-rdoc --source http://gems.opscode.com --source http://gems.rubyforge.org"
|
65
|
+
end
|
66
|
+
|
67
|
+
def sudo
|
68
|
+
ssh('which sudo > /dev/null 2>&1') ? 'sudo' : ''
|
49
69
|
end
|
50
70
|
|
51
71
|
def upload_ssh_key
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spatula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 8
|
9
|
-
version: 0.0.8
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.9
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Trotter Cashion
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-02-20 00:00:00 -05:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 13
|
31
|
-
- 4
|
32
24
|
version: 0.13.4
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -40,10 +32,6 @@ dependencies:
|
|
40
32
|
requirements:
|
41
33
|
- - ">="
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 1
|
45
|
-
- 2
|
46
|
-
- 4
|
47
35
|
version: 1.2.4
|
48
36
|
type: :runtime
|
49
37
|
version_requirements: *id002
|
@@ -77,21 +65,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
65
|
requirements:
|
78
66
|
- - ">="
|
79
67
|
- !ruby/object:Gem::Version
|
80
|
-
segments:
|
81
|
-
- 0
|
82
68
|
version: "0"
|
83
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
70
|
none: false
|
85
71
|
requirements:
|
86
72
|
- - ">="
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
segments:
|
89
|
-
- 0
|
90
74
|
version: "0"
|
91
75
|
requirements: []
|
92
76
|
|
93
77
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.
|
78
|
+
rubygems_version: 1.5.0
|
95
79
|
signing_key:
|
96
80
|
specification_version: 3
|
97
81
|
summary: Command line helper app for use with Chef
|