ridley 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +0 -55
- data/lib/ridley.rb +0 -2
- data/lib/ridley/chef_objects/node_object.rb +0 -14
- data/lib/ridley/client.rb +0 -16
- data/lib/ridley/resources/node_resource.rb +0 -189
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +0 -2
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +0 -16
- data/spec/unit/ridley/client_spec.rb +0 -12
- data/spec/unit/ridley/resources/node_resource_spec.rb +2 -133
- metadata +2 -46
- data/lib/ridley/host_commander.rb +0 -231
- data/lib/ridley/host_connector.rb +0 -83
- data/lib/ridley/host_connector/response.rb +0 -27
- data/lib/ridley/host_connector/ssh.rb +0 -211
- data/lib/ridley/host_connector/winrm.rb +0 -218
- data/lib/ridley/host_connector/winrm/command_uploader.rb +0 -87
- data/spec/unit/ridley/host_commander_spec.rb +0 -173
- data/spec/unit/ridley/host_connector/ssh_spec.rb +0 -57
- data/spec/unit/ridley/host_connector/winrm/command_uploader_spec.rb +0 -67
- data/spec/unit/ridley/host_connector/winrm_spec.rb +0 -145
- data/spec/unit/ridley/host_connector_spec.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1502e3edb782cbe22be2729744d1272bb81c9863
|
4
|
+
data.tar.gz: 26860b2a9731e88a3077d58ae1b46257c6055157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13bae8f8d79d3baeea469c9cb082f143a6a6bbaf976cd61b8c936e51fc5603ae59dcc09fa17dbe696f894c3ca384fe3a064cdb57997ca4061f3ec6a043864b79
|
7
|
+
data.tar.gz: f536df4f30fd045955a06108adc8df2284fb4b6425d4fabc054bf262e2e8f8d06f5b9025cc8e1b25278bfe0daa199dc41fe2b3459d05503b5a8cb340d62d9f57
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 2.0.0
|
2
|
+
|
3
|
+
* [#227](https://github.com/RiotGames/ridley/pull/227) HostCommander and HostConnector code has been moved into its own gem - [found here](https://github.com/RiotGames/ridley-connectors)
|
4
|
+
* As discussed by @jtimberman in [#225](https://github.com/RiotGames/ridley/issues/225) it makes sense to move this code based on Ridley's main purpose, and gives a decent performance boost to users who don't need this extra functionality.
|
5
|
+
|
1
6
|
# 1.7.1
|
2
7
|
|
3
8
|
* [#224](https://github.com/RiotGames/ridley/pull/224) Connection#stream will now return true/false on whether it copied the file that was streamed.
|
data/README.md
CHANGED
@@ -337,61 +337,6 @@ production_env.set_override_attribute("my_app.proxy.enabled", false)
|
|
337
337
|
production_env.save #=> true
|
338
338
|
```
|
339
339
|
|
340
|
-
Node Resource
|
341
|
-
-------------
|
342
|
-
|
343
|
-
### Bootstrapping Unix nodes
|
344
|
-
|
345
|
-
```ruby
|
346
|
-
ridley = Ridley.new(
|
347
|
-
server_url: "https://api.opscode.com",
|
348
|
-
organization: "vialstudios",
|
349
|
-
validator_client: "vialstudios-validator",
|
350
|
-
validator_path: "/Users/reset/.chef/vialstudios-validator.pem",
|
351
|
-
ssh: {
|
352
|
-
user: "vagrant",
|
353
|
-
password: "vagrant"
|
354
|
-
}
|
355
|
-
)
|
356
|
-
|
357
|
-
ridley.node.bootstrap("33.33.33.10", "33.33.33.11")
|
358
|
-
```
|
359
|
-
|
360
|
-
### Bootstrapping Windows Nodes
|
361
|
-
|
362
|
-
Windows Nodes are bootstrapped using a combination of WinRM, Batch, and PowerShell. You will probably need to tweak some settings on your Windows servers to ensure the commands are successful.
|
363
|
-
|
364
|
-
#### WinRM Settings
|
365
|
-
|
366
|
-
1. Enable WinRM: `winrm quickconfig` and say Yes.
|
367
|
-
2. Set some WinRM settings to ensure that you don't get 401 Unauthorized responses and 500 Responses because of timeouts.
|
368
|
-
|
369
|
-
```
|
370
|
-
winrm set winrm/config/service/auth @{Basic="true"}
|
371
|
-
winrm set winrm/config/service @{AllowUnencrypted="true"}
|
372
|
-
winrm set winrm/config/service @{EnumerationTimeoutms="600000"}
|
373
|
-
winrm set winrm/config @{MaxTimeoutms="600000"}
|
374
|
-
winrm set winrm/config/client @{TrustedHosts="*"}
|
375
|
-
```
|
376
|
-
|
377
|
-
#### PowerShell Settings
|
378
|
-
|
379
|
-
1. You should also configure your PowerShell profile, so that PowerShell commands have a more lenient timeout period.
|
380
|
-
|
381
|
-
```
|
382
|
-
mkdir C:\Users\my_user\Documents\WindowsPowerShell
|
383
|
-
echo "$PSSessionOption = New-PSSessionOption -OpenTimeout 0 -CancelTimeout 0 -IdleTimeout 0 -OperationTimeout 0" > C:\Users\my_user\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
|
384
|
-
```
|
385
|
-
|
386
|
-
Verify the PowerShell settings by opening up the PowerShell Console and entering `$PSSessionOption` and ensure those values are set, and that there are no errors output.
|
387
|
-
|
388
|
-
The following links offer some information about configuring a machine's PowerShell settings:
|
389
|
-
- [PowerShell Profiles](http://technet.microsoft.com/en-us/library/ee692764.aspx)
|
390
|
-
- [The $PSSessionOptions Preference Variable](http://technet.microsoft.com/library/hh847796.aspx)
|
391
|
-
- [Creating a new PSSessionOption](http://technet.microsoft.com/en-us/library/hh849703.aspx)
|
392
|
-
|
393
|
-
You may also want to tweak your Windows boxes a bit more ex: turning UAC off, turning off the Windows Firewall.
|
394
|
-
|
395
340
|
Role Resource
|
396
341
|
-------------
|
397
342
|
|
data/lib/ridley.rb
CHANGED
@@ -71,8 +71,6 @@ module Ridley
|
|
71
71
|
require_relative 'ridley/client'
|
72
72
|
require_relative 'ridley/connection'
|
73
73
|
require_relative 'ridley/chef'
|
74
|
-
require_relative 'ridley/host_commander'
|
75
|
-
require_relative 'ridley/host_connector'
|
76
74
|
require_relative 'ridley/middleware'
|
77
75
|
require_relative 'ridley/resource'
|
78
76
|
require_relative 'ridley/resources'
|
@@ -124,20 +124,6 @@ module Ridley
|
|
124
124
|
self.cloud_provider == "rackspace"
|
125
125
|
end
|
126
126
|
|
127
|
-
# Executes a Chef run on the node
|
128
|
-
#
|
129
|
-
# @return [HostConnector::Response]
|
130
|
-
def chef_run
|
131
|
-
resource.chef_run(self.public_hostname)
|
132
|
-
end
|
133
|
-
|
134
|
-
# Puts the configured encrypted data bag secret on the node
|
135
|
-
#
|
136
|
-
# @return [HostConnector::Response]
|
137
|
-
def put_secret
|
138
|
-
resource.put_secret(self.public_hostname)
|
139
|
-
end
|
140
|
-
|
141
127
|
# Merges the instaniated nodes data with the given data and updates
|
142
128
|
# the remote with the merged results
|
143
129
|
#
|
data/lib/ridley/client.rb
CHANGED
@@ -86,8 +86,6 @@ module Ridley
|
|
86
86
|
attr_accessor :validator_client
|
87
87
|
attr_accessor :validator_path
|
88
88
|
attr_accessor :encrypted_data_bag_secret_path
|
89
|
-
attr_accessor :ssh
|
90
|
-
attr_accessor :winrm
|
91
89
|
attr_accessor :chef_version
|
92
90
|
|
93
91
|
# @option options [String] :server_url
|
@@ -99,16 +97,6 @@ module Ridley
|
|
99
97
|
# @option options [String] :validator_client (nil)
|
100
98
|
# @option options [String] :validator_path (nil)
|
101
99
|
# @option options [String] :encrypted_data_bag_secret_path (nil)
|
102
|
-
# @option options [Hash] :ssh (Hash.new)
|
103
|
-
# * :user (String) a shell user that will login to each node and perform the bootstrap command on (required)
|
104
|
-
# * :password (String) the password for the shell user that will perform the bootstrap
|
105
|
-
# * :keys (Array, String) an array of keys (or a single key) to authenticate the ssh user with instead of a password
|
106
|
-
# * :timeout (Float) [5.0] timeout value for SSH bootstrap
|
107
|
-
# * :sudo (Boolean) [true] bootstrap with sudo
|
108
|
-
# @option options [Hash] :winrm (Hash.new)
|
109
|
-
# * :user (String) a user that will login to each node and perform the bootstrap command on (required)
|
110
|
-
# * :password (String) the password for the user that will perform the bootstrap
|
111
|
-
# * :port (Fixnum) the winrm port to connect on the node the bootstrap will be performed on (5985)
|
112
100
|
# @option options [String] :chef_version
|
113
101
|
# the version of Chef to use when bootstrapping
|
114
102
|
# @option options [Hash] :params
|
@@ -128,14 +116,10 @@ module Ridley
|
|
128
116
|
# a file path pointing to a readable client key, or is a string containing a valid key
|
129
117
|
def initialize(options = {})
|
130
118
|
@options = options.reverse_merge(
|
131
|
-
ssh: Hash.new,
|
132
|
-
winrm: Hash.new,
|
133
119
|
pool_size: 4
|
134
120
|
).deep_symbolize_keys
|
135
121
|
self.class.validate_options(@options)
|
136
122
|
|
137
|
-
@ssh = @options[:ssh]
|
138
|
-
@winrm = @options[:winrm]
|
139
123
|
@chef_version = @options[:chef_version]
|
140
124
|
@validator_client = @options[:validator_client]
|
141
125
|
|
@@ -5,165 +5,11 @@ module Ridley
|
|
5
5
|
set_resource_path "nodes"
|
6
6
|
represented_by Ridley::NodeObject
|
7
7
|
|
8
|
-
attr_reader :server_url
|
9
|
-
attr_reader :validator_path
|
10
|
-
attr_reader :validator_client
|
11
|
-
attr_reader :encrypted_data_bag_secret
|
12
|
-
attr_reader :ssh
|
13
|
-
attr_reader :winrm
|
14
|
-
attr_reader :chef_version
|
15
|
-
|
16
|
-
finalizer :finalize_callback
|
17
|
-
|
18
8
|
# @param [Celluloid::Registry] connection_registry
|
19
|
-
#
|
20
|
-
# @option options [String] :server_url
|
21
|
-
# URL to the Chef API
|
22
|
-
# @option options [Hash] ssh
|
23
|
-
# * :user (String) a shell user that will login to each node and perform the bootstrap command on
|
24
|
-
# * :password (String) the password for the shell user that will perform the bootstrap
|
25
|
-
# * :keys (Array, String) an array of keys (or a single key) to authenticate the ssh user with instead of a password
|
26
|
-
# * :timeout (Float) [5.0] timeout value for SSH bootstrap
|
27
|
-
# @option options [Hash] :winrm
|
28
|
-
# * :user (String) a user that will login to each node and perform the bootstrap command on
|
29
|
-
# * :password (String) the password for the user that will perform the bootstrap
|
30
|
-
# * :port (Fixnum) the winrm port to connect on the node the bootstrap will be performed on
|
31
|
-
# @option options [String] :validator_client
|
32
|
-
# @option options [String] :validator_path
|
33
|
-
# filepath to the validator used to bootstrap the node
|
34
|
-
# @option options [String] :encrypted_data_bag_secret
|
35
|
-
# your organizations encrypted data bag secret
|
36
|
-
# @option options [String] :chef_version
|
37
|
-
# version of Chef to install on the node (default: nil)
|
38
9
|
def initialize(connection_registry, options = {})
|
39
10
|
super(connection_registry)
|
40
|
-
@server_url = options[:server_url]
|
41
|
-
@validator_path = options[:validator_path]
|
42
|
-
@validator_client = options[:validator_client]
|
43
|
-
@encrypted_data_bag_secret = options[:encrypted_data_bag_secret]
|
44
|
-
@ssh = options[:ssh]
|
45
|
-
@winrm = options[:winrm]
|
46
|
-
@chef_version = options[:chef_version]
|
47
|
-
@host_commander = HostCommander.new_link
|
48
11
|
end
|
49
12
|
|
50
|
-
# @param [String] host
|
51
|
-
#
|
52
|
-
# @option options [Hash] ssh
|
53
|
-
# * :user (String) a shell user that will login to each node and perform the bootstrap command on (required)
|
54
|
-
# * :password (String) the password for the shell user that will perform the bootstrap
|
55
|
-
# * :keys (Array, String) an array of keys (or a single key) to authenticate the ssh user with instead of a password
|
56
|
-
# * :timeout (Float) [5.0] timeout value for SSH bootstrap
|
57
|
-
# @option options [Hash] :winrm
|
58
|
-
# * :user (String) a user that will login to each node and perform the bootstrap command on (required)
|
59
|
-
# * :password (String) the password for the user that will perform the bootstrap
|
60
|
-
# * :port (Fixnum) the winrm port to connect on the node the bootstrap will be performed on (5985)
|
61
|
-
# @option options [String] :validator_client
|
62
|
-
# @option options [String] :validator_path
|
63
|
-
# filepath to the validator used to bootstrap the node (required)
|
64
|
-
# @option options [String] :bootstrap_proxy
|
65
|
-
# URL to a proxy server to bootstrap through (default: nil)
|
66
|
-
# @option options [String] :encrypted_data_bag_secret_path
|
67
|
-
# filepath on your host machine to your organizations encrypted data bag secret (default: nil)
|
68
|
-
# @option options [Hash] :hints
|
69
|
-
# a hash of Ohai hints to place on the bootstrapped node (default: Hash.new)
|
70
|
-
# @option options [Hash] :attributes
|
71
|
-
# a hash of attributes to use in the first Chef run (default: Hash.new)
|
72
|
-
# @option options [Array] :run_list
|
73
|
-
# an initial run list to bootstrap with (default: Array.new)
|
74
|
-
# @option options [String] :chef_version
|
75
|
-
# version of Chef to install on the node (default: nil)
|
76
|
-
# @option options [String] :environment
|
77
|
-
# environment to join the node to (default: '_default')
|
78
|
-
# @option options [Boolean] :sudo
|
79
|
-
# bootstrap with sudo (default: true)
|
80
|
-
# @option options [String] :template
|
81
|
-
# bootstrap template to use (default: omnibus)
|
82
|
-
#
|
83
|
-
# @return [HostConnector::Response]
|
84
|
-
def bootstrap(host, options = {})
|
85
|
-
options = options.reverse_merge(
|
86
|
-
server_url: server_url,
|
87
|
-
validator_path: validator_path,
|
88
|
-
validator_client: validator_client,
|
89
|
-
encrypted_data_bag_secret: encrypted_data_bag_secret,
|
90
|
-
ssh: ssh,
|
91
|
-
winrm: winrm,
|
92
|
-
chef_version: chef_version
|
93
|
-
)
|
94
|
-
|
95
|
-
host_commander.bootstrap(host, options)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Executes a Chef run using the best worker available for the given
|
99
|
-
# host.
|
100
|
-
#
|
101
|
-
# @param [String] host
|
102
|
-
#
|
103
|
-
# @return [HostConnector::Response]
|
104
|
-
def chef_run(host)
|
105
|
-
host_commander.chef_client(host, ssh: ssh, winrm: winrm)
|
106
|
-
rescue Errors::HostConnectionError => ex
|
107
|
-
abort(ex)
|
108
|
-
end
|
109
|
-
|
110
|
-
# Puts a secret on the host using the best worker available for
|
111
|
-
# the given host.
|
112
|
-
#
|
113
|
-
# @param [String] host
|
114
|
-
#
|
115
|
-
# @return [HostConnector::Response]
|
116
|
-
def put_secret(host)
|
117
|
-
host_commander.put_secret(host, encrypted_data_bag_secret, ssh: ssh, winrm: winrm)
|
118
|
-
end
|
119
|
-
|
120
|
-
# Executes an arbitrary ruby script using the best worker available
|
121
|
-
# for the given host.
|
122
|
-
#
|
123
|
-
# @param [String] host
|
124
|
-
# @param [Array<String>] command_lines
|
125
|
-
#
|
126
|
-
# @return [HostConnector::Response]
|
127
|
-
def ruby_script(host, command_lines)
|
128
|
-
host_commander.ruby_script(host, command_lines, ssh: ssh, winrm: winrm)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Executes the given command on a node using the best worker
|
132
|
-
# available for the given host.
|
133
|
-
#
|
134
|
-
# @param [String] host
|
135
|
-
# @param [String] command
|
136
|
-
#
|
137
|
-
# @return [HostConnector::Response]
|
138
|
-
def run(host, command)
|
139
|
-
host_commander.run(host, command, ssh: ssh, winrm: winrm)
|
140
|
-
end
|
141
|
-
alias_method :execute_command, :run
|
142
|
-
|
143
|
-
# Executes the given command on a node using a platform specific
|
144
|
-
# command.
|
145
|
-
#
|
146
|
-
# @param [String] host
|
147
|
-
# @param [Hash] commands
|
148
|
-
#
|
149
|
-
# @example
|
150
|
-
# platform_specific_run("host.example.com", linux: "hostname -f", windows: "echo %COMPUTERNAME%")
|
151
|
-
#
|
152
|
-
# @return [HostConnector::Response]
|
153
|
-
def platform_specific_run(host, commands)
|
154
|
-
case (type = host_commander.connector_for(host, ssh: ssh, winrm: winrm))
|
155
|
-
when HostConnector::SSH
|
156
|
-
raise Errors::CommandNotProvided.new(:ssh) unless commands[:ssh] and !commands[:ssh].empty?
|
157
|
-
run(host, commands[:ssh])
|
158
|
-
when HostConnector::WinRM
|
159
|
-
raise Errors::CommandNotProvided.new(:winrm) unless commands[:winrm] and !commands[:winrm].empty?
|
160
|
-
run(host, commands[:winrm])
|
161
|
-
else
|
162
|
-
raise RuntimeError, "#{type.class.to_s} is not a supported connector for #{self.class}##{__method__}"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
alias_method :execute_platform_specific_command, :platform_specific_run
|
166
|
-
|
167
13
|
# Merges the given data with the the data of the target node on the remote
|
168
14
|
#
|
169
15
|
# @param [Ridley::NodeResource, String] target
|
@@ -185,40 +31,5 @@ module Ridley
|
|
185
31
|
|
186
32
|
update(node.merge_data(options))
|
187
33
|
end
|
188
|
-
|
189
|
-
# Uninstall Chef from a node
|
190
|
-
#
|
191
|
-
# @param [String] host
|
192
|
-
# the host to perform the action on
|
193
|
-
#
|
194
|
-
# @option options [Boolena] :skip_chef (false)
|
195
|
-
# skip removal of the Chef package and the contents of the installation
|
196
|
-
# directory. Setting this to true will only remove any data and configurations
|
197
|
-
# generated by running Chef client.
|
198
|
-
# @option options [Hash] :ssh
|
199
|
-
# * :user (String) a shell user that will login to each node and perform the bootstrap command on
|
200
|
-
# * :password (String) the password for the shell user that will perform the bootstrap
|
201
|
-
# * :keys (Array, String) an array of key(s) to authenticate the ssh user with instead of a password
|
202
|
-
# * :timeout (Float) timeout value for SSH bootstrap (5.0)
|
203
|
-
# * :sudo (Boolean) run as sudo (true)
|
204
|
-
# @option options [Hash] :winrm
|
205
|
-
# * :user (String) a user that will login to each node and perform the bootstrap command on
|
206
|
-
# * :password (String) the password for the user that will perform the bootstrap (required)
|
207
|
-
# * :port (Fixnum) the winrm port to connect on the node the bootstrap will be performed on (5985)
|
208
|
-
#
|
209
|
-
# @return [HostConnector::Response]
|
210
|
-
def uninstall_chef(host, options = {})
|
211
|
-
options = options.reverse_merge(ssh: ssh, winrm: winrm)
|
212
|
-
host_commander.uninstall_chef(host, options)
|
213
|
-
end
|
214
|
-
|
215
|
-
private
|
216
|
-
|
217
|
-
# @return [Ridley::HostCommander]
|
218
|
-
attr_reader :host_commander
|
219
|
-
|
220
|
-
def finalize_callback
|
221
|
-
@host_commander.terminate if @host_commander && @host_commander.alive?
|
222
|
-
end
|
223
34
|
end
|
224
35
|
end
|
data/lib/ridley/version.rb
CHANGED
data/ridley.gemspec
CHANGED
@@ -31,10 +31,8 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_dependency 'json', '>= 1.7.7'
|
32
32
|
s.add_dependency 'mixlib-authentication', '>= 1.3.0'
|
33
33
|
s.add_dependency 'net-http-persistent', '>= 2.8'
|
34
|
-
s.add_dependency 'net-ssh'
|
35
34
|
s.add_dependency 'retryable'
|
36
35
|
s.add_dependency 'solve', '>= 0.4.4'
|
37
|
-
s.add_dependency 'winrm', '~> 1.1.0'
|
38
36
|
|
39
37
|
s.add_development_dependency 'buff-ruby_engine', '~> 0.1'
|
40
38
|
end
|
@@ -241,22 +241,6 @@ describe Ridley::NodeObject do
|
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
|
-
describe "#chef_run" do
|
245
|
-
it "sends the message #chef_run to the resource with the public_hostname of this instance" do
|
246
|
-
resource.should_receive(:chef_run).with(instance.public_hostname)
|
247
|
-
|
248
|
-
subject.chef_run
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
describe "#put_secret" do
|
253
|
-
it "sends the message #put_secret to the resource with the public_hostname of this instance" do
|
254
|
-
resource.should_receive(:put_secret).with(instance.public_hostname)
|
255
|
-
|
256
|
-
subject.put_secret
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
244
|
describe "#merge_data" do
|
261
245
|
before(:each) { subject.name = "reset.riotgames.com" }
|
262
246
|
|
@@ -6,8 +6,6 @@ describe Ridley::Client do
|
|
6
6
|
let(:client_key) { fixtures_path.join("reset.pem").to_s }
|
7
7
|
let(:organization) { "vialstudios" }
|
8
8
|
let(:encrypted_data_bag_secret_path) { fixtures_path.join("reset.pem").to_s }
|
9
|
-
let(:ssh) { {user: "reset", password: "password1", port: "222"} }
|
10
|
-
let(:winrm) { {user: "reset", password: "password2", port: "5986"} }
|
11
9
|
let(:chef_version) { "10.24.0-01" }
|
12
10
|
|
13
11
|
let(:config) do
|
@@ -17,8 +15,6 @@ describe Ridley::Client do
|
|
17
15
|
client_key: client_key,
|
18
16
|
organization: organization,
|
19
17
|
encrypted_data_bag_secret_path: encrypted_data_bag_secret_path,
|
20
|
-
ssh: ssh,
|
21
|
-
winrm: winrm,
|
22
18
|
chef_version: chef_version
|
23
19
|
}
|
24
20
|
end
|
@@ -107,14 +103,6 @@ describe Ridley::Client do
|
|
107
103
|
described_class.new(config).client_key.should == key
|
108
104
|
end
|
109
105
|
|
110
|
-
it "assigns a 'ssh' attribute from the given 'ssh' option" do
|
111
|
-
described_class.new(config).ssh.should eql({user: "reset", password: "password1", port: "222"})
|
112
|
-
end
|
113
|
-
|
114
|
-
it "assigns a 'winrm' attribute from the given 'winrm' option" do
|
115
|
-
described_class.new(config).winrm.should eql({user: "reset", password: "password2", port: "5986"})
|
116
|
-
end
|
117
|
-
|
118
106
|
it "assigns a 'chef_version' attribute from the given 'chef_version' option" do
|
119
107
|
described_class.new(config).chef_version.should eql("10.24.0-01")
|
120
108
|
end
|
@@ -1,143 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ridley::NodeResource do
|
4
|
-
let(:host) { "33.33.33.10" }
|
5
|
-
let(:worker) { double('worker', alive?: true, terminate: nil) }
|
6
|
-
let(:host_commander) { double('host-commander') }
|
7
|
-
let(:options) do
|
8
|
-
{
|
9
|
-
server_url: double('server_url'),
|
10
|
-
validator_path: double('validator_path'),
|
11
|
-
validator_client: double('validator_client'),
|
12
|
-
encrypted_data_bag_secret: double('encrypted_data_bag_secret'),
|
13
|
-
ssh: double('ssh'),
|
14
|
-
winrm: double('winrm'),
|
15
|
-
chef_version: double('chef_version')
|
16
|
-
}
|
17
|
-
end
|
18
4
|
let(:instance) do
|
19
|
-
inst = described_class.new(double
|
20
|
-
inst.stub(connection: chef_zero_connection
|
5
|
+
inst = described_class.new(double)
|
6
|
+
inst.stub(connection: chef_zero_connection)
|
21
7
|
inst
|
22
8
|
end
|
23
9
|
|
24
|
-
describe "#bootstrap" do
|
25
|
-
it "sends the message #bootstrap to the instance's host_commander" do
|
26
|
-
host_commander.should_receive(:bootstrap).with(host, options)
|
27
|
-
instance.bootstrap(host)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "passes pre-configured options to #bootstrap" do
|
31
|
-
host_commander.should_receive(:bootstrap).with(host, options)
|
32
|
-
instance.bootstrap(host)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#chef_run" do
|
37
|
-
it "sends the message #chef_client to the instance's host_commander" do
|
38
|
-
host_commander.should_receive(:chef_client).with(host, ssh: instance.ssh, winrm: instance.winrm)
|
39
|
-
instance.chef_run(host)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#put_secret" do
|
44
|
-
let(:secret) { options[:encrypted_data_bag_secret] }
|
45
|
-
|
46
|
-
it "sends the message #put_secret to the instance's host_commander" do
|
47
|
-
host_commander.should_receive(:put_secret).with(host, secret, options.slice(:ssh, :winrm))
|
48
|
-
instance.put_secret(host)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "#ruby_script" do
|
53
|
-
let(:command_lines) { ["puts 'hello'", "puts 'there'"] }
|
54
|
-
|
55
|
-
it "sends the message #ruby_script to the instance's host_commander" do
|
56
|
-
host_commander.should_receive(:ruby_script).with(host, command_lines, ssh: instance.ssh, winrm: instance.winrm)
|
57
|
-
instance.ruby_script(host, command_lines)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#run" do
|
62
|
-
let(:command) { "echo 'hello world'" }
|
63
|
-
|
64
|
-
it "sends the message #run to the instance's host_commander" do
|
65
|
-
host_commander.should_receive(:run).with(host, command, ssh: instance.ssh, winrm: instance.winrm)
|
66
|
-
instance.run(host, command)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#platform_specific_run" do
|
71
|
-
let(:ssh_command) { "hostname -f" }
|
72
|
-
let(:winrm_command) { "echo %COMPUTERNAME%" }
|
73
|
-
let(:ssh_connector) { Ridley::HostConnector::SSH.new }
|
74
|
-
let(:winrm_connector) { Ridley::HostConnector::WinRM.new }
|
75
|
-
let(:unsupported_connector) { Object.new }
|
76
|
-
|
77
|
-
describe "expecting the ssh connector" do
|
78
|
-
before do
|
79
|
-
host_commander.stub(:connector_for).and_return ssh_connector
|
80
|
-
end
|
81
|
-
it "sends the ssh command" do
|
82
|
-
instance.should_receive(:run).with(host, ssh_command)
|
83
|
-
instance.platform_specific_run(host, ssh: ssh_command, winrm: winrm_command)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "raises an error if no command is provided for the ssh connector when the ssh connector is used" do
|
87
|
-
expect {
|
88
|
-
instance.platform_specific_run(host, winrm: winrm_command)
|
89
|
-
}.to raise_error(Ridley::Errors::CommandNotProvided)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "raises an error if an empty command is provided for the ssh connector when the ssh connector is used" do
|
93
|
-
expect {
|
94
|
-
instance.platform_specific_run(host, ssh: "", winrm: winrm_command)
|
95
|
-
}.to raise_error(Ridley::Errors::CommandNotProvided)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "raises an error if a nil command is provided for the ssh connector when the ssh connector is used" do
|
99
|
-
expect {
|
100
|
-
instance.platform_specific_run(host, ssh: nil, winrm: winrm_command)
|
101
|
-
}.to raise_error(Ridley::Errors::CommandNotProvided)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe "expecting the winrm connector" do
|
106
|
-
before do
|
107
|
-
host_commander.stub(:connector_for).and_return winrm_connector
|
108
|
-
end
|
109
|
-
it "sends the ssh command if the connector is winrm" do
|
110
|
-
instance.should_receive(:run).with(host, winrm_command)
|
111
|
-
instance.platform_specific_run(host, ssh: ssh_command, winrm: winrm_command)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "raises an error if no command is provided for the winrm connector when the winrm connector is used" do
|
115
|
-
expect {
|
116
|
-
instance.platform_specific_run(host, ssh: ssh_command)
|
117
|
-
}.to raise_error(Ridley::Errors::CommandNotProvided)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "raises an error if an empty is provided for the winrm connector when the winrm connector is used" do
|
121
|
-
expect {
|
122
|
-
instance.platform_specific_run(host, ssh: ssh_command, winrm: "")
|
123
|
-
}.to raise_error(Ridley::Errors::CommandNotProvided)
|
124
|
-
end
|
125
|
-
|
126
|
-
it "raises a nil command is provided for the winrm connector when the winrm connector is used" do
|
127
|
-
expect {
|
128
|
-
instance.platform_specific_run(host, ssh: ssh_command, winrm: nil)
|
129
|
-
}.to raise_error(Ridley::Errors::CommandNotProvided)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
it "raises a RuntimeError if an unsupported connector is used" do
|
134
|
-
host_commander.stub(:connector_for).and_return unsupported_connector
|
135
|
-
expect {
|
136
|
-
instance.platform_specific_run(host, ssh: ssh_command, winrm: winrm_command)
|
137
|
-
}.to raise_error(RuntimeError)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
10
|
describe "#merge_data" do
|
142
11
|
let(:node_name) { "rspec-test" }
|
143
12
|
let(:run_list) { [ "recipe[one]", "recipe[two]" ] }
|