knife-solo 0.3.0.pre3 → 0.3.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +29 -4
- data/lib/chef/knife/solo_bootstrap.rb +1 -1
- data/lib/chef/knife/solo_clean.rb +1 -0
- data/lib/chef/knife/solo_cook.rb +32 -37
- data/lib/chef/knife/solo_init.rb +22 -16
- data/lib/knife-solo.rb +1 -0
- data/lib/knife-solo/berkshelf.rb +37 -0
- data/lib/knife-solo/bootstraps/linux.rb +12 -17
- data/lib/knife-solo/cookbook_manager.rb +120 -0
- data/lib/knife-solo/cookbook_manager_selector.rb +75 -0
- data/lib/knife-solo/deprecated_command.rb +5 -0
- data/lib/knife-solo/info.rb +1 -1
- data/lib/knife-solo/librarian.rb +39 -0
- data/lib/knife-solo/node_config_command.rb +10 -1
- data/lib/knife-solo/resources/knife.rb +3 -0
- data/lib/knife-solo/resources/solo.rb.erb +1 -0
- data/lib/knife-solo/ssh_command.rb +14 -2
- data/test/deprecated_command_test.rb +14 -1
- data/test/gemfiles/Gemfile.chef-10 +5 -0
- data/test/gemfiles/Gemfile.chef-11 +5 -0
- data/test/integration/cases/apache2_bootstrap.rb +8 -1
- data/test/integration/cases/cache_path_usage.rb +1 -1
- data/test/integration/cases/encrypted_data_bag.rb +1 -1
- data/test/integration/{centos5_6_test.rb → centos5_8_test.rb} +2 -2
- data/test/integration/centos6_3_test.rb +24 -0
- data/test/integration/debian7_knife_bootstrap_test.rb +1 -1
- data/test/solo_clean_test.rb +6 -0
- data/test/solo_cook_test.rb +60 -9
- data/test/solo_init_test.rb +149 -9
- data/test/ssh_command_test.rb +27 -0
- data/test/support/ec2_runner.rb +2 -2
- data/test/support/integration_test.rb +3 -3
- data/test/support/kitchen_helper.rb +1 -1
- data/test/support/secret_cookbook/metadata.rb +1 -0
- metadata +66 -63
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 904d74c337d53936e856d39cbba88504da008ba8
|
4
|
+
data.tar.gz: 450ff917a4c869ed34b664083c00b15534281244
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ab1298a915aa64fdc6e5b84dafa6f7c792c6ad8ff279c9b02e96916c85140515f2b6e9a74d8d320f1f3fbf9f5f9441f24be54e4c93a07ce6740a0c398f595ae
|
7
|
+
data.tar.gz: 2049637c24941db8f9828cb8fcf7b14f1e6e644944bfb9fca1ee79e4e8be50356e3d5b7f71ba2167949deaca532abd3f51058bafbbca90be3d4c7040b218b093
|
data/CHANGELOG.md
CHANGED
@@ -4,19 +4,22 @@
|
|
4
4
|
|
5
5
|
## Changes and new features
|
6
6
|
|
7
|
-
* Automatically add librarian to cookbook paths when syncing ([226])
|
8
7
|
* BREAKING: Generate solo.rb based on knife.rb settings ([199])
|
9
|
-
- `solo.rb` is not used and a warning is issued if it still found
|
8
|
+
- `solo.rb` is not used and a warning is issued if it is still found
|
10
9
|
- You have to specify the local cookbook etc. paths in `.chef/knife.rb`
|
11
10
|
* BREAKING: Set root path with `--provisioning-path` or `knife[:provisioning_path]` and use ~/chef-solo by default ([1], [86], [125], [128], [177], [197])
|
12
11
|
* BREAKING: Remove hard dependency on Librarian-Chef ([211])
|
13
12
|
- If you use Librarian integration you need to install the librarian-chef gem yourself
|
13
|
+
* Add Berkshelf integration ([227])
|
14
|
+
* Automatically add librarian to cookbook paths when syncing ([226])
|
14
15
|
* Add `--solo` option and `knife[:solo]` configuration option to `knife bootstrap` ([207])
|
15
16
|
* `--prerelease` option to allow pre-release versions of chef omnibus or rubygem to be installed ([205])
|
16
17
|
* Prepare/bootstrap now installs the same version of Chef that the workstation is running ([186])
|
17
18
|
* Switch `--omnibus-version` flag to `--bootstrap-version` ([185])
|
18
19
|
* Support `--override-runlist` option ([204])
|
20
|
+
* Support Fedora 18 and other new EL distros ([229], [51a581])
|
19
21
|
* Drop support for openSUSE 11
|
22
|
+
* Upgrade chef-solo-search to v0.4.0
|
20
23
|
|
21
24
|
## Fixes
|
22
25
|
|
@@ -28,14 +31,22 @@
|
|
28
31
|
* Ensure rsync is installed on openSUSE ([f43ba4])
|
29
32
|
* Clean up bootstrap classes ([213])
|
30
33
|
* Rsync dot files by default, exclude only VCS dirs ([d21756], [1d3485])
|
31
|
-
* Standardize messaging across commands [215]
|
34
|
+
* Standardize messaging across commands ([215], [d37162])
|
32
35
|
* Librarian-Chef was not run by default when knife-solo was invoked from ruby ([221])
|
36
|
+
* Fix `solo init` on Ruby 1.8 ([230])
|
37
|
+
* Fix deprecated commands to include options and dependencies from the new ones ([233])
|
38
|
+
* Parse Chef version even if chef-solo command prints warnings ([235], [238])
|
39
|
+
* Upgrade CentOS in integration tests to 5.8 and 6.3 ([237])
|
40
|
+
* Default to `lsb_release` for detecting the Linux distro and add support for RHEL based systems where /etc/issue is modified ([234], [242])
|
33
41
|
|
34
42
|
## Thanks to our contributors!
|
35
43
|
|
36
44
|
* [David Kinzer][dkinzer]
|
37
45
|
* [Naoya Ito][naoya]
|
38
46
|
* [David Radcliffe][dwradcliffe]
|
47
|
+
* [Łukasz Dubiel][bambuchaAdm]
|
48
|
+
* [kmdsbng][kmdsbng]
|
49
|
+
* [Darshan Patil][dapatil]
|
39
50
|
|
40
51
|
[1]: https://github.com/matschaffer/knife-solo/issues/1
|
41
52
|
[86]: https://github.com/matschaffer/knife-solo/issues/86
|
@@ -56,10 +67,21 @@
|
|
56
67
|
[213]: https://github.com/matschaffer/knife-solo/issues/213
|
57
68
|
[215]: https://github.com/matschaffer/knife-solo/issues/215
|
58
69
|
[221]: https://github.com/matschaffer/knife-solo/issues/221
|
59
|
-
[226]: https://github.com/matschaffer/knife-solo/issues/
|
70
|
+
[226]: https://github.com/matschaffer/knife-solo/issues/226
|
71
|
+
[227]: https://github.com/matschaffer/knife-solo/issues/227
|
72
|
+
[229]: https://github.com/matschaffer/knife-solo/issues/229
|
73
|
+
[230]: https://github.com/matschaffer/knife-solo/issues/230
|
74
|
+
[233]: https://github.com/matschaffer/knife-solo/issues/233
|
75
|
+
[234]: https://github.com/matschaffer/knife-solo/issues/234
|
76
|
+
[235]: https://github.com/matschaffer/knife-solo/issues/235
|
77
|
+
[237]: https://github.com/matschaffer/knife-solo/issues/237
|
78
|
+
[238]: https://github.com/matschaffer/knife-solo/issues/238
|
79
|
+
[242]: https://github.com/matschaffer/knife-solo/issues/242
|
60
80
|
[d21756]: https://github.com/matschaffer/knife-solo/commit/d21756
|
61
81
|
[1d3485]: https://github.com/matschaffer/knife-solo/commit/1d3485
|
62
82
|
[f43ba4]: https://github.com/matschaffer/knife-solo/commit/f43ba4
|
83
|
+
[51a581]: https://github.com/matschaffer/knife-solo/commit/51a581
|
84
|
+
[d37162]: https://github.com/matschaffer/knife-solo/commit/d37162
|
63
85
|
|
64
86
|
# 0.2.0 / 2013-02-12
|
65
87
|
|
@@ -307,8 +329,10 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
|
|
307
329
|
[amoslanka]: https://github.com/amoslanka
|
308
330
|
[ares]: https://github.com/ares
|
309
331
|
[avit]: https://github.com/avit
|
332
|
+
[bambuchaAdm]: https://github.com/bambuchaAdm
|
310
333
|
[brynary]: https://github.com/brynary
|
311
334
|
[btm]: https://github.com/btm
|
335
|
+
[dapatil]: https://github.com/dapatil
|
312
336
|
[davidsch]: https://github.com/davidsch
|
313
337
|
[deepak]: https://github.com/deepak
|
314
338
|
[dkinzer]: https://github.com/dkinzer
|
@@ -321,6 +345,7 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
|
|
321
345
|
[hrp]: https://github.com/hrp
|
322
346
|
[jgarber]: https://github.com/jgarber
|
323
347
|
[jgrevich]: https://github.com/jgrevich
|
348
|
+
[kmdsbng]: https://github.com/kmdsbng
|
324
349
|
[naoya]: https://github.com/naoya
|
325
350
|
[natlownes]: https://github.com/natlownes
|
326
351
|
[patatepartie]: https://github.com/patatepartie
|
@@ -19,7 +19,7 @@ class Chef
|
|
19
19
|
|
20
20
|
# Use (some) options from prepare and cook commands
|
21
21
|
self.options = SoloPrepare.options
|
22
|
-
[:librarian, :sync_only, :why_run].each { |opt| option opt, SoloCook.options[opt] }
|
22
|
+
[:berkshelf, :librarian, :sync_only, :why_run].each { |opt| option opt, SoloCook.options[opt] }
|
23
23
|
|
24
24
|
def run
|
25
25
|
validate!
|
data/lib/chef/knife/solo_cook.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'chef/knife'
|
2
2
|
|
3
|
-
require 'knife-solo'
|
4
3
|
require 'knife-solo/ssh_command'
|
5
4
|
require 'knife-solo/node_config_command'
|
6
5
|
require 'knife-solo/tools'
|
@@ -18,9 +17,11 @@ class Chef
|
|
18
17
|
|
19
18
|
deps do
|
20
19
|
require 'chef/cookbook/chefignore'
|
20
|
+
require 'knife-solo'
|
21
|
+
require 'knife-solo/berkshelf'
|
22
|
+
require 'knife-solo/librarian'
|
21
23
|
require 'erubis'
|
22
24
|
require 'pathname'
|
23
|
-
require 'tempfile'
|
24
25
|
KnifeSolo::SshCommand.load_deps
|
25
26
|
KnifeSolo::NodeConfigCommand.load_deps
|
26
27
|
end
|
@@ -40,6 +41,10 @@ class Chef
|
|
40
41
|
:long => '--sync-only',
|
41
42
|
:description => 'Only sync the cookbook - do not run Chef'
|
42
43
|
|
44
|
+
option :berkshelf,
|
45
|
+
:long => '--no-berkshelf',
|
46
|
+
:description => 'Skip berks install'
|
47
|
+
|
43
48
|
option :librarian,
|
44
49
|
:long => '--no-librarian',
|
45
50
|
:description => 'Skip librarian-chef install'
|
@@ -72,6 +77,7 @@ class Chef
|
|
72
77
|
|
73
78
|
check_chef_version if config[:chef_check]
|
74
79
|
generate_node_config
|
80
|
+
berkshelf_install if config_value(:berkshelf, true)
|
75
81
|
librarian_install if config_value(:librarian, true)
|
76
82
|
sync_kitchen
|
77
83
|
generate_solorb
|
@@ -100,14 +106,19 @@ class Chef
|
|
100
106
|
cookbook_paths.each_with_index do |path, i|
|
101
107
|
upload_to_provision_path(path, "/cookbooks-#{i + 1}", 'cookbook_path')
|
102
108
|
end
|
109
|
+
upload_to_provision_path(node_config, 'dna.json')
|
103
110
|
upload_to_provision_path(nodes_path, 'nodes')
|
104
111
|
upload_to_provision_path(:role_path, 'roles')
|
105
112
|
upload_to_provision_path(:data_bag_path, 'data_bags')
|
106
113
|
upload_to_provision_path(:encrypted_data_bag_secret, 'data_bag_key')
|
107
114
|
end
|
108
115
|
|
116
|
+
def expand_path(path)
|
117
|
+
Pathname.new(path).expand_path
|
118
|
+
end
|
119
|
+
|
109
120
|
def expanded_config_paths(key)
|
110
|
-
Array(Chef::Config[key]).map { |path|
|
121
|
+
Array(Chef::Config[key]).map { |path| expand_path path }
|
111
122
|
end
|
112
123
|
|
113
124
|
def cookbook_paths
|
@@ -115,6 +126,7 @@ class Chef
|
|
115
126
|
end
|
116
127
|
|
117
128
|
def add_cookbook_path(path)
|
129
|
+
path = expand_path path
|
118
130
|
cookbook_paths.unshift(path) unless cookbook_paths.include?(path)
|
119
131
|
end
|
120
132
|
|
@@ -122,10 +134,6 @@ class Chef
|
|
122
134
|
KnifeSolo.resource('patch_cookbooks')
|
123
135
|
end
|
124
136
|
|
125
|
-
def nodes_path
|
126
|
-
'nodes'
|
127
|
-
end
|
128
|
-
|
129
137
|
def chefignore
|
130
138
|
@chefignore ||= ::Chef::Cookbook::Chefignore.new("./")
|
131
139
|
end
|
@@ -146,6 +154,10 @@ class Chef
|
|
146
154
|
adjust_rsync_path(path)
|
147
155
|
end
|
148
156
|
|
157
|
+
def rsync_debug
|
158
|
+
'-v' if debug?
|
159
|
+
end
|
160
|
+
|
149
161
|
# see http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
|
150
162
|
def rsync_permissions
|
151
163
|
'--chmod=ugo=rwX' if windows_client?
|
@@ -168,33 +180,14 @@ class Chef
|
|
168
180
|
ui.msg "#{msg} finished in #{Time.now - start} seconds"
|
169
181
|
end
|
170
182
|
|
171
|
-
def
|
172
|
-
|
173
|
-
|
174
|
-
elsif !load_librarian
|
175
|
-
ui.warn "Librarian-Chef could not be loaded"
|
176
|
-
ui.warn "Please add the librarian-chef gem to your Gemfile or install it manually with `gem install librarian-chef`"
|
177
|
-
else
|
178
|
-
ui.msg "Installing Librarian cookbooks..."
|
179
|
-
Librarian::Action::Resolve.new(librarian_env).run
|
180
|
-
Librarian::Action::Install.new(librarian_env).run
|
181
|
-
add_cookbook_path librarian_env.install_path
|
182
|
-
end
|
183
|
+
def berkshelf_install
|
184
|
+
path = KnifeSolo::Berkshelf.new(config, ui).install
|
185
|
+
add_cookbook_path(path) if path
|
183
186
|
end
|
184
187
|
|
185
|
-
def
|
186
|
-
|
187
|
-
|
188
|
-
require 'librarian/chef'
|
189
|
-
rescue LoadError
|
190
|
-
false
|
191
|
-
else
|
192
|
-
true
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def librarian_env
|
197
|
-
@librarian_env ||= Librarian::Chef::Environment.new
|
188
|
+
def librarian_install
|
189
|
+
path = KnifeSolo::Librarian.new(config, ui).install
|
190
|
+
add_cookbook_path(path) if path
|
198
191
|
end
|
199
192
|
|
200
193
|
def generate_solorb
|
@@ -233,8 +226,10 @@ class Chef
|
|
233
226
|
end
|
234
227
|
|
235
228
|
def rsync(source_path, target_path, extra_opts = '--delete')
|
236
|
-
cmd = %Q{rsync -rl #{rsync_permissions} --rsh="ssh #{ssh_args}" #{extra_opts}
|
237
|
-
|
229
|
+
cmd = %Q{rsync -rl #{rsync_debug} #{rsync_permissions} --rsh="ssh #{ssh_args}" #{extra_opts}}
|
230
|
+
cmd << rsync_excludes.map { |ignore| " --exclude '#{ignore}'" }.join
|
231
|
+
cmd << %Q{ #{adjust_rsync_path_on_client(source_path)} :#{adjust_rsync_path_on_node(target_path)}}
|
232
|
+
Chef::Log.debug cmd
|
238
233
|
system! cmd
|
239
234
|
end
|
240
235
|
|
@@ -247,13 +242,13 @@ class Chef
|
|
247
242
|
|
248
243
|
# Parses "Chef: x.y.z" from the chef-solo version output
|
249
244
|
def chef_version
|
250
|
-
|
251
|
-
|
245
|
+
cmd = %q{sudo chef-solo --version 2>/dev/null | awk '$1 == "Chef:" {print $2}'}
|
246
|
+
run_command(cmd).stdout.strip
|
252
247
|
end
|
253
248
|
|
254
249
|
def cook
|
255
250
|
ui.msg "Running Chef..."
|
256
|
-
cmd = "sudo chef-solo -c #{provisioning_path}/solo.rb -j #{provisioning_path}
|
251
|
+
cmd = "sudo chef-solo -c #{provisioning_path}/solo.rb -j #{provisioning_path}/dna.json"
|
257
252
|
cmd << " -l debug" if debug?
|
258
253
|
cmd << " -N #{config[:chef_node_name]}" if config[:chef_node_name]
|
259
254
|
cmd << " -W" if config[:why_run]
|
data/lib/chef/knife/solo_init.rb
CHANGED
@@ -7,19 +7,25 @@ class Chef
|
|
7
7
|
include FileUtils
|
8
8
|
|
9
9
|
deps do
|
10
|
+
require 'knife-solo'
|
11
|
+
require 'knife-solo/cookbook_manager_selector'
|
10
12
|
require 'knife-solo/gitignore'
|
13
|
+
require 'knife-solo/tools'
|
11
14
|
end
|
12
15
|
|
13
16
|
banner "knife solo init DIRECTORY"
|
14
17
|
|
15
18
|
option :git,
|
16
|
-
:long
|
17
|
-
:description => 'Do not generate .gitignore'
|
18
|
-
|
19
|
+
:long => '--no-git',
|
20
|
+
:description => 'Do not generate .gitignore'
|
21
|
+
|
22
|
+
option :berkshelf,
|
23
|
+
:long => '--[no-]berkshelf',
|
24
|
+
:description => 'Generate files for Berkshelf support'
|
19
25
|
|
20
26
|
option :librarian,
|
21
|
-
:long
|
22
|
-
:description => '
|
27
|
+
:long => '--[no-]librarian',
|
28
|
+
:description => 'Generate files for Librarian support'
|
23
29
|
|
24
30
|
def run
|
25
31
|
@base = @name_args.first
|
@@ -27,7 +33,10 @@ class Chef
|
|
27
33
|
create_kitchen
|
28
34
|
create_config
|
29
35
|
create_cupboards %w[nodes roles data_bags site-cookbooks cookbooks]
|
30
|
-
|
36
|
+
gitignore %w[/cookbooks/]
|
37
|
+
if (cm = cookbook_manager)
|
38
|
+
cm.bootstrap(@base)
|
39
|
+
end
|
31
40
|
end
|
32
41
|
|
33
42
|
def validate!
|
@@ -38,6 +47,10 @@ class Chef
|
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
50
|
+
def config_value(key, default = nil)
|
51
|
+
KnifeSolo::Tools.config_value(config, key, default)
|
52
|
+
end
|
53
|
+
|
41
54
|
def create_cupboards(dirs)
|
42
55
|
ui.msg "Creating cupboards..."
|
43
56
|
dirs.each do |dir|
|
@@ -63,19 +76,12 @@ class Chef
|
|
63
76
|
end
|
64
77
|
end
|
65
78
|
|
66
|
-
def
|
67
|
-
ui.
|
68
|
-
cheffile = File.join(@base, 'Cheffile')
|
69
|
-
unless File.exist?(cheffile)
|
70
|
-
File.open(cheffile, 'w') do |f|
|
71
|
-
f.puts("site 'http://community.opscode.com/api/v1'")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
gitignore %w[/cookbooks/ /tmp/librarian/]
|
79
|
+
def cookbook_manager
|
80
|
+
KnifeSolo::CookbookManagerSelector.new(config, ui).select(@base)
|
75
81
|
end
|
76
82
|
|
77
83
|
def gitignore(*entries)
|
78
|
-
if
|
84
|
+
if config_value(:git, true)
|
79
85
|
KnifeSolo::Gitignore.new(@base).add(*entries)
|
80
86
|
end
|
81
87
|
end
|
data/lib/knife-solo.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'digest/sha1'
|
2
|
+
require 'knife-solo/cookbook_manager'
|
3
|
+
require 'knife-solo/tools'
|
4
|
+
|
5
|
+
module KnifeSolo
|
6
|
+
class Berkshelf
|
7
|
+
include CookbookManager
|
8
|
+
|
9
|
+
def self.gem_libraries
|
10
|
+
%w[berkshelf]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.conf_file_name
|
14
|
+
'Berksfile'
|
15
|
+
end
|
16
|
+
|
17
|
+
def install!
|
18
|
+
path = berkshelf_path
|
19
|
+
ui.msg "Installing Berkshelf cookbooks to '#{path}'..."
|
20
|
+
::Berkshelf::Berksfile.from_file('Berksfile').install(:path => path)
|
21
|
+
path
|
22
|
+
end
|
23
|
+
|
24
|
+
def berkshelf_path
|
25
|
+
KnifeSolo::Tools.config_value(config, :berkshelf_path) || default_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_path
|
29
|
+
File.join(::Berkshelf.berkshelf_path, 'knife-solo',
|
30
|
+
Digest::SHA1.hexdigest(File.expand_path('.')))
|
31
|
+
end
|
32
|
+
|
33
|
+
def initial_config
|
34
|
+
'site :opscode'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module KnifeSolo::Bootstraps
|
2
2
|
class Linux < Base
|
3
|
-
|
4
3
|
def issue
|
5
|
-
|
4
|
+
commands = [
|
5
|
+
'lsb_release -d -s',
|
6
|
+
'cat /etc/redhat-release',
|
7
|
+
'cat /etc/issue'
|
8
|
+
]
|
9
|
+
result = prepare.run_with_fallbacks(commands)
|
10
|
+
result.success? ? result.stdout.strip : nil
|
6
11
|
end
|
7
12
|
|
8
13
|
def x86?
|
@@ -66,25 +71,15 @@ module KnifeSolo::Bootstraps
|
|
66
71
|
{:type => (x86? ? "debianoid_omnibus" : "debianoid_gem")}
|
67
72
|
when %r{Linaro}
|
68
73
|
{:type => "debianoid_gem"}
|
69
|
-
when %r{CentOS
|
70
|
-
{:type => "yum_omnibus"}
|
71
|
-
when %r{CentOS.*? 6}
|
74
|
+
when %r{CentOS}
|
72
75
|
{:type => "yum_omnibus"}
|
73
76
|
when %r{Amazon Linux}
|
74
77
|
{:type => "yum_omnibus"}
|
75
|
-
when %r{Red Hat Enterprise
|
76
|
-
{:type => "yum_omnibus"}
|
77
|
-
when %r{Red Hat Enterprise.*? 6}
|
78
|
-
{:type => "yum_omnibus"}
|
79
|
-
when %r{Fedora release.*? 15}
|
80
|
-
{:type => "yum_omnibus"}
|
81
|
-
when %r{Fedora release.*? 16}
|
82
|
-
{:type => "yum_omnibus"}
|
83
|
-
when %r{Fedora release.*? 17}
|
78
|
+
when %r{Red Hat Enterprise}
|
84
79
|
{:type => "yum_omnibus"}
|
85
|
-
when %r{
|
80
|
+
when %r{Fedora release}
|
86
81
|
{:type => "yum_omnibus"}
|
87
|
-
when %r{Scientific Linux
|
82
|
+
when %r{Scientific Linux}
|
88
83
|
{:type => "yum_omnibus"}
|
89
84
|
when %r{SUSE Linux Enterprise Server 1[12]}
|
90
85
|
{:type => "omnibus"}
|
@@ -93,7 +88,7 @@ module KnifeSolo::Bootstraps
|
|
93
88
|
when %r{This is \\n\.\\O \(\\s \\m \\r\) \\t}
|
94
89
|
{:type => "emerge_gem"}
|
95
90
|
else
|
96
|
-
raise "
|
91
|
+
raise "Distribution not recognized. Please run again with `-VV` option and file an issue: https://github.com/matschaffer/knife-solo/issues"
|
97
92
|
end
|
98
93
|
Chef::Log.debug("Distro detection yielded: #{@distro}")
|
99
94
|
@distro
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'chef/mixin/convert_to_class_name'
|
2
|
+
require 'knife-solo/gitignore'
|
3
|
+
require 'knife-solo/tools'
|
4
|
+
|
5
|
+
module KnifeSolo
|
6
|
+
module CookbookManager
|
7
|
+
def self.included(base)
|
8
|
+
base.extend ClassMethods
|
9
|
+
base.send(:include, InstanceMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
include Chef::Mixin::ConvertToClassName
|
14
|
+
|
15
|
+
# Returns an Array of libraries to load
|
16
|
+
def gem_libraries
|
17
|
+
raise "Must be overridden by the including class"
|
18
|
+
end
|
19
|
+
|
20
|
+
def gem_name
|
21
|
+
gem_libraries.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_gem
|
25
|
+
begin
|
26
|
+
gem_libraries.each { |lib| require lib }
|
27
|
+
true
|
28
|
+
rescue LoadError
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Key in Chef::Config and CLI options
|
34
|
+
def config_key
|
35
|
+
snake_case_basename(name).to_sym
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the base name of the configuration file
|
39
|
+
def conf_file_name
|
40
|
+
raise "Must be overridden by the including class"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module InstanceMethods
|
45
|
+
attr_reader :config, :ui
|
46
|
+
|
47
|
+
def initialize(config, ui)
|
48
|
+
@config = config
|
49
|
+
@ui = ui
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
name
|
54
|
+
end
|
55
|
+
|
56
|
+
def name
|
57
|
+
self.class.name.split('::').last
|
58
|
+
end
|
59
|
+
|
60
|
+
def gem_name
|
61
|
+
self.class.gem_name
|
62
|
+
end
|
63
|
+
|
64
|
+
def gem_installed?
|
65
|
+
self.class.load_gem
|
66
|
+
end
|
67
|
+
|
68
|
+
def conf_file(base = nil)
|
69
|
+
base ? File.join(base, self.class.conf_file_name) : self.class.conf_file_name
|
70
|
+
end
|
71
|
+
|
72
|
+
def enabled_by_chef_config?
|
73
|
+
KnifeSolo::Tools.config_value(config, self.class.config_key)
|
74
|
+
end
|
75
|
+
|
76
|
+
def conf_file_exists?(base = nil)
|
77
|
+
File.exists?(conf_file(base))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Runs the manager and returns the path to the cookbook directory
|
81
|
+
def install!
|
82
|
+
raise "Must be overridden by the including class"
|
83
|
+
end
|
84
|
+
|
85
|
+
# Runs installer if the configuration file is found and gem installed
|
86
|
+
# Returns the cookbook path or nil
|
87
|
+
def install
|
88
|
+
if !conf_file_exists?
|
89
|
+
Chef::Log.debug "#{conf_file} not found"
|
90
|
+
elsif !self.class.load_gem
|
91
|
+
ui.warn "#{name} could not be loaded"
|
92
|
+
ui.warn "Please add the #{gem_name} gem to your Gemfile or install it manually with `gem install #{gem_name}`"
|
93
|
+
else
|
94
|
+
return install!
|
95
|
+
end
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def bootstrap(base)
|
100
|
+
ui.msg "Setting up #{name}..."
|
101
|
+
unless conf_file_exists?(base)
|
102
|
+
File.open(conf_file(base), 'w') { |f| f.puts(initial_config) }
|
103
|
+
end
|
104
|
+
if KnifeSolo::Tools.config_value(config, :git, true) && gitignores
|
105
|
+
KnifeSolo::Gitignore.new(base).add(gitignores)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns content for configuration file when bootstrapping
|
110
|
+
def initial_config
|
111
|
+
raise "Must be overridden by the including class"
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns an array of strings to gitignore when bootstrapping
|
115
|
+
def gitignores
|
116
|
+
nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|