knife-solo 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/cook.rb +6 -1
- data/lib/chef/knife/kitchen.rb +4 -5
- data/lib/knife-solo/bootstraps/linux.rb +15 -9
- data/lib/knife-solo/info.rb +1 -1
- data/lib/knife-solo/kitchen_command.rb +11 -3
- data/lib/knife-solo/ssh_command.rb +24 -2
- metadata +14 -13
data/lib/chef/knife/cook.rb
CHANGED
@@ -16,11 +16,16 @@ class Chef
|
|
16
16
|
|
17
17
|
banner "knife cook [user@]hostname [json] (options)"
|
18
18
|
|
19
|
+
option :skip_chef_check,
|
20
|
+
:long => '--skip-chef-check',
|
21
|
+
:boolean => true,
|
22
|
+
:description => "Skip the version check on the Chef gem"
|
23
|
+
|
19
24
|
def run
|
20
25
|
super
|
21
26
|
check_syntax
|
22
27
|
Chef::Config.from_file('solo.rb')
|
23
|
-
check_chef_version
|
28
|
+
check_chef_version unless config[:skip_chef_check]
|
24
29
|
rsync_kitchen
|
25
30
|
add_patches
|
26
31
|
cook
|
data/lib/chef/knife/kitchen.rb
CHANGED
@@ -10,11 +10,10 @@ class Chef
|
|
10
10
|
def run
|
11
11
|
name = @name_args.first
|
12
12
|
mkdir name
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
mkdir name + "/cookbooks"
|
13
|
+
%w(nodes roles data_bags site-cookbooks cookbooks).each do |dir|
|
14
|
+
mkdir name + "/#{dir}"
|
15
|
+
touch name + "/#{dir}/.gitkeep"
|
16
|
+
end
|
18
17
|
File.open(name + "/solo.rb", 'w') do |f|
|
19
18
|
f << <<-RUBY.gsub(/^ {12}/, '')
|
20
19
|
file_cache_path "/tmp/chef-solo"
|
@@ -28,23 +28,29 @@ module KnifeSolo::Bootstraps
|
|
28
28
|
run_command("sudo USE='-test' ACCEPT_KEYWORDS='~amd64' emerge -u chef")
|
29
29
|
end
|
30
30
|
|
31
|
-
def add_yum_repos
|
31
|
+
def add_yum_repos(repo_path)
|
32
32
|
repo_url = "http://rbel.co/"
|
33
|
-
|
34
|
-
|
35
|
-
else
|
36
|
-
repo_path = "/rbel6"
|
37
|
-
end
|
33
|
+
|
34
|
+
tmp_file = "/tmp/rbel"
|
38
35
|
installed = "is already installed"
|
39
|
-
|
36
|
+
run_command("sudo yum -y install curl")
|
37
|
+
run_command("curl #{repo_url}#{repo_path} -o #{tmp_file}")
|
38
|
+
result = run_command("sudo rpm -Uvh #{tmp_file} && rm #{tmp_file}")
|
40
39
|
raise result.stderr_or_stdout unless result.success? || result.stdout.match(installed)
|
41
40
|
end
|
42
41
|
|
43
42
|
def yum_install
|
44
43
|
ui.msg("Installing required packages...")
|
45
|
-
|
44
|
+
|
45
|
+
if distro[:version] == "RHEL5"
|
46
|
+
repo_path = "rbel5"
|
47
|
+
else
|
48
|
+
repo_path = "rbel6"
|
49
|
+
end
|
50
|
+
|
51
|
+
add_yum_repos(repo_path)
|
46
52
|
@packages = %w(rubygem-chef rsync)
|
47
|
-
run_command("sudo yum -y install #{package_list}")
|
53
|
+
run_command("sudo yum -y --disablerepo=* --enablerepo=#{repo_path} install #{package_list}")
|
48
54
|
end
|
49
55
|
|
50
56
|
def debian_gem_install
|
data/lib/knife-solo/info.rb
CHANGED
@@ -6,8 +6,16 @@ module KnifeSolo
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
%w(nodes roles cookbooks data_bags
|
9
|
+
def self.required_directories
|
10
|
+
%w(nodes roles cookbooks data_bags site-cookbooks)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.required_files
|
14
|
+
%w(solo.rb)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.all_requirements
|
18
|
+
required_files + required_directories
|
11
19
|
end
|
12
20
|
|
13
21
|
def run
|
@@ -15,7 +23,7 @@ module KnifeSolo
|
|
15
23
|
end
|
16
24
|
|
17
25
|
def required_files_present?
|
18
|
-
|
26
|
+
KitchenCommand.all_requirements.inject(true) { |m, f| m && File.exists?(f) }
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -27,6 +27,11 @@ module KnifeSolo
|
|
27
27
|
:short => "-p FILE",
|
28
28
|
:long => "--ssh-port FILE",
|
29
29
|
:description => "The ssh port"
|
30
|
+
|
31
|
+
option :startup_script,
|
32
|
+
:short => "-s FILE",
|
33
|
+
:long => "--startup-script FILE",
|
34
|
+
:description => "The startup script on the remote server containing variable definitions"
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
@@ -105,6 +110,10 @@ module KnifeSolo
|
|
105
110
|
[host_arg, config_arg, ident_arg, port_arg].compact.join(' ')
|
106
111
|
end
|
107
112
|
|
113
|
+
def startup_script
|
114
|
+
config[:startup_script]
|
115
|
+
end
|
116
|
+
|
108
117
|
class ExecResult
|
109
118
|
attr_accessor :stdout, :stderr, :exit_code
|
110
119
|
|
@@ -141,19 +150,32 @@ module KnifeSolo
|
|
141
150
|
command.sub(/^\s*sudo/, replacement)
|
142
151
|
end
|
143
152
|
|
153
|
+
def process_startup_file(command)
|
154
|
+
command.insert(0, "source #{startup_script} && ")
|
155
|
+
end
|
156
|
+
|
144
157
|
def stream_command(command)
|
145
158
|
run_command(command, :streaming => true)
|
146
159
|
end
|
147
160
|
|
161
|
+
def processed_command(command, options = {})
|
162
|
+
command = process_sudo(command) if options[:process_sudo]
|
163
|
+
command = process_startup_file(command) if startup_script
|
164
|
+
command
|
165
|
+
end
|
166
|
+
|
148
167
|
def run_command(command, options={})
|
149
168
|
defaults = {:process_sudo => true}
|
150
169
|
options = defaults.merge(options)
|
151
170
|
|
152
171
|
detect_authentication_method
|
153
172
|
|
154
|
-
Chef::Log.debug("
|
173
|
+
Chef::Log.debug("Initial command #{command}")
|
155
174
|
result = ExecResult.new
|
156
|
-
|
175
|
+
|
176
|
+
command = processed_command(command, options)
|
177
|
+
Chef::Log.debug("Running processed command #{command}")
|
178
|
+
|
157
179
|
Net::SSH.start(host, user, connection_options) do |ssh|
|
158
180
|
ssh.open_channel do |channel|
|
159
181
|
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.8
|
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:
|
12
|
+
date: 2012-02-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70146380288440 !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: *70146380288440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &70146380288020 !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: *70146380288020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: virtualbox
|
38
|
-
requirement: &
|
38
|
+
requirement: &70146380287600 !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: *70146380287600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: chef
|
49
|
-
requirement: &
|
49
|
+
requirement: &70146380287100 !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: *70146380287100
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: net-ssh
|
60
|
-
requirement: &
|
60
|
+
requirement: &70146380286600 !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: *70146380286600
|
69
69
|
description: Handles bootstrapping, running chef solo, rsyncing cookbooks etc
|
70
70
|
email: mat@schaffer.me
|
71
71
|
executables: []
|
@@ -104,8 +104,9 @@ 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.15
|
108
108
|
signing_key:
|
109
109
|
specification_version: 3
|
110
110
|
summary: A collection of knife plugins for dealing with chef solo
|
111
111
|
test_files: []
|
112
|
+
has_rdoc:
|