ridley 0.9.1 → 0.10.0.rc1

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 (51) hide show
  1. data/.gitignore +1 -0
  2. data/.ruby-version +1 -0
  3. data/Guardfile +1 -1
  4. data/README.md +1 -1
  5. data/bootstrappers/{omnibus.erb → unix_omnibus.erb} +20 -5
  6. data/bootstrappers/windows_omnibus.erb +133 -0
  7. data/lib/ridley.rb +4 -1
  8. data/lib/ridley/bootstrap_bindings.rb +5 -0
  9. data/lib/ridley/bootstrap_bindings/unix_template_binding.rb +112 -0
  10. data/lib/ridley/bootstrap_bindings/windows_template_binding.rb +221 -0
  11. data/lib/ridley/bootstrapper.rb +14 -22
  12. data/lib/ridley/bootstrapper/context.rb +53 -162
  13. data/lib/ridley/chef.rb +0 -1
  14. data/lib/ridley/chef/cookbook.rb +0 -9
  15. data/lib/ridley/client.rb +12 -1
  16. data/lib/ridley/errors.rb +1 -0
  17. data/lib/ridley/host_connector.rb +76 -0
  18. data/lib/ridley/{ssh → host_connector}/response.rb +1 -1
  19. data/lib/ridley/{ssh → host_connector}/response_set.rb +11 -11
  20. data/lib/ridley/host_connector/ssh.rb +58 -0
  21. data/lib/ridley/host_connector/ssh/worker.rb +99 -0
  22. data/lib/ridley/host_connector/winrm.rb +55 -0
  23. data/lib/ridley/host_connector/winrm/worker.rb +126 -0
  24. data/lib/ridley/mixin/bootstrap_binding.rb +88 -0
  25. data/lib/ridley/resource.rb +1 -1
  26. data/lib/ridley/resources/client_resource.rb +7 -0
  27. data/lib/ridley/resources/node_resource.rb +9 -4
  28. data/lib/ridley/sandbox_uploader.rb +1 -7
  29. data/lib/ridley/version.rb +1 -1
  30. data/ridley.gemspec +1 -0
  31. data/spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb +102 -0
  32. data/spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb +118 -0
  33. data/spec/unit/ridley/bootstrapper/context_spec.rb +19 -106
  34. data/spec/unit/ridley/bootstrapper_spec.rb +2 -12
  35. data/spec/unit/ridley/client_spec.rb +20 -2
  36. data/spec/unit/ridley/{ssh → host_connector}/response_set_spec.rb +17 -17
  37. data/spec/unit/ridley/host_connector/ssh/worker_spec.rb +15 -0
  38. data/spec/unit/ridley/{ssh_spec.rb → host_connector/ssh_spec.rb} +5 -5
  39. data/spec/unit/ridley/host_connector/winrm/worker_spec.rb +41 -0
  40. data/spec/unit/ridley/host_connector/winrm_spec.rb +47 -0
  41. data/spec/unit/ridley/host_connector_spec.rb +102 -0
  42. data/spec/unit/ridley/mixin/bootstrap_binding_spec.rb +56 -0
  43. data/spec/unit/ridley/sandbox_uploader_spec.rb +1 -28
  44. metadata +53 -25
  45. data/.rbenv-version +0 -1
  46. data/lib/ridley/chef/chefignore.rb +0 -76
  47. data/lib/ridley/ssh.rb +0 -56
  48. data/lib/ridley/ssh/worker.rb +0 -87
  49. data/spec/fixtures/chefignore +0 -8
  50. data/spec/unit/ridley/chef/chefignore_spec.rb +0 -40
  51. data/spec/unit/ridley/ssh/worker_spec.rb +0 -13
@@ -1,13 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ridley::SandboxUploader do
4
- let(:connection) { double('chef-conn') }
5
4
  let(:client) do
6
5
  double('client',
7
6
  client_name: 'reset',
8
7
  client_key: fixtures_path.join('reset.pem'),
9
- options: {},
10
- connection: connection
8
+ options: {}
11
9
  )
12
10
  end
13
11
 
@@ -68,10 +66,6 @@ describe Ridley::SandboxUploader do
68
66
  let(:chk_id) { "oGCPHrQ+5MylEL+V+NIJ9w==" }
69
67
  let(:path) { fixtures_path.join('reset.pem').to_s }
70
68
 
71
- before do
72
- connection.stub(foss?: false)
73
- end
74
-
75
69
  context "when the checksum needs uploading" do
