knife-solo 0.0.6 → 0.0.7
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/chef/knife/cook.rb +12 -13
- data/lib/chef/knife/prepare.rb +1 -6
- data/lib/knife-solo/bootstraps/linux.rb +2 -2
- data/lib/knife-solo/info.rb +1 -1
- data/lib/knife-solo/ssh_command.rb +16 -7
- metadata +13 -13
data/lib/chef/knife/cook.rb
CHANGED
@@ -18,26 +18,16 @@ class Chef
|
|
18
18
|
|
19
19
|
def run
|
20
20
|
super
|
21
|
-
|
22
21
|
check_syntax
|
23
|
-
|
24
22
|
Chef::Config.from_file('solo.rb')
|
25
|
-
|
23
|
+
check_chef_version
|
26
24
|
rsync_kitchen
|
27
|
-
|
28
25
|
add_patches
|
29
|
-
|
30
|
-
check_chef_version
|
31
|
-
|
32
|
-
logging_arg = "-l debug" if config[:verbosity] > 0
|
33
|
-
stream_command <<-BASH
|
34
|
-
#{sudo} chef-solo -c #{chef_path}/solo.rb \
|
35
|
-
-j #{chef_path}/#{node_config} \
|
36
|
-
#{logging_arg}
|
37
|
-
BASH
|
26
|
+
cook
|
38
27
|
end
|
39
28
|
|
40
29
|
def check_syntax
|
30
|
+
ui.msg('Checking cookbook syntax...')
|
41
31
|
Dir["**/*.rb"].each do |recipe|
|
42
32
|
ok = system "ruby -c #{recipe} >/dev/null 2>&1"
|
43
33
|
raise "Syntax error in #{recipe}" if not ok
|
@@ -84,6 +74,15 @@ class Chef
|
|
84
74
|
BASH
|
85
75
|
raise "The chef gem on #{host} is out of date. Please run `#{$0} prepare #{ssh_args}` to upgrade Chef to #{constraint}." unless result.success?
|
86
76
|
end
|
77
|
+
|
78
|
+
def cook
|
79
|
+
logging_arg = "-l debug" if config[:verbosity] > 0
|
80
|
+
stream_command <<-BASH
|
81
|
+
sudo chef-solo -c #{chef_path}/solo.rb \
|
82
|
+
-j #{chef_path}/#{node_config} \
|
83
|
+
#{logging_arg}
|
84
|
+
BASH
|
85
|
+
end
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
data/lib/chef/knife/prepare.rb
CHANGED
@@ -36,7 +36,7 @@ module KnifeSolo::Bootstraps
|
|
36
36
|
repo_path = "/rbel6"
|
37
37
|
end
|
38
38
|
installed = "is already installed"
|
39
|
-
result = run_command("
|
39
|
+
result = run_command("sudo rpm -Uvh #{repo_url}#{repo_path}")
|
40
40
|
raise result.stderr_or_stdout unless result.success? || result.stdout.match(installed)
|
41
41
|
end
|
42
42
|
|
@@ -44,7 +44,7 @@ module KnifeSolo::Bootstraps
|
|
44
44
|
ui.msg("Installing required packages...")
|
45
45
|
add_yum_repos
|
46
46
|
@packages = %w(rubygem-chef rsync)
|
47
|
-
run_command("
|
47
|
+
run_command("sudo yum -y install #{package_list}")
|
48
48
|
end
|
49
49
|
|
50
50
|
def debian_gem_install
|
data/lib/knife-solo/info.rb
CHANGED
@@ -125,14 +125,20 @@ module KnifeSolo
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
def
|
129
|
-
return @
|
130
|
-
|
131
|
-
|
128
|
+
def sudo_available?
|
129
|
+
return @sudo_available unless @sudo_available.nil?
|
130
|
+
@sudo_available = run_command('sudo -V', :process_sudo => false).success?
|
131
|
+
Chef::Log.debug("`sudo` not available on #{host}") unless @sudo_available
|
132
|
+
@sudo_available
|
133
|
+
end
|
134
|
+
|
135
|
+
def process_sudo(command)
|
136
|
+
if sudo_available?
|
137
|
+
replacement = 'sudo -p \'knife sudo password: \''
|
132
138
|
else
|
133
|
-
|
134
|
-
@sudo = ""
|
139
|
+
replacement = ''
|
135
140
|
end
|
141
|
+
command.sub(/^\s*sudo/, replacement)
|
136
142
|
end
|
137
143
|
|
138
144
|
def stream_command(command)
|
@@ -140,11 +146,14 @@ module KnifeSolo
|
|
140
146
|
end
|
141
147
|
|
142
148
|
def run_command(command, options={})
|
149
|
+
defaults = {:process_sudo => true}
|
150
|
+
options = defaults.merge(options)
|
151
|
+
|
143
152
|
detect_authentication_method
|
144
153
|
|
145
154
|
Chef::Log.debug("Running command #{command}")
|
146
155
|
result = ExecResult.new
|
147
|
-
command = command
|
156
|
+
command = process_sudo(command) if options[:process_sudo]
|
148
157
|
Net::SSH.start(host, user, connection_options) do |ssh|
|
149
158
|
ssh.open_channel do |channel|
|
150
159
|
channel.request_pty
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-solo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70125916232020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70125916232020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &70125916231600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70125916231600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: virtualbox
|
38
|
-
requirement: &
|
38
|
+
requirement: &70125916231180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70125916231180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: chef
|
49
|
-
requirement: &
|
49
|
+
requirement: &70125916230640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.10.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70125916230640
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: net-ssh
|
60
|
-
requirement: &
|
60
|
+
requirement: &70125916230080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 2.1.3
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70125916230080
|
69
69
|
description: Handles bootstrapping, running chef solo, rsyncing cookbooks etc
|
70
70
|
email: mat@schaffer.me
|
71
71
|
executables: []
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project: nowarning
|
107
|
-
rubygems_version: 1.8.
|
107
|
+
rubygems_version: 1.8.6
|
108
108
|
signing_key:
|
109
109
|
specification_version: 3
|
110
110
|
summary: A collection of knife plugins for dealing with chef solo
|