knife-solo 0.4.3 → 0.5.0

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -13
  3. data/README.rdoc +8 -2
  4. data/lib/chef/knife/solo_cook.rb +23 -15
  5. data/lib/chef/knife/solo_prepare.rb +8 -0
  6. data/lib/knife-solo/berkshelf.rb +11 -2
  7. data/lib/knife-solo/bootstraps.rb +13 -0
  8. data/lib/knife-solo/bootstraps/linux.rb +7 -16
  9. data/lib/knife-solo/cookbook_manager.rb +12 -10
  10. data/lib/knife-solo/info.rb +1 -1
  11. data/lib/knife-solo/librarian.rb +1 -1
  12. data/lib/knife-solo/resources/knife.rb +1 -0
  13. data/lib/knife-solo/resources/solo.rb.erb +1 -1
  14. data/lib/knife-solo/ssh_command.rb +67 -20
  15. data/test/deprecated_command_test.rb +2 -2
  16. data/test/gemfiles/Gemfile.chef-12 +5 -0
  17. data/test/integration/cases/apache2_bootstrap.rb +1 -1
  18. data/test/integration/cases/ohai_hints.rb +33 -0
  19. data/test/integration/centos6_3_test.rb +2 -9
  20. data/test/integration/debian6_bootstrap_test.rb +1 -1
  21. data/test/integration/debian7_knife_bootstrap_test.rb +1 -1
  22. data/test/integration/scientific_linux_63_test.rb +3 -1
  23. data/test/integration/ubuntu12_04_ohai_hints_test.rb +17 -0
  24. data/test/integration_helper.rb +1 -1
  25. data/test/knife_bootstrap_test.rb +1 -1
  26. data/test/solo_cook_test.rb +9 -11
  27. data/test/solo_init_test.rb +5 -5
  28. data/test/ssh_command_test.rb +36 -1
  29. data/test/support/ec2_runner.rb +13 -8
  30. data/test/support/environment_cookbook/metadata.rb +1 -1
  31. data/test/support/integration_test.rb +17 -2
  32. data/test/support/knife.rb +0 -0
  33. data/test/support/test_case.rb +2 -1
  34. data/test/support/validation_helper.rb +1 -1
  35. metadata +16 -11
  36. data/.coveralls.yml +0 -2
  37. data/test/integration/ubuntu10_04_test.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 185d7ad8aab05bbb1f49d75b658736269c881988
4
- data.tar.gz: d168feaaf06c9c58d6828aafa0aa87016cd35e5e
3
+ metadata.gz: aaa57c26fd7e654b43bb5286b1652f92d8400ae4
4
+ data.tar.gz: 64fd07ee767055a7291073b6b3ea9bb6b77ebfe1
5
5
  SHA512:
6
- metadata.gz: e2e27539c89353f585dcc643722e5b8fc0751b8e2e4dfdbc9134f9002355c82bb6511e862ec8ed73a09764d666e6ae095848f1422f1582b932561c8cfb2ec3e3
7
- data.tar.gz: 24e8fe991daa1990bbed002508e5cb933af0e0f7406905fb945e863f63535708cbff6bfde3ba8f24a60dd0fdb0f098ea5a4c2dd0818256e2881993b600674b0d
6
+ metadata.gz: 69b3f89c75297c8998a8680eef37a3d05eb1273a050010b5f12f1da2727d2d5ccd8d84e33aabd6ccd8dc38b954f8434c8d68fbc848592515cd898c0c4e3243fb
7
+ data.tar.gz: 9f7ddb4384f9a0d3d5ec54b73f80774efb23a11f0fa35b0e9051089511fd05130d88368b2dafdf4a94ec218f9b18aef04a1595b7f18fb8fe5ab6fb930a999c80
@@ -1,12 +1,65 @@
1
- # 0.4.3 / 2015-09-10
1
+ # 0.5.0 / 2015-08-28
2
+
3
+ ## Changes and new features
4
+
5
+ * Configurable cygwin prefixes ([378][])
6
+ * Configurable sudo command ([394][])
7
+ * SSH keepalive support, required bump to Chef >=10.20 ([288][], [404][])
8
+ * Configurable secret file location ([412][])
9
+ * Allow passing options to Berkshelf (>=3 only) ([369][])
10
+ * Arch Linux support ([389][], [393][], [396][])
11
+ * Manjaro Linux support ([414][])
12
+ * Debian 8 support ([436][])
13
+ * Use control sockets to speed up rsync transfers ([440][])
14
+ * Support for ohai hints ([339][])
2
15
 
3
16
  ## Fixes
4
17
 
5
- * Pass node name down to solo.rb ([452][])
18
+ * Updates for Berkshelf 3 ([376][], [405][])
19
+ * Better warnings for berkshelf/librarian ([383][])
20
+ * Show chef command during run output ([401][])
21
+ * Make `ssl_verify_mode` `:verify_peer` by default ([413][])
22
+ * Avoid copying local http proxy info to node's knife.rb ([421][])
6
23
 
7
24
  ## Thanks to our contributors!
8
25
 
9
- * [aaadschutz][aaadschutz]
26
+ * [Ivan Tanev][VanTanev]
27
+ * [Masato Ikeda][a2ikm]
28
+ * [Graham Lyus][grahamlyus]
29
+ * [Oleg Selin][OlegPS]
30
+ * [Todd Willey][xtoddx]
31
+ * [DQNEO][DQNEO]
32
+ * [Kevin McAllister][mclazarus]
33
+ * [Yoz (Jeremy) Grahame][yozlet]
34
+ * [Nori Yoshioka][noric]
35
+ * [Josh Yotty][jyotty]
36
+ * [Markus Kern][makern]
37
+ * [esio][es1o]
38
+ * [Evgeny Vereshchagin][evverx]
39
+ * [Tomo Masakura][masakura]
40
+ * [Iavael][iavael]
41
+ * [Patrick Connolly][patcon]
42
+ * [Markus Kern][makern]
43
+
44
+ [378]: https://github.com/matschaffer/knife-solo/issues/378
45
+ [376]: https://github.com/matschaffer/knife-solo/issues/376
46
+ [383]: https://github.com/matschaffer/knife-solo/issues/383
47
+ [389]: https://github.com/matschaffer/knife-solo/issues/389
48
+ [393]: https://github.com/matschaffer/knife-solo/issues/393
49
+ [396]: https://github.com/matschaffer/knife-solo/issues/396
50
+ [394]: https://github.com/matschaffer/knife-solo/issues/394
51
+ [401]: https://github.com/matschaffer/knife-solo/issues/401
52
+ [405]: https://github.com/matschaffer/knife-solo/issues/405
53
+ [288]: https://github.com/matschaffer/knife-solo/issues/288
54
+ [404]: https://github.com/matschaffer/knife-solo/issues/404
55
+ [413]: https://github.com/matschaffer/knife-solo/issues/413
56
+ [412]: https://github.com/matschaffer/knife-solo/issues/412
57
+ [414]: https://github.com/matschaffer/knife-solo/issues/414
58
+ [421]: https://github.com/matschaffer/knife-solo/issues/421
59
+ [369]: https://github.com/matschaffer/knife-solo/issues/369
60
+ [436]: https://github.com/matschaffer/knife-solo/issues/436
61
+ [440]: https://github.com/matschaffer/knife-solo/issues/440
62
+ [339]: https://github.com/matschaffer/knife-solo/issues/339
10
63
 
11
64
  # 0.4.2 / 2014-06-05