76
70
  let(:checksums) do
77
71
  {
@@ -106,26 +100,5 @@ describe Ridley::SandboxUploader do
106
100
  subject.upload(chk_id, path).should be_nil
107
101
  end
108
102
  end
109
-
110
- context "when the connection is an open source server connection with a non-80 port" do
111
- before do
112
- connection.stub(foss?: true, server_url: "http://localhost:8889")
113
- end
114
-
115
- let(:checksums) do
116
- {
117
- chk_id => {
118
- url: "http://localhost/sandboxes/bd091b150b0a4578b97771af6abf3e05",
119
- needs_upload: true
120
- }
121
- }
122
- end
123
-
124
- it "does not strip the port from the target to upload to" do
125
- stub_request(:put, "http://localhost:8889/sandboxes/bd091b150b0a4578b97771af6abf3e05")
126
-
127
- subject.upload(chk_id, path)
128
- end
129
- end
130
103
  end
131
104
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
5
- prerelease:
4
+ version: 0.10.0.rc1
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jamie Winsor
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-28 00:00:00.000000000 Z
12
+ date: 2013-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -267,6 +267,22 @@ dependencies:
267
267
  - - ! '>='
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
+ - !ruby/object:Gem::Dependency
271
+ name: winrm
272
+ requirement: !ruby/object:Gem::Requirement
273
+ none: false
274
+ requirements:
275
+ - - ~>
276
+ - !ruby/object:Gem::Version
277
+ version: 1.1.0
278
+ type: :runtime
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ none: false
282
+ requirements:
283
+ - - ~>
284
+ - !ruby/object:Gem::Version
285
+ version: 1.1.0
270
286
  description: A reliable Chef API client with a clean syntax
271
287
  email:
272
288
  - reset@riotgames.com
@@ -275,20 +291,23 @@ extensions: []
275
291
  extra_rdoc_files: []
276
292
  files:
277
293
  - .gitignore
278
- - .rbenv-version
294
+ - .ruby-version
279
295
  - .travis.yml
280
296
  - Gemfile
281
297
  - Guardfile
282
298
  - LICENSE
283
299
  - README.md
284
300
  - Thorfile
285
- - bootstrappers/omnibus.erb
301
+ - bootstrappers/unix_omnibus.erb
302
+ - bootstrappers/windows_omnibus.erb
286
303
  - lib/ridley.rb
304
+ - lib/ridley/bootstrap_bindings.rb
305
+ - lib/ridley/bootstrap_bindings/unix_template_binding.rb
306
+ - lib/ridley/bootstrap_bindings/windows_template_binding.rb
287
307
  - lib/ridley/bootstrapper.rb
288
308
  - lib/ridley/bootstrapper/context.rb
289
309
  - lib/ridley/chain_link.rb
290
310
  - lib/ridley/chef.rb
291
- - lib/ridley/chef/chefignore.rb
292
311
  - lib/ridley/chef/cookbook.rb
293
312
  - lib/ridley/chef/cookbook/metadata.rb
294
313
  - lib/ridley/chef/cookbook/syntax_check.rb
@@ -296,6 +315,13 @@ files:
296
315
  - lib/ridley/client.rb
297
316
  - lib/ridley/connection.rb
298
317
  - lib/ridley/errors.rb
318
+ - lib/ridley/host_connector.rb
319
+ - lib/ridley/host_connector/response.rb
320
+ - lib/ridley/host_connector/response_set.rb
321
+ - lib/ridley/host_connector/ssh.rb
322
+ - lib/ridley/host_connector/ssh/worker.rb
323
+ - lib/ridley/host_connector/winrm.rb
324
+ - lib/ridley/host_connector/winrm/worker.rb
299
325
  - lib/ridley/log.rb
300
326
  - lib/ridley/logging.rb
301
327
  - lib/ridley/middleware.rb
@@ -305,6 +331,7 @@ files:
305
331
  - lib/ridley/middleware/parse_json.rb
306
332
  - lib/ridley/middleware/retry.rb
307
333
  - lib/ridley/mixin.rb
334
+ - lib/ridley/mixin/bootstrap_binding.rb
308
335
  - lib/ridley/mixin/checksum.rb
309
336
  - lib/ridley/mixin/shell_out.rb
310
337
  - lib/ridley/resource.rb
@@ -320,10 +347,6 @@ files:
320
347
  - lib/ridley/resources/sandbox_resource.rb
321
348
  - lib/ridley/resources/search.rb
322
349
  - lib/ridley/sandbox_uploader.rb
323
- - lib/ridley/ssh.rb
324
- - lib/ridley/ssh/response.rb
325
- - lib/ridley/ssh/response_set.rb
326
- - lib/ridley/ssh/worker.rb
327
350
  - lib/ridley/version.rb
328
351
  - ridley.gemspec
329
352
  - spec/acceptance/bootstrapping_spec.rb
@@ -335,7 +358,6 @@ files:
335
358
  - spec/acceptance/role_resource_spec.rb
336
359
  - spec/acceptance/sandbox_resource_spec.rb
337
360
  - spec/acceptance/search_resource_spec.rb
338
- - spec/fixtures/chefignore
339
361
  - spec/fixtures/encrypted_data_bag_secret
340
362
  - spec/fixtures/example_cookbook/README.md
341
363
  - spec/fixtures/example_cookbook/attributes/default.rb
@@ -357,17 +379,25 @@ files:
357
379
  - spec/support/filepath_matchers.rb
358
380
  - spec/support/shared_examples/ridley_resource.rb
359
381
  - spec/support/spec_helpers.rb
382
+ - spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb
383
+ - spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb
360
384
  - spec/unit/ridley/bootstrapper/context_spec.rb
361
385
  - spec/unit/ridley/bootstrapper_spec.rb
362
- - spec/unit/ridley/chef/chefignore_spec.rb
363
386
  - spec/unit/ridley/chef/cookbook_spec.rb
364
387
  - spec/unit/ridley/chef/digester_spec.rb
365
388
  - spec/unit/ridley/client_spec.rb
366
389
  - spec/unit/ridley/connection_spec.rb
367
390
  - spec/unit/ridley/errors_spec.rb
391
+ - spec/unit/ridley/host_connector/response_set_spec.rb
392
+ - spec/unit/ridley/host_connector/ssh/worker_spec.rb
393
+ - spec/unit/ridley/host_connector/ssh_spec.rb
394
+ - spec/unit/ridley/host_connector/winrm/worker_spec.rb
395
+ - spec/unit/ridley/host_connector/winrm_spec.rb
396
+ - spec/unit/ridley/host_connector_spec.rb
368
397
  - spec/unit/ridley/middleware/chef_auth_spec.rb
369
398
  - spec/unit/ridley/middleware/chef_response_spec.rb
370
399
  - spec/unit/ridley/middleware/parse_json_spec.rb
400
+ - spec/unit/ridley/mixin/bootstrap_binding_spec.rb
371
401
  - spec/unit/ridley/resource_spec.rb
372
402
  - spec/unit/ridley/resources/client_resource_spec.rb
373
403
  - spec/unit/ridley/resources/cookbook_resource_spec.rb
@@ -379,9 +409,6 @@ files:
379
409
  - spec/unit/ridley/resources/sandbox_resource_spec.rb
380
410
  - spec/unit/ridley/resources/search_spec.rb
381
411
  - spec/unit/ridley/sandbox_uploader_spec.rb
382
- - spec/unit/ridley/ssh/response_set_spec.rb
383
- - spec/unit/ridley/ssh/worker_spec.rb
384
- - spec/unit/ridley/ssh_spec.rb
385
412
  - spec/unit/ridley_spec.rb
386
413
  homepage: https://github.com/reset/ridley
387
414
  licenses:
@@ -399,12 +426,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
399
426
  required_rubygems_version: !ruby/object:Gem::Requirement
400
427
  none: false
401
428
  requirements:
402
- - - ! '>='
429
+ - - ! '>'
403
430
  - !ruby/object:Gem::Version
404
- version: '0'
405
- segments:
406
- - 0
407
- hash: -3927256690615298092
431
+ version: 1.3.1
408
432
  requirements: []
409
433
  rubyforge_project:
410
434
  rubygems_version: 1.8.23
@@ -421,7 +445,6 @@ test_files:
421
445
  - spec/acceptance/role_resource_spec.rb
422
446
  - spec/acceptance/sandbox_resource_spec.rb
423
447
  - spec/acceptance/search_resource_spec.rb
424
- - spec/fixtures/chefignore
425
448
  - spec/fixtures/encrypted_data_bag_secret
426
449
  - spec/fixtures/example_cookbook/README.md
427
450
  - spec/fixtures/example_cookbook/attributes/default.rb
@@ -443,17 +466,25 @@ test_files:
443
466
  - spec/support/filepath_matchers.rb
444
467
  - spec/support/shared_examples/ridley_resource.rb
445
468
  - spec/support/spec_helpers.rb
469
+ - spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb
470
+ - spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb
446
471
  - spec/unit/ridley/bootstrapper/context_spec.rb
447
472
  - spec/unit/ridley/bootstrapper_spec.rb
448
- - spec/unit/ridley/chef/chefignore_spec.rb
449
473
  - spec/unit/ridley/chef/cookbook_spec.rb
450
474
  - spec/unit/ridley/chef/digester_spec.rb
451
475
  - spec/unit/ridley/client_spec.rb
452
476
  - spec/unit/ridley/connection_spec.rb
453
477
  - spec/unit/ridley/errors_spec.rb
478
+ - spec/unit/ridley/host_connector/response_set_spec.rb
479
+ - spec/unit/ridley/host_connector/ssh/worker_spec.rb
480
+ - spec/unit/ridley/host_connector/ssh_spec.rb
481
+ - spec/unit/ridley/host_connector/winrm/worker_spec.rb
482
+ - spec/unit/ridley/host_connector/winrm_spec.rb
483
+ - spec/unit/ridley/host_connector_spec.rb
454
484
  - spec/unit/ridley/middleware/chef_auth_spec.rb
455
485
  - spec/unit/ridley/middleware/chef_response_spec.rb
456
486
  - spec/unit/ridley/middleware/parse_json_spec.rb
487
+ - spec/unit/ridley/mixin/bootstrap_binding_spec.rb
457
488
  - spec/unit/ridley/resource_spec.rb
458
489
  - spec/unit/ridley/resources/client_resource_spec.rb
459
490
  - spec/unit/ridley/resources/cookbook_resource_spec.rb
@@ -465,8 +496,5 @@ test_files:
465
496
  - spec/unit/ridley/resources/sandbox_resource_spec.rb
466
497
  - spec/unit/ridley/resources/search_spec.rb
467
498
  - spec/unit/ridley/sandbox_uploader_spec.rb
468
- - spec/unit/ridley/ssh/response_set_spec.rb
469
- - spec/unit/ridley/ssh/worker_spec.rb
470
- - spec/unit/ridley/ssh_spec.rb
471
499
  - spec/unit/ridley_spec.rb
472
500
  has_rdoc:
data/.rbenv-version DELETED
@@ -1 +0,0 @@
1
- 1.9.3-p327
@@ -1,76 +0,0 @@
1
- module Ridley::Chef
2
- # Borrowed and modified from:
3
- # {https://raw.github.com/opscode/chef/62f9b0e3be8e22eef092163c331b7d3f8d350f94/lib/chef/cookbook/chefignore.rb}
4
- #
5
- # Copyright:: Copyright (c) 2011 Opscode, Inc.
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- class Chefignore
19
- class << self
20
- # Traverse a path in relative context to find a Chefignore file
21
- #
22
- # @param [String] path
23
- # path to traverse
24
- #
25
- # @return [String, nil]
26
- def find_relative_to(path)
27
- [
28
- File.join(path, FILENAME),
29
- File.join(path, 'cookbooks', FILENAME)
30
- ].find { |f| File.exists?(f) }
31
- end
32
- end
33
-
34
- FILENAME = "chefignore".freeze
35
- COMMENTS_AND_WHITESPACE = /^\s*(?:#.*)?$/
36
-
37
- attr_reader :ignores
38
-
39
- def initialize(ignore_file_or_repo)
40
- @ignore_file = find_ignore_file(ignore_file_or_repo)
41
- @ignores = parse_ignore_file
42
- end
43
-
44
- def remove_ignores_from(file_list)
45
- Array(file_list).inject([]) do |unignored, file|
46
- ignored?(file) ? unignored : unignored << file
47
- end
48
- end
49
-
50
- def ignored?(file_name)
51
- @ignores.any? { |glob| File.fnmatch?(glob, file_name) }
52
- end
53
-
54
- private
55
-
56
- def parse_ignore_file
57
- ignore_globs = []
58
-
59
- if File.exist?(@ignore_file) && File.readable?(@ignore_file)
60
- File.foreach(@ignore_file) do |line|
61
- ignore_globs << line.strip unless line =~ COMMENTS_AND_WHITESPACE
62
- end
63
- end
64
-
65
- ignore_globs
66
- end
67
-
68
- def find_ignore_file(path)
69
- if File.basename(path) =~ /#{FILENAME}/
70
- path
71
- else
72
- File.join(path, FILENAME)
73
- end
74
- end
75
- end
76
- end
data/lib/ridley/ssh.rb DELETED
@@ -1,56 +0,0 @@
1
- require 'net/ssh'
2
-
3
- module Ridley
4
- # @author Jamie Winsor <reset@riotgames.com>
5
- class SSH
6
- autoload :Response, 'ridley/ssh/response'
7
- autoload :ResponseSet, 'ridley/ssh/response_set'
8
- autoload :Worker, 'ridley/ssh/worker'
9
-
10
- class << self
11
- # @param [Ridley::NodeResource, Array<Ridley::NodeResource>] nodes
12
- # @param [Hash] options
13
- def start(nodes, options = {}, &block)
14
- runner = new(nodes, options)
15
- result = yield runner
16
- runner.terminate
17
-
18
- result
19
- end
20
- end
21
-
22
- include Celluloid
23
- include Celluloid::Logger
24
-
25
- attr_reader :nodes
26
- attr_reader :options
27
-
28
- # @param [Ridley::NodeResource, Array<Ridley::NodeResource>] nodes
29
- # @param [Hash] options
30
- # @see Net::SSH
31
- def initialize(nodes, options = {})
32
- @nodes = Array(nodes)
33
- @options = options
34
- end
35
-
36
- # @param [String] command
37
- #
38
- # @return [Array]
39
- def run(command)
40
- workers = Array.new
41
- futures = self.nodes.collect do |node|
42
- workers << worker = Worker.new_link(self.options.freeze)
43
- worker.future.run(node.public_hostname, command)
44
- end
45
-
46
- ResponseSet.new.tap do |response_set|
47
- futures.each do |future|
48
- status, response = future.value
49
- response_set.add_response(response)
50
- end
51
- end
52
- ensure
53
- workers.map(&:terminate)
54
- end
55
- end
56
- end
@@ -1,87 +0,0 @@
1
- module Ridley
2
- class SSH
3
- # @author Jamie Winsor <reset@riotgames.com>
4
- # @api private
5
- class Worker
6
- include Celluloid
7
- include Celluloid::Logger
8
-
9
- attr_reader :sudo
10
- attr_reader :user
11
- # @return [Hashie::Mash]
12
- attr_reader :options
13
-
14
- # @param [Hash] options
15
- def initialize(options = {})
16
- @options = options.deep_symbolize_keys
17
- @sudo = @options[:sudo]
18
- @user = @options[:user]
19
-
20
- @options[:paranoid] = false
21
- end
22
-
23
- # @param [String] host
24
- # @param [String] command
25
- #
26
- # @return [Array]
27
- def run(host, command)
28
- response = Response.new(host)
29
- debug "Running SSH command: '#{command}' on: '#{host}' as: '#{user}'"
30
-
31
- Net::SSH.start(host, user, options.slice(*Net::SSH::VALID_OPTIONS)) do |ssh|
32
- ssh.open_channel do |channel|
33
- if self.sudo
34
- channel.request_pty
35
- end
36
-
37
- channel.exec(command) do |ch, success|
38
- unless success
39
- raise "FAILURE: could not execute command"
40
- end
41
-
42
- channel.on_data do |ch, data|
43
- response.stdout += data
44
- info "NODE[#{host}] #{data}" if data.present? and data != "\r\n"
45
- end
46
-
47
- channel.on_extended_data do |ch, type, data|
48
- response.stderr += data
49
- info "NODE[#{host}] #{data}" if data.present? and data != "\r\n"
50
- end
51
-
52
- channel.on_request("exit-status") do |ch, data|
53
- response.exit_code = data.read_long
54
- end
55
-
56
- channel.on_request("exit-signal") do |ch, data|
57
- response.exit_signal = data.read_string
58
- end
59
- end
60
- end
61
-
62
- ssh.loop
63
- end
64
-
65
- case response.exit_code
66
- when 0
67
- debug "Successfully ran SSH command on: '#{host}' as: '#{user}'"
68
- [ :ok, response ]
69
- else
70
- error "Successfully ran SSH command on: '#{host}' as: '#{user}', but it failed"
71
- error response.stdout
72
- [ :error, response ]
73
- end
74
- rescue => e
75
- error "Failed to run SSH command on: '#{host}' as: '#{user}'"
76
- error "#{e.class}: #{e.message}"
77
- response.exit_code = -1
78
- response.stderr = e.message
79
- [ :error, response ]
80
- end
81
-
82
- private
83
-
84
- attr_reader :runner
85
- end
86
- end
87
- end