12
65
 
@@ -452,18 +505,28 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
452
505
  * Cook via rsync
453
506
 
454
507
  [ChrisLundquist]: https://github.com/ChrisLundquist
508
+ [DQNEO]: https://github.com/DQNEO
509
+ [Domon]: https://github.com/Domon
455
510
  [DrGonzo65]: https://github.com/DrGonzo65
456
511
  [Frozenproduce]: https://github.com/Frozenproduce
457
512
  [Motiejus]: https://github.com/Motiejus
458
513
  [Nix-wie-weg]: https://github.com/Nix-wie-weg
514
+ [OlegPS]: https://github.com/OlegPS
459
515
  [TheAlphaTester]: https://github.com/TheAlphaTester
460
516
  [TylerRick]: https://github.com/TylerRick
517
+ [VanTanev]: https://github.com/VanTanev
518
+ [a2ikm]: https://github.com/a2ikm
461
519
  [aaronjensen]: https://github.com/aaronjensen
520
+ [alexsiri7]: https://github.com/alexsiri7
521
+ [allaire]: https://github.com/allaire
462
522
  [amoslanka]: https://github.com/amoslanka
523
+ [angelabad]: https://github.com/angelabad
524
+ [anl]: https://github.com/anl
463
525
  [ares]: https://github.com/ares
464
526
  [aromarom64]: https://github.com/aromarom64
465
527
  [avit]: https://github.com/avit
466
528
  [bambuchaAdm]: https://github.com/bambuchaAdm
529
+ [brainopia]: https://github.com/brainopia
467
530
  [brynary]: https://github.com/brynary
468
531
  [btm]: https://github.com/btm
469
532
  [dapatil]: https://github.com/dapatil
@@ -471,19 +534,27 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
471
534
  [deepak]: https://github.com/deepak
472
535
  [dkinzer]: https://github.com/dkinzer
473
536
  [dwradcliffe]: https://github.com/dwradcliffe
537
+ [es1o]: https://github.com/es1o
538
+ [evverx]: https://github.com/evverx
474
539
  [fnichol]: https://github.com/fnichol
475
540
  [funglaub]: https://github.com/funglaub
541
+ [grahamlyus]: https://github.com/grahamlyus
476
542
  [gregf]: https://github.com/gregf
477
543
  [gsterndale]: https://github.com/gsterndale
478
544
  [hectcastro]: https://github.com/hectcastro
479
545
  [hrp]: https://github.com/hrp
546
+ [iavael]: https://github.com/iavael
480
547
  [jgarber]: https://github.com/jgarber
481
548
  [jgrevich]: https://github.com/jgrevich
549
+ [jyotty]: https://github.com/jyotty
482
550
  [kmdsbng]: https://github.com/kmdsbng
483
551
  [makern]: https://github.com/makern
552
+ [masakura]: https://github.com/masakura
553
+ [mclazarus]: https://github.com/mclazarus
484
554
  [michaelglass]: https://github.com/michaelglass
485
555
  [naoya]: https://github.com/naoya
486
556
  [natlownes]: https://github.com/natlownes
557
+ [noric]: https://github.com/noric
487
558
  [patatepartie]: https://github.com/patatepartie
488
559
  [patcon]: https://github.com/patcon
489
560
  [pferdefleisch]: https://github.com/pferdefleisch
@@ -491,6 +562,7 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
491
562
  [portertech]: https://github.com/portertech
492
563
  [retr0h]: https://github.com/retr0h
493
564
  [rmoriz]: https://github.com/rmoriz
565
+ [robacarp]: https://github.com/robacarp
494
566
  [rosstimson]: https://github.com/rosstimson
495
567
  [rubiojr]: https://github.com/rubiojr
496
568
  [russellcardullo]: https://github.com/russellcardullo
@@ -503,14 +575,7 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
503
575
  [tmatilai]: https://github.com/tmatilai
504
576
  [tocky]: https://github.com/tocky
505
577
  [vjpr]: https://github.com/vjpr
506
- [zeph]: https://github.com/zeph
507
- [allaire]: https://github.com/allaire
508
- [yugui]: https://github.com/yugui
509
578
  [xtoddx]: https://github.com/xtoddx
510
- [anl]: https://github.com/anl
511
- [robacarp]: https://github.com/robacarp
512
- [alexsiri7]: https://github.com/alexsiri7
513
- [brainopia]: https://github.com/brainopia
514
- [Domon]: https://github.com/Domon
515
- [angelabad]: https://github.com/angelabad
516
- [aaadschutz]: https://github.com/aaadschutz
579
+ [yozlet]: https://github.com/yozlet
580
+ [yugui]: https://github.com/yugui
581
+ [zeph]: https://github.com/zeph
@@ -22,6 +22,9 @@ Installation is a normal gem installation.
22
22
 
23
23
  gem install knife-solo
24
24
 
25
+ # or if using ChefDK
26
+ chef gem install knife-solo
27
+
25
28
  If you need to install from git run:
26
29
 
27
30
  bundle && bundle exec rake install
@@ -106,7 +109,7 @@ Under the hood it first calls +knife solo prepare+ and then +knife solo cook+ wi
106
109
 
107
110
  ==== Integration with knife bootstrap
108
111
 
109
- knife-solo also integrates with <tt>knife bootstrap</tt> by adding +--solo+ command line option and +knife[:solo]+ configuration parameter to it. When requested, "knife solo bootrap" is used instead of the normal template based chef-client bootstrap. This is especially useful with other knife plugins like {knife-ec2}[https://github.com/opscode/knife-ec2] that invoke "knife bootstrap" after creating an server instance. Even if these plugins do not have the "--solo" option, you can put <tt>knife[:solo] = true</tt> in knife.rb.
112
+ knife-solo also integrates with <tt>knife bootstrap</tt> by adding +--solo+ command line option and +knife[:solo]+ configuration parameter to it. When requested, "knife solo bootstrap" is used instead of the normal template based chef-client bootstrap. This is especially useful with other knife plugins like {knife-ec2}[https://github.com/opscode/knife-ec2] that invoke "knife bootstrap" after creating an server instance. Even if these plugins do not have the "--solo" option, you can put <tt>knife[:solo] = true</tt> in knife.rb.
110
113
 
111
114
  === Clean command
112
115
 
@@ -134,7 +137,10 @@ The cook command will work on Windows node if you meet the following howto:
134
137
 
135
138
  ==== Cook
136
139
 
137
- - cook should work as expected automatically, if you use cygwin rsync
140
+ - cook should work as expected automatically, if you use cygwin rsync. If you're using MinGW / Git Bash, or you have a non-standard <tt>cygdrive</tt> setting, you can set that in <tt>.chef/knife.rb</tt>:
141
+
142
+ knife[:cygdrive_prefix_local] = '/cygdrive' # prefix for your local machine, set to empty string for MinGW
143
+ knife[:cygdrive_prefix_remote] = '/cygdrive' # prefix on the remote windows node
138
144
 
139
145
  == DEVELOPMENT
140
146
 
@@ -26,7 +26,7 @@ class Chef
26
26
  KnifeSolo::NodeConfigCommand.load_deps
27
27
  end
28
28
 
29
- banner "knife solo cook [USER@]HOSTNAME [JSON] (options)"
29
+ banner "knife solo cook [USER@]HOSTNAME [JSONFILE] (options)"
30
30
 
31
31
  option :chef_check,
32
32
  :long => '--no-chef-check',
@@ -53,6 +53,10 @@ class Chef
53
53
  :long => '--no-librarian',
54
54
  :description => 'Skip librarian-chef install'
55
55
 
56
+ option :secret_file,
57
+ :long => '--secret-file SECRET_FILE',
58
+ :description => 'A file containing the secret key used to encrypt data bag item values'
59
+
56
60
  option :why_run,
57
61
  :short => '-W',
58
62
  :long => '--why-run',
@@ -123,7 +127,7 @@ class Chef
123
127
  upload_to_provision_path(nodes_path, 'nodes')
124
128
  upload_to_provision_path(:role_path, 'roles')
125
129
  upload_to_provision_path(:data_bag_path, 'data_bags')
126
- upload_to_provision_path(:encrypted_data_bag_secret, 'data_bag_key')
130
+ upload_to_provision_path(config[:secret_file] || :encrypted_data_bag_secret, 'data_bag_key')
127
131
  upload_to_provision_path(:environment_path, 'environments')
128
132
  end
129
133
 
@@ -144,7 +148,7 @@ class Chef
144
148
  end
145
149
 
146
150
  def proxy_setting_keys
147
- [:http_proxy, :https_proxy, :http_proxy_user, :http_proxy_pass, :no_proxy]
151
+ [:http_proxy, :https_proxy, :http_proxy_user, :http_proxy_pass, :https_proxy_user, :https_proxy_pass, :no_proxy]
148
152
  end
149
153
 
150
154
  def proxy_settings
@@ -167,20 +171,20 @@ class Chef
167
171
  @chefignore ||= ::Chef::Cookbook::Chefignore.new("./")
168
172
  end
169
173
 
170
- # cygwin rsync path must be adjusted to work
171
- def adjust_rsync_path(path)
174
+ # path must be adjusted to work on windows
175
+ def adjust_rsync_path(path, path_prefix)
172
176
  path_s = path.to_s
173
- path_s.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
177
+ path_s.gsub(/^(\w):/) { path_prefix + "/#{$1}" }
174
178
  end
175
179
 
176
180
  def adjust_rsync_path_on_node(path)
177
181
  return path unless windows_node?
178
- adjust_rsync_path(path)
182
+ adjust_rsync_path(path, config_value(:cygdrive_prefix_remote, '/cygdrive'))
179
183
  end
180
184
 
181
185
  def adjust_rsync_path_on_client(path)
182
186
  return path unless windows_client?
183
- adjust_rsync_path(path)
187
+ adjust_rsync_path(path, config_value(:cygdrive_prefix_local, '/cygdrive'))
184
188
  end
185
189
 
186
190
  def rsync_debug
@@ -193,7 +197,7 @@ class Chef
193
197
  end
194
198
 
195
199
  def rsync_excludes
196
- (%w{revision-deploys tmp .git .hg .svn .bzr} + chefignore.ignores).uniq
200
+ (%w{revision-deploys .git .hg .svn .bzr} + chefignore.ignores).uniq
197
201
  end
198
202
 
199
203
  def debug?
@@ -256,18 +260,21 @@ class Chef
256
260
  file.unlink
257
261
  end
258
262
 
259
- def rsync(source_path, target_path, extra_opts = '--delete-after')
263
+ def rsync(source_path, target_path, extra_opts = ['--delete-after', '-zt'])
260
264
  if config[:ssh_gateway]
261
265
  ssh_command = "ssh -TA #{config[:ssh_gateway]} ssh -T -o StrictHostKeyChecking=no #{ssh_args}"
262
266
  else
263
267
  ssh_command = "ssh #{ssh_args}"
264
268
  end
265
269
 
266
- cmd = ['rsync', '-rL', rsync_debug, rsync_permissions, %Q{--rsh=#{ssh_command}}, extra_opts]
270
+ cmd = ['rsync', '-rL', rsync_debug, rsync_permissions, %Q{--rsh=#{ssh_command}}]
271
+ cmd += extra_opts
267
272
  cmd += rsync_excludes.map { |ignore| "--exclude=#{ignore}" }
268
- cmd << adjust_rsync_path_on_client(source_path)
269
- cmd << %Q{:#{adjust_rsync_path_on_node(target_path)}}
270
- cmd = cmd.flatten.compact
273
+ cmd += [ adjust_rsync_path_on_client(source_path),
274
+ ':' + adjust_rsync_path_on_node(target_path) ]
275
+
276
+ cmd = cmd.compact
277
+
271
278
  Chef::Log.debug cmd.inspect
272
279
  system!(*cmd)
273
280
  end
@@ -296,13 +303,14 @@ class Chef
296
303
  end
297
304
 
298
305
  def cook
299
- ui.msg "Running Chef..."
300
306
  cmd = "sudo chef-solo -c #{provisioning_path}/solo.rb -j #{provisioning_path}/dna.json"
301
307
  cmd << " -l debug" if debug?
302
308
  cmd << " -N #{config[:chef_node_name]}" if config[:chef_node_name]
303
309
  cmd << " -W" if config[:why_run]
304
310
  cmd << " -o #{config[:override_runlist]}" if config[:override_runlist]
305
311
 
312
+ ui.msg "Running Chef: #{cmd}"
313
+
306
314
  result = stream_command cmd
307
315
  raise "chef-solo failed. See output above." unless result.success?
308
316
  end
@@ -39,6 +39,14 @@ class Chef
39
39
  :long => '--omnibus-version VERSION',
40
40
  :description => 'Deprecated. Replaced with --bootstrap-version.'
41
41
 
42
+ option :hint,
43
+ :long => '--hint HINT_NAME[=HINT_FILE]',
44
+ :description => 'Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.',
45
+ :proc => Proc.new { |h|
46
+ Chef::Config[:knife][:hints] ||= Hash.new
47
+ name, path = h.split("=")
48
+ Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : Hash.new }
49
+
42
50
  def run
43
51
  if config[:omnibus_version]
44
52
  ui.warn '`--omnibus-version` is deprecated, please use `--bootstrap-version`.'
@@ -19,7 +19,12 @@ module KnifeSolo
19
19
  path = berkshelf_path
20
20
  ui.msg "Installing Berkshelf cookbooks to '#{path}'..."
21
21
 
22
- berksfile = ::Berkshelf::Berksfile.from_file('Berksfile')
22
+ if Gem::Version.new(::Berkshelf::VERSION) >= Gem::Version.new("3.0.0")
23
+ berkshelf_options = KnifeSolo::Tools.config_value(config, :berkshelf_options) || {}
24
+ berksfile = ::Berkshelf::Berksfile.from_file('Berksfile',berkshelf_options)
25
+ else
26
+ berksfile = ::Berkshelf::Berksfile.from_file('Berksfile')
27
+ end
23
28
  if berksfile.respond_to?(:vendor)
24
29
  FileUtils.rm_rf(path)
25
30
  berksfile.vendor(path)
@@ -40,7 +45,11 @@ module KnifeSolo
40
45
  end
41
46
 
42
47
  def initial_config
43
- 'site :opscode'
48
+ if defined?(::Berkshelf) && Gem::Version.new(::Berkshelf::VERSION) >= Gem::Version.new("3.0.0")
49
+ 'source "https://api.berkshelf.com"'
50
+ else
51
+ 'site :opscode'
52
+ end
44
53
  end
45
54
  end
46
55
  end
@@ -49,6 +49,7 @@ module KnifeSolo
49
49
  def bootstrap!
50
50
  run_pre_bootstrap_checks
51
51
  send("#{distro[:type]}_install")
52
+ install_ohai_hints
52
53
  end
53
54
 
54
55
  def distro
@@ -111,6 +112,18 @@ module KnifeSolo
111
112
  "--version #{chef_version}"
112
113
  end
113
114
  end
115
+
116
+ def install_ohai_hints
117
+ hints = Chef::Config[:knife][:hints]
118
+ unless hints.nil? || hints.empty?
119
+ ui.msg "Setting Ohai hints..."
120
+ run_command("sudo mkdir -p /etc/chef/ohai/hints")
121
+ run_command("sudo rm -f /etc/chef/ohai/hints/*")
122
+ hints.each do |name, hash|
123
+ run_command("sudo tee -a /etc/chef/ohai/hints/#{name}.json > /dev/null <<EOF\n#{hash.to_json}\nEOF\n")
124
+ end
125
+ end
126
+ end
114
127
  end #InstallCommands
115
128
 
116
129
  class Base
@@ -4,6 +4,7 @@ module KnifeSolo::Bootstraps
4
4
  commands = [
5
5
  'lsb_release -d -s',
6
6
  'cat /etc/redhat-release',
7
+ 'cat /etc/os-release',
7
8
  'cat /etc/issue'
8
9
  ]
9
10
  result = prepare.run_with_fallbacks(commands)
@@ -29,20 +30,10 @@ module KnifeSolo::Bootstraps
29
30
  gem_install
30
31
  end
31
32
 
32
- def yaourt_install
33
+ def pacman_install
33
34
  ui.msg("Installing required packages...")
34
- stream_command <<-BASH
35
- if ! sudo grep -Fxq "[archlinuxfrx]" /etc/pacman.conf ; then
36
- sudo bash -c 'echo "[archlinuxfr]" >> /etc/pacman.conf'
37
- sudo bash -c 'echo "SigLevel = Never" >> /etc/pacman.conf'
38
- sudo bash -c 'echo "Server = http://repo.archlinux.fr/\\\$arch" >> /etc/pacman.conf'
39
- fi
40
- if ! command -v yaourt >/dev/null 2>&1 ; then
41
- sudo pacman -Sy --noconfirm yaourt
42
- fi
43
- yaourt -S --noconfirm ruby-chef rsync
44
- BASH
45
- run_command("sudo gem install --no-rdoc --no-ri pry") # patch for ruby-chef
35
+ run_command("sudo pacman -Sy ruby rsync make gcc --noconfirm")
36
+ run_command("sudo gem install chef --no-user-install --no-rdoc --no-ri")
46
37
  end
47
38
 
48
39
  def debianoid_gem_install
@@ -79,7 +70,7 @@ module KnifeSolo::Bootstraps
79
70
  def distro
80
71
  return @distro if @distro
81
72
  @distro = case issue
82
- when %r{Debian GNU/Linux [67]}
73
+ when %r{Debian GNU/Linux [678]}
83
74
  {:type => (x86? ? "debianoid_omnibus" : "debianoid_gem")}
84
75
  when %r{Debian}
85
76
  {:type => "debianoid_gem"}
@@ -113,8 +104,8 @@ module KnifeSolo::Bootstraps
113
104
  {:type => "zypper_omnibus"}
114
105
  when %r{This is \\n\.\\O \(\\s \\m \\r\) \\t}
115
106
  {:type => "emerge_gem"}
116
- when %r{Arch Linux \\r \(\\l\)}
117
- {:type => "yaourt"}
107
+ when %r{Arch Linux}, %r{Manjaro Linux}
108
+ {:type => "pacman"}
118
109
  else
119
110
  raise "Distribution not recognized. Please run again with `-VV` option and file an issue: https://github.com/matschaffer/knife-solo/issues"
120
111
  end
@@ -22,12 +22,7 @@ module KnifeSolo
22
22
  end
23
23
 
24
24
  def load_gem
25
- begin
26
- gem_libraries.each { |lib| require lib }
27
- true
28
- rescue LoadError
29
- false
30
- end
25
+ gem_libraries.each { |lib| require lib }
31
26
  end
32
27
 
33
28
  # Key in Chef::Config and CLI options
@@ -63,6 +58,9 @@ module KnifeSolo
63
58
 
64
59
  def gem_installed?
65
60
  self.class.load_gem
61
+ true
62
+ rescue LoadError
63
+ false
66
64
  end
67
65
 
68
66
  def conf_file(base = nil)
@@ -87,11 +85,15 @@ module KnifeSolo
87
85
  def install
88
86
  if !conf_file_exists?
89
87
  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
88
  else
94
- return install!
89
+ begin
90
+ self.class.load_gem
91
+ return install!
92
+ rescue LoadError => e
93
+ ui.warn e.inspect
94
+ ui.warn "#{name} could not be loaded"
95
+ ui.warn "Please add the #{gem_name} gem to your Gemfile or install it manually with `gem install #{gem_name}`"
96
+ end
95
97
  end
96
98
  nil
97
99
  end
@@ -1,6 +1,6 @@
1
1
  module KnifeSolo
2
2
  def self.version
3
- '0.4.3'
3
+ '0.5.0'
4
4
  end
5
5
 
6
6
  def self.post_install_message
@@ -28,7 +28,7 @@ module KnifeSolo
28
28
  end
29
29
 
30
30
  def initial_config
31
- "site 'http://community.opscode.com/api/v1'"
31
+ "site 'http://supermarket.getchef.com/api/v1'"
32
32
  end
33
33
 
34
34
  # Returns an array of strings to gitignore when bootstrapping
@@ -6,3 +6,4 @@ data_bag_path "data_bags"
6
6
  #encrypted_data_bag_secret "data_bag_key"
7
7
 
8
8
  knife[:berkshelf_path] = "cookbooks"
9
+ Chef::Config[:ssl_verify_mode] = :verify_peer if defined? ::Chef
@@ -1,4 +1,4 @@
1
- node_name <%= node_name.inspect %>
1
+ node_name <%= host.inspect %>
2
2
 
3
3
  base = File.expand_path('..', __FILE__)
4
4
 
@@ -47,6 +47,11 @@ module KnifeSolo
47
47
  :long => '--ssh-identity FILE',
48
48
  :description => 'Deprecated. Replaced with --identity-file.'
49
49
 
50
+ option :ssh_control_master,
51
+ :long => '--ssh-control-master SETTING',
52
+ :description => 'Control master setting to use when running rsync (use "no" to disable)',
53
+ :default => 'auto'
54
+
50
55
  option :identity_file,
51
56
  :short => '-i IDENTITY_FILE',
52
57
  :long => '--identity-file FILE',
@@ -54,7 +59,7 @@ module KnifeSolo
54
59
 
55
60
  option :forward_agent,
56
61
  :long => '--forward-agent',
57
- :description => 'Forward SSH authentication',
62
+ :description => 'Forward SSH authentication. Adds -E to sudo, override with --sudo-command.',
58
63
  :boolean => true,
59
64
  :default => false
60
65
 
@@ -63,6 +68,17 @@ module KnifeSolo
63
68
  :long => '--ssh-port PORT',
64
69
  :description => 'The ssh port'
65
70
 
71
+ option :ssh_keepalive,
72
+ :long => '--[no-]ssh-keepalive',
73
+ :description => 'Use ssh keepalive',
74
+ :default => true
75
+
76
+ option :ssh_keepalive_interval,
77
+ :long => '--ssh-keepalive-interval SECONDS',
78
+ :description => 'The ssh keepalive interval',
79
+ :default => 300,
80
+ :proc => Proc.new { |v| v.to_i }
81
+
66
82
  option :startup_script,
67
83
  :short => '-s FILE',
68
84
  :long => '--startup-script FILE',
@@ -98,6 +114,12 @@ module KnifeSolo
98
114
  if config[:ssh_user]
99
115
  host_descriptor[:user] ||= config[:ssh_user]
100
116
  end
117
+
118
+ # NOTE: can't rely on default since it won't get called when invoked via knife bootstrap --solo
119
+ if config[:ssh_keepalive_interval] && config[:ssh_keepalive_interval] <= 0
120
+ ui.fatal '`--ssh-keepalive-interval` must be a positive number'
121
+ exit 1
122
+ end
101
123
  end
102
124
 
103
125
  def host_descriptor
@@ -149,6 +171,10 @@ module KnifeSolo
149
171
  options[:paranoid] = false
150
172
  options[:user_known_hosts_file] = "/dev/null"
151
173
  end
174
+ if config[:ssh_keepalive]
175
+ options[:keepalive] = config[:ssh_keepalive]
176
+ options[:keepalive_interval] = config[:ssh_keepalive_interval]
177
+ end
152
178
  # Respect users' specification of config[:ssh_config]
153
179
  # Prevents Net::SSH itself from applying the default ssh_config files.
154
180
  options[:config] = false
@@ -173,20 +199,45 @@ module KnifeSolo
173
199
  end
174
200
 
175
201
  def ssh_args
176
- host_arg = [user, host].compact.join('@')
177
- config_arg = "-F #{config[:ssh_config]}" if config[:ssh_config]
178
- ident_arg = "-i #{config[:identity_file]}" if config[:identity_file]
179
- forward_arg = "-o ForwardAgent=yes" if config[:forward_agent]
180
- port_arg = "-p #{config[:ssh_port]}" if config[:ssh_port]
181
- knownhosts_arg = "-o UserKnownHostsFile=#{connection_options[:user_known_hosts_file]}" if config[:host_key_verify] == false
182
- stricthosts_arg = "-o StrictHostKeyChecking=no" if config[:host_key_verify] == false
202
+ args = []
203
+
204
+ args << [user, host].compact.join('@')
205
+
206
+ args << "-F #{config[:ssh_config]}" if config[:ssh_config]
207
+ args << "-i #{config[:identity_file]}" if config[:identity_file]
208
+ args << "-o ForwardAgent=yes" if config[:forward_agent]
209
+ args << "-p #{config[:ssh_port]}" if config[:ssh_port]
210
+ args << "-o UserKnownHostsFile=#{connection_options[:user_known_hosts_file]}" if config[:host_key_verify] == false
211
+ args << "-o StrictHostKeyChecking=no" if config[:host_key_verify] == false
212
+ args << "-o ControlMaster=auto -o ControlPath=#{ssh_control_path} -o ControlPersist=3600" unless config[:ssh_control_master] == "no"
183
213
 
214
+ args.join(' ')
215
+ end
184
216
 
185
- [host_arg, config_arg, ident_arg, forward_arg, port_arg, knownhosts_arg, stricthosts_arg].compact.join(' ')
217
+ def ssh_control_path
218
+ dir = File.join(ENV['HOME'], '.chef', 'knife-solo-sockets')
219
+ FileUtils.mkdir_p(dir)
220
+ File.join(dir, '%h')
221
+ end
222
+
223
+ def custom_sudo_command
224
+ if sudo_command=config[:sudo_command]
225
+ Chef::Log.debug("Using replacement sudo command: #{sudo_command}")
226
+ return sudo_command
227
+ end
228
+ end
229
+
230
+ def standard_sudo_command
231
+ return unless sudo_available?
232
+ if config[:forward_agent]
233
+ return 'sudo -E -p \'knife sudo password: \''
234
+ else
235
+ return 'sudo -p \'knife sudo password: \''
236
+ end
186
237
  end
187
238
 
188
239
  def sudo_command
189
- config[:sudo_command]
240
+ custom_sudo_command || standard_sudo_command || ''
190
241
  end
191
242
 
192
243
  def startup_script
@@ -196,7 +247,11 @@ module KnifeSolo
196
247
  def windows_node?
197
248
  return @windows_node unless @windows_node.nil?
198
249
  @windows_node = run_command('ver', :process_sudo => false).stdout =~ /Windows/i
199
- Chef::Log.debug("Windows node detected") if @windows_node
250
+ if @windows_node
251
+ Chef::Log.debug("Windows node detected")
252
+ else
253
+ @windows_node = false
254
+ end
200
255
  @windows_node
201
256
  end
202
257
 
@@ -208,15 +263,7 @@ module KnifeSolo
208
263
  end
209
264
 
210
265
  def process_sudo(command)
211
- if sudo_command
212
- Chef::Log.debug("Using replacement sudo command: #{sudo_command}")
213
- replacement = sudo_command
214
- elsif sudo_available?
215
- replacement = 'sudo -E -p \'knife sudo password: \''
216
- else
217
- replacement = ''
218
- end
219
- command.gsub(/sudo/, replacement)
266
+ command.gsub(/sudo/, sudo_command)
220
267
  end
221
268
 
222
269
  def process_startup_file(command)
@@ -32,13 +32,13 @@ class DeprecatedCommandTest < TestCase
32
32
 
33
33
  def test_warns_about_deprecation
34
34
  cmd = command
35
- cmd.ui.expects(:err).with(regexp_matches(/deprecated!/))
35
+ cmd.ui.expects(:warn).with(regexp_matches(/deprecated!/))
36
36
  cmd.run
37
37
  end
38
38
 
39
39
  def test_runs_new_command
40
40
  cmd = command
41
- cmd.ui.stubs(:err)
41
+ cmd.ui.stubs(:warn)
42
42
  cmd.expects(:new_run)
43
43
  cmd.run
44
44
  end
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../..'
4
+
5
+ gem 'chef', '~> 12'
@@ -8,7 +8,7 @@ module Apache2Bootstrap
8
8
 
9
9
  def write_berksfile
10
10
  File.open('Berksfile', 'w') do |f|
11
- f.puts "site :opscode"
11
+ f.puts 'source "https://supermarket.chef.io"'
12
12
  f.puts "cookbook 'apache2'"
13
13
  end
14
14
  end
@@ -0,0 +1,33 @@
1
+ # Tries to bootstrap with --hint option and
2
+ # verifies ohai hints get written properly.
3
+
4
+ module OhaiHints
5
+ def prepare_hints(hints)
6
+ hints.map { |name, data|
7
+ if data.nil?
8
+ "--hint #{name}"
9
+ else
10
+ File.open("#{name}.json", "wb") { |f| f.write(data) }
11
+ "--hint #{name}=#{name}.json"
12
+ end
13
+ }.join(' ')
14
+ end
15
+
16
+ def check_hints(hints)
17
+ hints.each do |name, data|
18
+ actual = `ssh #{connection_string} cat /etc/chef/ohai/hints/#{name}.json`
19
+ assert_match actual.strip, data.nil? ? '{}' : data
20
+ end
21
+ end
22
+
23
+ def test_ohai_hints
24
+ hints = {
25
+ 'test_hint_1' => '{"foo":"bar"}',
26
+ 'test_hint_2' => nil
27
+ }
28
+
29
+ hint_opts = prepare_hints(hints)
30
+ assert_subcommand "bootstrap #{hint_opts}"
31
+ check_hints(hints)
32
+ end
33
+ end
@@ -1,6 +1,8 @@
1
1
  require 'integration_helper'
2
2
 
3
3
  class Centos6_3Test < IntegrationTest
4
+ disable_firewall
5
+
4
6
  def user
5
7
  "root"
6
8
  end
@@ -9,15 +11,6 @@ class Centos6_3Test < IntegrationTest
9
11
  "ami-86e15bef"
10
12
  end
11
13
 
12
- def prepare_server
13
- disable_firewall
14
- super
15
- end
16
-
17
- def disable_firewall
18
- system "ssh #{connection_string} service iptables stop >> #{log_file}"
19
- end
20
-
21
14
  include EmptyCook
22
15
  include Apache2Cook
23
16
  include EncryptedDataBag
@@ -9,7 +9,7 @@ class Debian6BootstrapTest < IntegrationTest
9
9
  def image_id
10
10
  # PVM 64-bit
11
11
  # From https://wiki.debian.org/Cloud/AmazonEC2Image/Squeeze
12
- "ami-0740476e"
12
+ "ami-5e12dc36"
13
13
  end
14
14
 
15
15
  def prepare_server
@@ -8,7 +8,7 @@ class Debian7KnifeBootstrapTest < IntegrationTest
8
8
  def image_id
9
9
  # PVM instance store
10
10
  # From https://wiki.debian.org/Cloud/AmazonEC2Image/Wheezy
11
- "ami-848a6eec"
11
+ "ami-74efab1c"
12
12
  end
13
13
 
14
14
  def prepare_server
@@ -1,6 +1,8 @@
1
1
  require 'integration_helper'
2
2
 
3
3
  class ScientificLinux63Test < IntegrationTest
4
+ disable_firewall
5
+
4
6
  def user
5
7
  "root"
6
8
  end
@@ -10,6 +12,6 @@ class ScientificLinux63Test < IntegrationTest
10
12
  end
11
13
 
12
14
  include EmptyCook
13
- #include Apache2Cook
15
+ include Apache2Cook
14
16
  include EncryptedDataBag
15
17
  end
@@ -0,0 +1,17 @@
1
+ require 'integration_helper'
2
+
3
+ class Ubuntu12_04OhaiHintsTest < IntegrationTest
4
+ def user
5
+ "ubuntu"
6
+ end
7
+
8
+ def image_id
9
+ "ami-9a873ff3"
10
+ end
11
+
12
+ def prepare_server
13
+ # Do nothing as `solo bootstrap` will do everything
14
+ end
15
+
16
+ include OhaiHints
17
+ end
@@ -11,5 +11,5 @@ require 'support/loggable'
11
11
  require 'support/ec2_runner'
12
12
  require 'support/integration_test'
13
13
 
14
- MiniTest::Parallel.processor_count = 5
14
+ MiniTest::Parallel.processor_count = Dir[$base_dir.join('integration', '*.rb')].size
15
15
  MiniTest::Unit.runner = EC2Runner.new
@@ -49,7 +49,7 @@ class KnifeBootstrapTest < TestCase
49
49
 
50
50
  def test_barks_without_atleast_a_hostname
51
51
  cmd = command("--solo")
52
- cmd.ui.expects(:err)
52
+ cmd.ui.expects(:error)
53
53
  in_kitchen do
54
54
  assert_exits cmd
55
55
  end
@@ -51,9 +51,7 @@ class SoloCookTest < TestCase
51
51
  cmd.expects(:system!).with('rsync',
52
52
  '-rL',
53
53
  '--rsh=ssh ssh_arguments',
54
- '--delete-after',
55
54
  '--exclude=revision-deploys',
56
- '--exclude=tmp',
57
55
  '--exclude=.git',
58
56
  '--exclude=.hg',
59
57
  '--exclude=.svn',
@@ -64,7 +62,7 @@ class SoloCookTest < TestCase
64
62
  cmd.stubs(:ssh_args => 'ssh_arguments')
65
63
  cmd.stubs(:windows_node? => false)
66
64
 
67
- cmd.rsync 'source', 'dest'
65
+ cmd.rsync 'source', 'dest', []
68
66
  end
69
67
  end
70
68
 
@@ -76,9 +74,7 @@ class SoloCookTest < TestCase
76
74
  cmd.expects(:system!).with('rsync',
77
75
  '-rL',
78
76
  '--rsh=ssh -TA user@gateway ssh -T -o StrictHostKeyChecking=no ssh_arguments',
79
- '--delete-after',
80
77
  '--exclude=revision-deploys',
81
- '--exclude=tmp',
82
78
  '--exclude=.git',
83
79
  '--exclude=.hg',
84
80
  '--exclude=.svn',
@@ -89,7 +85,7 @@ class SoloCookTest < TestCase
89
85
  cmd.stubs(:ssh_args => 'ssh_arguments')
90
86
  cmd.stubs(:windows_node? => false)
91
87
 
92
- cmd.rsync 'source', 'dest'
88
+ cmd.rsync 'source', 'dest', []
93
89
  end
94
90
  end
95
91
 
@@ -175,8 +171,9 @@ class SoloCookTest < TestCase
175
171
  in_kitchen do
176
172
  FileUtils.touch "Berksfile"
177
173
  cmd = command("somehost")
178
- cmd.ui.expects(:err).with(regexp_matches(/berkshelf gem/))
179
- KnifeSolo::Berkshelf.expects(:load_gem).returns(false)
174
+ cmd.ui.expects(:warn).with(regexp_matches(/LoadError/))
175
+ cmd.ui.expects(:warn).with(regexp_matches(/berkshelf gem/))
176
+ KnifeSolo::Berkshelf.expects(:load_gem).raises(LoadError)
180
177
  Berkshelf::Berksfile.any_instance.expects(:vendor).never
181
178
  cmd.run
182
179
  end
@@ -185,7 +182,7 @@ class SoloCookTest < TestCase
185
182
  def test_wont_complain_if_berkshelf_gem_missing_but_no_berkfile
186
183
  in_kitchen do
187
184
  cmd = command("somehost")
188
- cmd.ui.expects(:err).never
185
+ cmd.ui.expects(:fatal).never
189
186
  KnifeSolo::Berkshelf.expects(:load_gem).never
190
187
  Berkshelf::Berksfile.any_instance.expects(:vendor).never
191
188
  cmd.run
@@ -230,8 +227,9 @@ class SoloCookTest < TestCase
230
227
  in_kitchen do
231
228
  FileUtils.touch "Cheffile"
232
229
  cmd = command("somehost")
233
- cmd.ui.expects(:err).with(regexp_matches(/librarian-chef gem/))
234
- KnifeSolo::Librarian.expects(:load_gem).returns(false)
230
+ cmd.ui.expects(:warn).with(regexp_matches(/LoadError/))
231
+ cmd.ui.expects(:warn).with(regexp_matches(/librarian-chef gem/))
232
+ KnifeSolo::Librarian.expects(:load_gem).raises(LoadError)
235
233
  Librarian::Action::Install.any_instance.expects(:run).never
236
234
  cmd.run
237
235
  end
@@ -23,7 +23,7 @@ class SoloInitTest < TestCase
23
23
 
24
24
  def test_barks_without_directory_arg
25
25
  cmd = command
26
- cmd.ui.expects(:err).with(regexp_matches(/You must specify a directory/))
26
+ cmd.ui.expects(:fatal).with(regexp_matches(/You must specify a directory/))
27
27
  $stdout.stubs(:puts)
28
28
  outside_kitchen do
29
29
  assert_exits cmd
@@ -110,7 +110,7 @@ class SoloInitTest < TestCase
110
110
  def test_wont_create_berksfile_if_gem_missing
111
111
  outside_kitchen do
112
112
  cmd = command(".")
113
- KnifeSolo::Berkshelf.expects(:load_gem).returns(false)
113
+ KnifeSolo::Berkshelf.expects(:load_gem).raises(LoadError)
114
114
  cmd.run
115
115
  refute File.exist?("Berksfile")
116
116
  end
@@ -189,7 +189,7 @@ class SoloInitTest < TestCase
189
189
  def test_wont_create_cheffile_if_gem_missing
190
190
  outside_kitchen do
191
191
  cmd = command(".")
192
- KnifeSolo::Librarian.expects(:load_gem).returns(false)
192
+ KnifeSolo::Librarian.expects(:load_gem).raises(LoadError)
193
193
  cmd.run
194
194
  refute File.exist?("Cheffile")
195
195
  end
@@ -210,8 +210,8 @@ class SoloInitTest < TestCase
210
210
  end
211
211
 
212
212
  def command(*args)
213
- KnifeSolo::Berkshelf.stubs(:load_gem).returns(false)
214
- KnifeSolo::Librarian.stubs(:load_gem).returns(false)
213
+ KnifeSolo::Berkshelf.stubs(:load_gem).raises(LoadError)
214
+ KnifeSolo::Librarian.stubs(:load_gem).raises(LoadError)
215
215
  knife_command(Chef::Knife::SoloInit, *args)
216
216
  end
217
217
  end
@@ -158,11 +158,15 @@ class SshCommandTest < TestCase
158
158
  cmd = command("usertest@10.0.0.1", "--ssh-gateway=test@host.com")
159
159
  cmd.validate_ssh_options!
160
160
  assert_equal "usertest@10.0.0.1", cmd.ssh_args
161
+
162
+ cmd = command_internal("usertest@10.0.0.1", "--ssh-gateway=test@host.com")
163
+ cmd.validate_ssh_options!
164
+ assert_equal "usertest@10.0.0.1 -o ControlMaster=auto -o ControlPath=#{cmd.ssh_control_path} -o ControlPersist=3600", cmd.ssh_args
161
165
  end
162
166
 
163
167
  def test_barks_without_atleast_a_hostname
164
168
  cmd = command
165
- cmd.ui.expects(:err).with(regexp_matches(/hostname.*argument/))
169
+ cmd.ui.expects(:fatal).with(regexp_matches(/hostname.*argument/))
166
170
  $stdout.stubs(:puts)
167
171
  assert_exits { cmd.validate_ssh_options! }
168
172
  end
@@ -188,6 +192,32 @@ class SshCommandTest < TestCase
188
192
  assert_equal 1, res.exit_code
189
193
  end
190
194
 
195
+ def test_handle_ssh_keepalive
196
+ cmd = command("usertest@10.0.0.1", "--ssh-keepalive", '--ssh-keepalive-interval=100')
197
+ cmd.validate_ssh_options!
198
+ assert_equal true, cmd.connection_options[:keepalive]
199
+ assert_equal 100, cmd.connection_options[:keepalive_interval]
200
+ end
201
+
202
+ def test_handle_no_ssh_keepalive
203
+ cmd = command("usertest@10.0.0.1", "--no-ssh-keepalive")
204
+ assert_equal nil, cmd.connection_options[:keepalive]
205
+ end
206
+
207
+ def test_handle_default_ssh_keepalive_is_true
208
+ cmd = command("usertest@10.0.0.1")
209
+ cmd.validate_ssh_options!
210
+ assert_equal true, cmd.connection_options[:keepalive]
211
+ assert_equal 300, cmd.connection_options[:keepalive_interval]
212
+ end
213
+
214
+ def test_barks_if_ssh_keepalive_is_zero
215
+ cmd = command("usertest@10.0.0.1", "--ssh-keepalive-interval=0")
216
+ cmd.ui.expects(:fatal).with(regexp_matches(/--ssh-keepalive-interval.*positive number/))
217
+ $stdout.stubs(:puts)
218
+ assert_exits { cmd.validate_ssh_options! }
219
+ end
220
+
191
221
  def result(code, stdout = "")
192
222
  res = KnifeSolo::SshConnection::ExecResult.new(code)
193
223
  res.stdout = stdout
@@ -195,6 +225,11 @@ class SshCommandTest < TestCase
195
225
  end
196
226
 
197
227
  def command(*args)
228
+ args << '--ssh-control-master=no'
229
+ command_internal(*args)
230
+ end
231
+
232
+ def command_internal(*args)
198
233
  Net::SSH::Config.stubs(:default_files)
199
234
  knife_command(DummySshCommand, *args)
200
235
  end
@@ -42,19 +42,24 @@ class EC2Runner < MiniTest::Unit
42
42
  `nc #{dns_name} 22 -w 1 -q 0 </dev/null`
43
43
  $?.success?
44
44
  end
45
- logger.info "Sleeping 10s to avoid Net::SSH locking up by connecting too early..."
46
- logger.info " (if you know a better way, please send me a note at https://github.com/matschaffer/knife-solo)"
47
- # These may have better ways:
48
- # http://rubydoc.info/gems/fog/Fog/Compute/AWS/Server:setup
49
- # http://rubydoc.info/gems/knife-ec2/Chef/Knife/Ec2ServerCreate:tcp_test_ssh
50
- sleep 10
45
+
46
+ unless server.tags["knife_solo_ssh_sleep_passed"]
47
+ logger.info "Sleeping 10s to avoid Net::SSH locking up by connecting too early..."
48
+ logger.info " (if you know a better way, please send me a note at https://github.com/matschaffer/knife-solo)"
49
+ # These may have better ways:
50
+ # http://rubydoc.info/gems/fog/Fog/Compute/AWS/Server:setup
51
+ # http://rubydoc.info/gems/knife-ec2/Chef/Knife/Ec2ServerCreate:tcp_test_ssh
52
+ sleep 10
53
+ tag_as(:ssh_sleep_passed, server)
54
+ end
55
+
51
56
  server
52
57
  end
53
58
 
54
59
  # Adds a knife_solo_prepared tag to the server so we can know not to re-prepare it
55
- def tag_as_prepared(server)
60
+ def tag_as(state, server)
56
61
  compute.tags.create(resource_id: server.identity,
57
- key: :knife_solo_prepared,
62
+ key: "knife_solo_#{state}",
58
63
  value: true)
59
64
  end
60
65
 
@@ -1,4 +1,4 @@
1
- name "environment"
1
+ name "environment_cookbook"
2
2
  maintainer "Mat Schaffer"
3
3
  maintainer_email "mat@schaffer.me"
4
4
  license "MIT"
@@ -66,8 +66,11 @@ class IntegrationTest < TestCase
66
66
  # Prepares the server unless it has already been marked as such
67
67
  def prepare_server
68
68
  return if server.tags["knife_solo_prepared"]
69
+ if self.class.firewall_disabled
70
+ system "ssh #{connection_string} service iptables stop >> #{log_file}"
71
+ end
69
72
  assert_subcommand prepare_command
70
- runner.tag_as_prepared(server)
73
+ runner.tag_as(:prepared, server)
71
74
  end
72
75
 
73
76
  # The prepare command to use on this server
@@ -87,7 +90,11 @@ class IntegrationTest < TestCase
87
90
 
88
91
  # Asserts that a knife command is successful
89
92
  def assert_knife_command(subcommand)
90
- system "knife #{subcommand} #{connection_string} -VV >> #{log_file}"
93
+ pid = Process.spawn("knife #{subcommand} #{connection_string} -VV",
94
+ :out => log_file.to_s,
95
+ :err => log_file.to_s)
96
+ Process.wait(pid)
97
+
91
98
  assert $?.success?
92
99
  end
93
100
 
@@ -95,5 +102,13 @@ class IntegrationTest < TestCase
95
102
  def assert_subcommand(subcommand)
96
103
  assert_knife_command "solo #{subcommand}"
97
104
  end
105
+
106
+ class << self
107
+ attr_reader :firewall_disabled
108
+
109
+ def disable_firewall
110
+ @firewall_disabled = true
111
+ end
112
+ end
98
113
  end
99
114
 
File without changes
@@ -12,8 +12,9 @@ class TestCase < MiniTest::Unit::TestCase
12
12
  cmd_class.load_deps
13
13
  command = cmd_class.new(args)
14
14
  command.ui.stubs(:msg)
15
- command.ui.stubs(:err)
15
+ command.ui.stubs(:warn)
16
16
  Chef::Config[:verbosity] = 0
17
+ command.config[:config_file] = "#{__dir__}/knife.rb"
17
18
  command.configure_chef
18
19
  command
19
20
  end
@@ -7,7 +7,7 @@ module ValidationHelper
7
7
 
8
8
  def test_barks_without_atleast_a_hostname
9
9
  cmd = command
10
- cmd.ui.expects(:err).with(regexp_matches(/hostname.*argument/))
10
+ cmd.ui.expects(:fatal).with(regexp_matches(/hostname.*argument/))
11
11
  $stdout.stubs(:puts)
12
12
  in_kitchen do
13
13
  assert_exits cmd
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-solo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Schaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: berkshelf
@@ -170,21 +170,21 @@ dependencies:
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '10.12'
173
+ version: '10.20'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '10.12'
180
+ version: '10.20'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: net-ssh
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 2.2.2
187
+ version: '2.7'
188
188
  - - "<"
189
189
  - !ruby/object:Gem::Version
190
190
  version: '3.0'
@@ -192,9 +192,9 @@ dependencies:
192
192
  prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - ">="
195
+ - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: 2.2.2
197
+ version: '2.7'
198
198
  - - "<"
199
199
  - !ruby/object:Gem::Version
200
200
  version: '3.0'
@@ -218,7 +218,6 @@ executables: []
218
218
  extensions: []
219
219
  extra_rdoc_files: []
220
220
  files:
221
- - ".coveralls.yml"
222
221
  - CHANGELOG.md
223
222
  - LICENSE
224
223
  - README.rdoc
@@ -279,6 +278,7 @@ files:
279
278
  - test/deprecated_command_test.rb
280
279
  - test/gemfiles/Gemfile.chef-10
281
280
  - test/gemfiles/Gemfile.chef-11
281
+ - test/gemfiles/Gemfile.chef-12
282
282
  - test/gemfiles/Gemfile.chef-master
283
283
  - test/gitignore_test.rb
284
284
  - test/integration/amazon_linux_2012_09_bootstrap_test.rb
@@ -290,6 +290,7 @@ files:
290
290
  - test/integration/cases/encrypted_data_bag.rb
291
291
  - test/integration/cases/environment.rb
292
292
  - test/integration/cases/knife_bootstrap.rb
293
+ - test/integration/cases/ohai_hints.rb
293
294
  - test/integration/centos5_8_test.rb
294
295
  - test/integration/centos6_3_test.rb
295
296
  - test/integration/debian6_bootstrap_test.rb
@@ -298,8 +299,8 @@ files:
298
299
  - test/integration/omnios_r151004_test.rb
299
300
  - test/integration/scientific_linux_63_test.rb
300
301
  - test/integration/sles_11_test.rb
301
- - test/integration/ubuntu10_04_test.rb
302
302
  - test/integration/ubuntu12_04_bootstrap_test.rb
303
+ - test/integration/ubuntu12_04_ohai_hints_test.rb
303
304
  - test/integration/ubuntu12_04_test.rb
304
305
  - test/integration_helper.rb
305
306
  - test/knife_bootstrap_test.rb
@@ -325,6 +326,7 @@ files:
325
326
  - test/support/issue_files/sles11-sp1
326
327
  - test/support/issue_files/ubuntu
327
328
  - test/support/kitchen_helper.rb
329
+ - test/support/knife.rb
328
330
  - test/support/loggable.rb
329
331
  - test/support/secret_cookbook/metadata.rb
330
332
  - test/support/secret_cookbook/recipes/default.rb
@@ -372,6 +374,7 @@ test_files:
372
374
  - test/deprecated_command_test.rb
373
375
  - test/gemfiles/Gemfile.chef-10
374
376
  - test/gemfiles/Gemfile.chef-11
377
+ - test/gemfiles/Gemfile.chef-12
375
378
  - test/gemfiles/Gemfile.chef-master
376
379
  - test/gitignore_test.rb
377
380
  - test/integration/amazon_linux_2012_09_bootstrap_test.rb
@@ -383,6 +386,7 @@ test_files:
383
386
  - test/integration/cases/encrypted_data_bag.rb
384
387
  - test/integration/cases/environment.rb
385
388
  - test/integration/cases/knife_bootstrap.rb
389
+ - test/integration/cases/ohai_hints.rb
386
390
  - test/integration/centos5_8_test.rb
387
391
  - test/integration/centos6_3_test.rb
388
392
  - test/integration/debian6_bootstrap_test.rb
@@ -391,8 +395,8 @@ test_files:
391
395
  - test/integration/omnios_r151004_test.rb
392
396
  - test/integration/scientific_linux_63_test.rb
393
397
  - test/integration/sles_11_test.rb
394
- - test/integration/ubuntu10_04_test.rb
395
398
  - test/integration/ubuntu12_04_bootstrap_test.rb
399
+ - test/integration/ubuntu12_04_ohai_hints_test.rb
396
400
  - test/integration/ubuntu12_04_test.rb
397
401
  - test/integration_helper.rb
398
402
  - test/knife_bootstrap_test.rb
@@ -418,6 +422,7 @@ test_files:
418
422
  - test/support/issue_files/sles11-sp1
419
423
  - test/support/issue_files/ubuntu
420
424
  - test/support/kitchen_helper.rb
425
+ - test/support/knife.rb
421
426
  - test/support/loggable.rb
422
427
  - test/support/secret_cookbook/metadata.rb
423
428
  - test/support/secret_cookbook/recipes/default.rb
@@ -1,2 +0,0 @@
1
- service_name: travis-pro
2
- repo_token: Z5jr8jFYz6ILfHjkgsFw6fd6CEMR8Mmdn
@@ -1,15 +0,0 @@
1
- require 'integration_helper'
2
-
3
- class Ubuntu10_04Test < IntegrationTest
4
- def user
5
- "ubuntu"
6
- end
7
-
8
- def image_id
9
- "ami-6936fb00"
10
- end
11
-
12
- include EmptyCook
13
- include Apache2Cook
14
- include EncryptedDataBag
15
- end