ridley 3.0.0 → 3.1.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 +12 -0
- data/lib/ridley.rb +0 -7
- data/lib/ridley/chef/cookbook/metadata.rb +10 -5
- data/lib/ridley/errors.rb +2 -21
- data/lib/ridley/version.rb +1 -1
- metadata +2 -18
- data/bootstrappers/unix_omnibus.erb +0 -91
- data/bootstrappers/windows_omnibus.erb +0 -113
- data/lib/ridley/bootstrap_context.rb +0 -100
- data/lib/ridley/bootstrap_context/unix.rb +0 -66
- data/lib/ridley/bootstrap_context/windows.rb +0 -118
- data/lib/ridley/command_context.rb +0 -76
- data/lib/ridley/command_context/unix_uninstall.rb +0 -42
- data/lib/ridley/command_context/windows_uninstall.rb +0 -35
- data/scripts/unix_uninstall_omnibus.erb +0 -31
- data/scripts/windows_uninstall_omnibus.erb +0 -10
- data/spec/unit/ridley/bootstrap_context/unix_spec.rb +0 -101
- data/spec/unit/ridley/bootstrap_context/windows_spec.rb +0 -116
- data/spec/unit/ridley/bootstrap_context_spec.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 968e81fedae6ac8df2b43fa45ba63c2675649712
|
4
|
+
data.tar.gz: 8355ce066cb04cb21759e6392719c5f555370697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc2d17acabc40f0aa5115cc2984ba6e065a8edaac9c5711a8c2a191af51ac634b758d341a1e3b948aa1de3e1529e8422dd381d7c847fc904f65fee0e5fbeb7c
|
7
|
+
data.tar.gz: eddbbb6c33c0a06e3a6ccc845ccf98b1f4df87f689115bb57b6d56d0beadd57facd41f74888ab9ad4e273f49a4376159139d04e10b8117b47585aabff674d500
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 3.1.0
|
2
|
+
|
3
|
+
* Fix issue with evaluating metadata generated by older versions of knife
|
4
|
+
* Move remaining host-connector code out of Ridley and into Ridley-Connectors
|
5
|
+
|
6
|
+
# 3.0.0
|
7
|
+
|
8
|
+
* Update Faraday
|
9
|
+
* Update Celluloid
|
10
|
+
* Fix noise in chefignore when debug flag is turned on
|
11
|
+
* Fix issue reading files that contain UTF-8
|
12
|
+
|
1
13
|
# 2.5.1
|
2
14
|
|
3
15
|
* Fix no method error bug in partial search
|
data/lib/ridley.rb
CHANGED
@@ -55,18 +55,11 @@ module Ridley
|
|
55
55
|
def root
|
56
56
|
@root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
|
57
57
|
end
|
58
|
-
|
59
|
-
# @return [Pathname]
|
60
|
-
def scripts
|
61
|
-
root.join('scripts')
|
62
|
-
end
|
63
58
|
end
|
64
59
|
|
65
60
|
require_relative 'ridley/mixin'
|
66
61
|
require_relative 'ridley/logging'
|
67
62
|
require_relative 'ridley/logger'
|
68
|
-
require_relative 'ridley/bootstrap_context'
|
69
|
-
require_relative 'ridley/command_context'
|
70
63
|
require_relative 'ridley/chef_object'
|
71
64
|
require_relative 'ridley/chef_objects'
|
72
65
|
require_relative 'ridley/client'
|
@@ -440,7 +440,7 @@ module Ridley::Chef
|
|
440
440
|
@maintainer = o[MAINTAINER] if o.has_key?(MAINTAINER)
|
441
441
|
@maintainer_email = o[MAINTAINER_EMAIL] if o.has_key?(MAINTAINER_EMAIL)
|
442
442
|
@license = o[LICENSE] if o.has_key?(LICENSE)
|
443
|
-
@platforms = o[PLATFORMS] if o.has_key?(PLATFORMS)
|
443
|
+
@platforms = handle_deprecated_constraints(o[PLATFORMS]) if o.has_key?(PLATFORMS)
|
444
444
|
@dependencies = handle_deprecated_constraints(o[DEPENDENCIES]) if o.has_key?(DEPENDENCIES)
|
445
445
|
@recommendations = handle_deprecated_constraints(o[RECOMMENDATIONS]) if o.has_key?(RECOMMENDATIONS)
|
446
446
|
@suggestions = handle_deprecated_constraints(o[SUGGESTIONS]) if o.has_key?(SUGGESTIONS)
|
@@ -548,15 +548,20 @@ module Ridley::Chef
|
|
548
548
|
# Before we began respecting version constraints, we allowed
|
549
549
|
# multiple constraints to be placed on cookbooks, as well as the
|
550
550
|
# << and >> operators, which are now just < and >. For
|
551
|
-
# specifications with more than one constraint,
|
552
|
-
#
|
553
|
-
# the contract they have specified to us). If there is only one
|
551
|
+
# specifications with more than one constraint, this method switches to
|
552
|
+
# the default constraint from SemVerse. If there is only one
|
554
553
|
# constraint, we are replacing the old << and >> with the new <
|
555
554
|
# and >.
|
556
555
|
def handle_deprecated_constraints(specification)
|
557
556
|
specification.inject(Hashie::Mash.new) do |acc, (cb, constraints)|
|
558
557
|
constraints = Array(constraints)
|
559
|
-
|
558
|
+
|
559
|
+
acc[cb] = if constraints.size == 1
|
560
|
+
constraints.first.gsub(/>>/, '>').gsub(/<</, '<')
|
561
|
+
else
|
562
|
+
Semverse::DEFAULT_CONSTRAINT.to_s
|
563
|
+
end
|
564
|
+
|
560
565
|
acc
|
561
566
|
end
|
562
567
|
end
|
data/lib/ridley/errors.rb
CHANGED
@@ -66,27 +66,8 @@ module Ridley
|
|
66
66
|
alias_method :message, :to_s
|
67
67
|
end
|
68
68
|
|
69
|
-
class
|
70
|
-
class
|
71
|
-
class EncryptedDataBagSecretNotFound < BootstrapError; end
|
72
|
-
|
73
|
-
class HostConnectionError < RidleyError; end
|
74
|
-
class DNSResolvError < HostConnectionError; end
|
75
|
-
|
76
|
-
class RemoteCommandError < RidleyError; end
|
77
|
-
class RemoteScriptError < RemoteCommandError; end
|
78
|
-
class CommandNotProvided < RemoteCommandError
|
79
|
-
attr_reader :connector_type
|
80
|
-
|
81
|
-
# @params [Symbol] connector_type
|
82
|
-
def initialize(connector_type)
|
83
|
-
@connector_type = connector_type
|
84
|
-
end
|
85
|
-
|
86
|
-
def to_s
|
87
|
-
"No command provided in #{connector_type.inspect}, however the #{connector_type.inspect} connector was selected."
|
88
|
-
end
|
89
|
-
end
|
69
|
+
class ClientKeyFileNotFoundOrInvalid < RidleyError; end
|
70
|
+
class EncryptedDataBagSecretNotFound < RidleyError; end
|
90
71
|
|
91
72
|
# Exception thrown when the maximum amount of requests is exceeded.
|
92
73
|
class RedirectLimitReached < RidleyError
|
data/lib/ridley/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -266,12 +266,7 @@ files:
|
|
266
266
|
- LICENSE
|
267
267
|
- README.md
|
268
268
|
- Thorfile
|
269
|
-
- bootstrappers/unix_omnibus.erb
|
270
|
-
- bootstrappers/windows_omnibus.erb
|
271
269
|
- lib/ridley.rb
|
272
|
-
- lib/ridley/bootstrap_context.rb
|
273
|
-
- lib/ridley/bootstrap_context/unix.rb
|
274
|
-
- lib/ridley/bootstrap_context/windows.rb
|
275
270
|
- lib/ridley/chef.rb
|
276
271
|
- lib/ridley/chef/chefignore.rb
|
277
272
|
- lib/ridley/chef/config.rb
|
@@ -291,9 +286,6 @@ files:
|
|
291
286
|
- lib/ridley/chef_objects/sandbox_object.rb
|
292
287
|
- lib/ridley/chef_objects/user_object.rb
|
293
288
|
- lib/ridley/client.rb
|
294
|
-
- lib/ridley/command_context.rb
|
295
|
-
- lib/ridley/command_context/unix_uninstall.rb
|
296
|
-
- lib/ridley/command_context/windows_uninstall.rb
|
297
289
|
- lib/ridley/connection.rb
|
298
290
|
- lib/ridley/errors.rb
|
299
291
|
- lib/ridley/logger.rb
|
@@ -323,8 +315,6 @@ files:
|
|
323
315
|
- lib/ridley/sandbox_uploader.rb
|
324
316
|
- lib/ridley/version.rb
|
325
317
|
- ridley.gemspec
|
326
|
-
- scripts/unix_uninstall_omnibus.erb
|
327
|
-
- scripts/windows_uninstall_omnibus.erb
|
328
318
|
- spec/acceptance/client_resource_spec.rb
|
329
319
|
- spec/acceptance/cookbook_resource_spec.rb
|
330
320
|
- spec/acceptance/data_bag_item_resource_spec.rb
|
@@ -362,9 +352,6 @@ files:
|
|
362
352
|
- spec/support/filepath_matchers.rb
|
363
353
|
- spec/support/shared_examples/ridley_resource.rb
|
364
354
|
- spec/support/spec_helpers.rb
|
365
|
-
- spec/unit/ridley/bootstrap_context/unix_spec.rb
|
366
|
-
- spec/unit/ridley/bootstrap_context/windows_spec.rb
|
367
|
-
- spec/unit/ridley/bootstrap_context_spec.rb
|
368
355
|
- spec/unit/ridley/chef/chefignore_spec.rb
|
369
356
|
- spec/unit/ridley/chef/cookbook/metadata_spec.rb
|
370
357
|
- spec/unit/ridley/chef/cookbook/syntax_check_spec.rb
|
@@ -463,9 +450,6 @@ test_files:
|
|
463
450
|
- spec/support/filepath_matchers.rb
|
464
451
|
- spec/support/shared_examples/ridley_resource.rb
|
465
452
|
- spec/support/spec_helpers.rb
|
466
|
-
- spec/unit/ridley/bootstrap_context/unix_spec.rb
|
467
|
-
- spec/unit/ridley/bootstrap_context/windows_spec.rb
|
468
|
-
- spec/unit/ridley/bootstrap_context_spec.rb
|
469
453
|
- spec/unit/ridley/chef/chefignore_spec.rb
|
470
454
|
- spec/unit/ridley/chef/cookbook/metadata_spec.rb
|
471
455
|
- spec/unit/ridley/chef/cookbook/syntax_check_spec.rb
|
@@ -1,91 +0,0 @@
|
|
1
|
-
bash -c '
|
2
|
-
<%= "export http_proxy=\"#{bootstrap_proxy}\"" if bootstrap_proxy -%>
|
3
|
-
|
4
|
-
exists() {
|
5
|
-
if command -v $1 &>/dev/null
|
6
|
-
then
|
7
|
-
return 0
|
8
|
-
else
|
9
|
-
return 1
|
10
|
-
fi
|
11
|
-
}
|
12
|
-
|
13
|
-
install_chef() {
|
14
|
-
install_sh="http://opscode.com/chef/install.sh"
|
15
|
-
proxy_string="<%= "--proxy=on " if bootstrap_proxy %>"
|
16
|
-
|
17
|
-
if [[ $requested_chef_version != "" ]]; then
|
18
|
-
version_string="-v $requested_chef_version"
|
19
|
-
else
|
20
|
-
version_string=""
|
21
|
-
fi
|
22
|
-
|
23
|
-
if exists wget; then
|
24
|
-
bash <(wget ${proxy_string} ${install_sh} -O -) ${version_string}
|
25
|
-
else
|
26
|
-
if exists curl; then
|
27
|
-
bash <(curl -L ${proxy_string} ${install_sh}) ${version_string}
|
28
|
-
fi
|
29
|
-
fi
|
30
|
-
}
|
31
|
-
|
32
|
-
requested_chef_version="<%= chef_version %>"
|
33
|
-
installed_chef_version="$(which chef-client &>/dev/null && chef-client -v | cut -f 2 -d " ")"
|
34
|
-
|
35
|
-
if [[ ! $installed_chef_version ]]; then
|
36
|
-
install_chef
|
37
|
-
elif [[ ($requested_chef_version != "") && ($installed_chef_version != $requested_chef_version) ]]; then
|
38
|
-
install_chef
|
39
|
-
fi
|
40
|
-
|
41
|
-
mkdir -p /etc/chef
|
42
|
-
|
43
|
-
(
|
44
|
-
cat <<'EOP'
|
45
|
-
<%= validation_key %>
|
46
|
-
EOP
|
47
|
-
) > /tmp/validation.pem
|
48
|
-
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
49
|
-
rm /tmp/validation.pem
|
50
|
-
chmod 0600 /etc/chef/validation.pem
|
51
|
-
|
52
|
-
<% if encrypted_data_bag_secret -%>
|
53
|
-
(
|
54
|
-
cat <<'EOP'
|
55
|
-
<%= encrypted_data_bag_secret %>
|
56
|
-
EOP
|
57
|
-
) > /tmp/encrypted_data_bag_secret
|
58
|
-
awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
|
59
|
-
rm /tmp/encrypted_data_bag_secret
|
60
|
-
chmod 0600 /etc/chef/encrypted_data_bag_secret
|
61
|
-
<% end -%>
|
62
|
-
|
63
|
-
<%# Generate Ohai Hints -%>
|
64
|
-
<% unless hints.empty? -%>
|
65
|
-
mkdir -p /etc/chef/ohai/hints
|
66
|
-
|
67
|
-
<% hints.each do |name, hash| -%>
|
68
|
-
(
|
69
|
-
cat <<'EOP'
|
70
|
-
<%= hash.to_json %>
|
71
|
-
EOP
|
72
|
-
) > /etc/chef/ohai/hints/<%= name %>.json
|
73
|
-
<% end -%>
|
74
|
-
<% end -%>
|
75
|
-
|
76
|
-
(
|
77
|
-
cat <<'EOP'
|
78
|
-
<%= chef_config %>
|
79
|
-
EOP
|
80
|
-
) > /etc/chef/client.rb
|
81
|
-
|
82
|
-
<%# Remove client pem if it already exists -%>
|
83
|
-
rm /etc/chef/client.pem
|
84
|
-
|
85
|
-
(
|
86
|
-
cat <<'EOP'
|
87
|
-
<%= first_boot %>
|
88
|
-
EOP
|
89
|
-
) > /etc/chef/first-boot.json
|
90
|
-
|
91
|
-
<%= chef_run %>'
|
@@ -1,113 +0,0 @@
|
|
1
|
-
@echo off
|
2
|
-
|
3
|
-
rem Author:: Kyle Allan (<kallan@riotgames.com>)
|
4
|
-
rem Original Author:
|
5
|
-
rem
|
6
|
-
rem Author:: Seth Chisamore (<schisam@oopscode.com>)
|
7
|
-
rem Copyright:: Copyright (c) 2011 Opscode, Inc.
|
8
|
-
rem License:: Apache License, Version 2.0
|
9
|
-
rem
|
10
|
-
rem Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
rem you may not use this file except in compliance with the License.
|
12
|
-
rem You may obtain a copy of the License at
|
13
|
-
rem
|
14
|
-
rem http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
rem
|
16
|
-
rem Unless required by applicable law or agreed to in writing, software
|
17
|
-
rem distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
rem See the License for the specific language governing permissions and
|
20
|
-
rem limitations under the License.
|
21
|
-
rem
|
22
|
-
|
23
|
-
setlocal
|
24
|
-
|
25
|
-
<%= "SETX HTTP_PROXY \"#{bootstrap_proxy}\"" if bootstrap_proxy %>
|
26
|
-
mkdir <%= bootstrap_directory %>
|
27
|
-
|
28
|
-
> <%= bootstrap_directory %>\wget.ps1 (
|
29
|
-
<%= windows_wget_powershell %>
|
30
|
-
)
|
31
|
-
|
32
|
-
rem Determine the version and the architecture
|
33
|
-
|
34
|
-
FOR /F "tokens=1-8 delims=.[] " %%A IN ('ver') DO (
|
35
|
-
set WinMajor=%%D
|
36
|
-
set WinMinor=%%E
|
37
|
-
set WinBuild=%%F
|
38
|
-
)
|
39
|
-
|
40
|
-
goto Version%WinMajor%.%WinMinor%
|
41
|
-
|
42
|
-
rem If this is an unknown version of windows set the default
|
43
|
-
set MACHINE_OS=2008r2
|
44
|
-
goto architecture
|
45
|
-
|
46
|
-
:Version6.0
|
47
|
-
set MACHINE_OS=2008
|
48
|
-
goto architecture
|
49
|
-
|
50
|
-
:Version5.2
|
51
|
-
set MACHINE_OS=2003r2
|
52
|
-
goto architecture
|
53
|
-
|
54
|
-
:Version6.1
|
55
|
-
set MACHINE_OS=2008r2
|
56
|
-
goto architecture
|
57
|
-
|
58
|
-
:Version6.2
|
59
|
-
set MACHINE_OS=2012
|
60
|
-
goto architecture
|
61
|
-
|
62
|
-
:architecture
|
63
|
-
|
64
|
-
goto Architecture%PROCESSOR_ARCHITECTURE%
|
65
|
-
|
66
|
-
rem If this is an unknown architecture set the default
|
67
|
-
set MACHINE_ARCH=i686
|
68
|
-
goto install
|
69
|
-
|
70
|
-
:Architecturex86
|
71
|
-
set MACHINE_ARCH=i686
|
72
|
-
goto install
|
73
|
-
|
74
|
-
:Architectureamd64
|
75
|
-
set MACHINE_ARCH=x86_64
|
76
|
-
goto install
|
77
|
-
|
78
|
-
:install
|
79
|
-
rem Install Chef using chef-client MSI installer
|
80
|
-
|
81
|
-
set "VERSION_STRING=<%= chef_version %>"
|
82
|
-
set "REMOTE_SOURCE_MSI_URL=https://www.opscode.com/chef/download?p=windows&pv=%MACHINE_OS%&m=%MACHINE_ARCH%&v=%VERSION_STRING%"
|
83
|
-
set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>"
|
84
|
-
set "FALLBACK_QUERY_STRING=&DownloadContext=PowerShell"
|
85
|
-
|
86
|
-
powershell -ExecutionPolicy Unrestricted -NoProfile -NonInteractive "& '<%= bootstrap_directory %>\wget.ps1' '%REMOTE_SOURCE_MSI_URL%%FALLBACK_QUERY_STRING%' '%LOCAL_DESTINATION_MSI_PATH%'"
|
87
|
-
|
88
|
-
<%= install_chef %>
|
89
|
-
|
90
|
-
endlocal
|
91
|
-
|
92
|
-
> <%= bootstrap_directory %>\validation.pem (
|
93
|
-
<%= validation_key %>
|
94
|
-
)
|
95
|
-
|
96
|
-
<% if encrypted_data_bag_secret -%>
|
97
|
-
> <%= bootstrap_directory %>\encrypted_data_bag_secret (
|
98
|
-
<%= encrypted_data_bag_secret %>
|
99
|
-
)
|
100
|
-
<% end -%>
|
101
|
-
|
102
|
-
> <%= bootstrap_directory %>\client.rb (
|
103
|
-
<%= chef_config %>
|
104
|
-
)
|
105
|
-
|
106
|
-
> <%= bootstrap_directory %>\first-boot.json (
|
107
|
-
<%= first_boot %>
|
108
|
-
)
|
109
|
-
|
110
|
-
SET "PATH=%PATH%;<%= env_path %>"
|
111
|
-
SETX PATH "%PATH;<%= env_path %>"
|
112
|
-
|
113
|
-
<%= chef_run %>
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'erubis'
|
2
|
-
|
3
|
-
module Ridley
|
4
|
-
module BootstrapContext
|
5
|
-
class Base
|
6
|
-
class << self
|
7
|
-
def validate_options(options = {})
|
8
|
-
if options[:server_url].nil?
|
9
|
-
raise Errors::ArgumentError, "A server_url is required for bootstrapping"
|
10
|
-
end
|
11
|
-
|
12
|
-
if options[:validator_path].nil?
|
13
|
-
raise Errors::ArgumentError, "A path to a validator is required for bootstrapping"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_reader :template_file
|
19
|
-
attr_reader :bootstrap_proxy
|
20
|
-
attr_reader :chef_version
|
21
|
-
attr_reader :validator_path
|
22
|
-
attr_reader :encrypted_data_bag_secret
|
23
|
-
attr_reader :server_url
|
24
|
-
attr_reader :validator_client
|
25
|
-
attr_reader :node_name
|
26
|
-
attr_reader :attributes
|
27
|
-
attr_reader :run_list
|
28
|
-
attr_reader :environment
|
29
|
-
attr_reader :hints
|
30
|
-
|
31
|
-
def initialize(options = {})
|
32
|
-
options = options.reverse_merge(
|
33
|
-
validator_client: "chef-validator",
|
34
|
-
attributes: Hash.new,
|
35
|
-
run_list: Array.new,
|
36
|
-
environment: "_default",
|
37
|
-
sudo: true,
|
38
|
-
hints: Hash.new,
|
39
|
-
chef_version: "latest"
|
40
|
-
)
|
41
|
-
options[:template] ||= default_template
|
42
|
-
self.class.validate_options(options)
|
43
|
-
|
44
|
-
@template_file = options[:template]
|
45
|
-
@bootstrap_proxy = options[:bootstrap_proxy]
|
46
|
-
@chef_version = options[:chef_version]
|
47
|
-
@sudo = options[:sudo]
|
48
|
-
@validator_path = options[:validator_path]
|
49
|
-
@encrypted_data_bag_secret = options[:encrypted_data_bag_secret]
|
50
|
-
@hints = options[:hints]
|
51
|
-
@server_url = options[:server_url]
|
52
|
-
@validator_client = options[:validator_client]
|
53
|
-
@node_name = options[:node_name]
|
54
|
-
@attributes = options[:attributes]
|
55
|
-
@run_list = options[:run_list]
|
56
|
-
@environment = options[:environment]
|
57
|
-
end
|
58
|
-
|
59
|
-
# @return [String]
|
60
|
-
def bootstrap_command
|
61
|
-
raise RuntimeError, "abstract function: must be implemented on includer"
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [String]
|
65
|
-
def default_template
|
66
|
-
raise RuntimeError, "abstract function: must be implemented on includer"
|
67
|
-
end
|
68
|
-
|
69
|
-
# @return [Pathname]
|
70
|
-
def templates_path
|
71
|
-
Ridley.root.join('bootstrappers')
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [String]
|
75
|
-
def first_boot
|
76
|
-
JSON.fast_generate(attributes.merge(run_list: run_list))
|
77
|
-
end
|
78
|
-
|
79
|
-
# The validation key to create a new client for the node
|
80
|
-
#
|
81
|
-
# @raise [Ridley::Errors::ValidatorNotFound]
|
82
|
-
#
|
83
|
-
# @return [String]
|
84
|
-
def validation_key
|
85
|
-
IO.read(File.expand_path(validator_path)).chomp
|
86
|
-
rescue Errno::ENOENT
|
87
|
-
raise Errors::ValidatorNotFound, "Error bootstrapping: Validator not found at '#{validator_path}'"
|
88
|
-
end
|
89
|
-
|
90
|
-
# @return [Erubis::Eruby]
|
91
|
-
def template
|
92
|
-
Erubis::Eruby.new(IO.read(template_file).chomp)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
Dir["#{File.dirname(__FILE__)}/bootstrap_context/*.rb"].sort.each do |path|
|
99
|
-
require_relative "bootstrap_context/#{File.basename(path, '.rb')}"
|
100
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Ridley
|
2
|
-
module BootstrapContext
|
3
|
-
# Represents a binding that will be evaluated as an ERB template. When bootstrapping
|
4
|
-
# nodes, an instance of this class represents the customizable and necessary configurations
|
5
|
-
# needed by the Host in order to install and connect to Chef. By default, this class will be used
|
6
|
-
# when SSH is the best way to connect to the node.
|
7
|
-
class Unix < BootstrapContext::Base
|
8
|
-
attr_reader :sudo
|
9
|
-
|
10
|
-
# @option options [Boolean] :sudo (true)
|
11
|
-
# bootstrap with sudo (default: true)
|
12
|
-
def initialize(options = {})
|
13
|
-
options = options.reverse_merge(sudo: true)
|
14
|
-
@sudo = options[:sudo]
|
15
|
-
super(options)
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [String]
|
19
|
-
def boot_command
|
20
|
-
template.evaluate(self)
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [String]
|
24
|
-
def chef_config
|
25
|
-
body = <<-CONFIG
|
26
|
-
log_level :info
|
27
|
-
log_location STDOUT
|
28
|
-
chef_server_url "#{server_url}"
|
29
|
-
validation_client_name "#{validator_client}"
|
30
|
-
CONFIG
|
31
|
-
|
32
|
-
if node_name.present?
|
33
|
-
body << %Q{node_name "#{node_name}"\n}
|
34
|
-
else
|
35
|
-
body << "# Using default node name (fqdn)\n"
|
36
|
-
end
|
37
|
-
|
38
|
-
if bootstrap_proxy.present?
|
39
|
-
body << %Q{http_proxy "#{bootstrap_proxy}"\n}
|
40
|
-
body << %Q{https_proxy "#{bootstrap_proxy}"\n}
|
41
|
-
end
|
42
|
-
|
43
|
-
if encrypted_data_bag_secret.present?
|
44
|
-
body << %Q{encrypted_data_bag_secret "#{bootstrap_directory}/encrypted_data_bag_secret"\n}
|
45
|
-
end
|
46
|
-
|
47
|
-
body
|
48
|
-
end
|
49
|
-
|
50
|
-
# @return [String]
|
51
|
-
def bootstrap_directory
|
52
|
-
"/etc/chef"
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [String]
|
56
|
-
def chef_run
|
57
|
-
"chef-client -j #{bootstrap_directory}/first-boot.json -E #{environment}"
|
58
|
-
end
|
59
|
-
|
60
|
-
# @return [String]
|
61
|
-
def default_template
|
62
|
-
templates_path.join('unix_omnibus.erb').to_s
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
module Ridley
|
2
|
-
module BootstrapContext
|
3
|
-
# Represents a binding that will be evaluated as an ERB template. When bootstrapping
|
4
|
-
# nodes, an instance of this class represents the customizable and necessary configurations
|
5
|
-
# needed by the Host in order to install and connect to Chef. By default, this class will be used
|
6
|
-
# when WinRM is the best way to connect to the node.
|
7
|
-
#
|
8
|
-
# Windows Specific code written by Seth Chisamore (<schisamo@opscode.com>) in knife-windows
|
9
|
-
# https://github.com/opscode/knife-windows/blob/3b8886ddcfb928ca0958cd05b22f8c3d78bee86e/lib/chef/knife/bootstrap/windows-chef-client-msi.erb
|
10
|
-
# https://github.com/opscode/knife-windows/blob/78d38bbed358ac20107fc2b5b427f4b5e52e5cb2/lib/chef/knife/core/windows_bootstrap_context.rb
|
11
|
-
class Windows < BootstrapContext::Base
|
12
|
-
# @return [String]
|
13
|
-
def boot_command
|
14
|
-
template.evaluate(self)
|
15
|
-
end
|
16
|
-
|
17
|
-
# @return [String]
|
18
|
-
def chef_config
|
19
|
-
body = <<-CONFIG
|
20
|
-
log_level :info
|
21
|
-
log_location STDOUT
|
22
|
-
chef_server_url "#{server_url}"
|
23
|
-
validation_client_name "#{validator_client}"
|
24
|
-
CONFIG
|
25
|
-
|
26
|
-
if node_name.present?
|
27
|
-
body << %Q{node_name "#{node_name}"\n}
|
28
|
-
else
|
29
|
-
body << "# Using default node name (fqdn)\n"
|
30
|
-
end
|
31
|
-
|
32
|
-
if bootstrap_proxy.present?
|
33
|
-
body << %Q{http_proxy "#{bootstrap_proxy}"\n}
|
34
|
-
body << %Q{https_proxy "#{bootstrap_proxy}"\n}
|
35
|
-
end
|
36
|
-
|
37
|
-
if encrypted_data_bag_secret.present?
|
38
|
-
body << %Q{encrypted_data_bag_secret '#{bootstrap_directory}\\encrypted_data_bag_secret'\n}
|
39
|
-
end
|
40
|
-
|
41
|
-
escape_and_echo(body)
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [String]
|
45
|
-
def bootstrap_directory
|
46
|
-
"C:\\chef"
|
47
|
-
end
|
48
|
-
|
49
|
-
# @return [String]
|
50
|
-
def validation_key
|
51
|
-
escape_and_echo(super)
|
52
|
-
end
|
53
|
-
|
54
|
-
# @return [String]
|
55
|
-
def chef_run
|
56
|
-
"chef-client -j #{bootstrap_directory}\\first-boot.json -E #{environment}"
|
57
|
-
end
|
58
|
-
|
59
|
-
# @return [String]
|
60
|
-
def default_template
|
61
|
-
templates_path.join('windows_omnibus.erb').to_s
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [String]
|
65
|
-
def encrypted_data_bag_secret
|
66
|
-
return unless @encrypted_data_bag_secret
|
67
|
-
|
68
|
-
escape_and_echo(@encrypted_data_bag_secret)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Implements a Powershell script that attempts a simple
|
72
|
-
# 'wget' to download the Chef msi
|
73
|
-
#
|
74
|
-
# @return [String]
|
75
|
-
def windows_wget_powershell
|
76
|
-
win_wget_ps = <<-WGET_PS
|
77
|
-
param(
|
78
|
-
[String] $remoteUrl,
|
79
|
-
[String] $localPath
|
80
|
-
)
|
81
|
-
|
82
|
-
$webClient = new-object System.Net.WebClient;
|
83
|
-
|
84
|
-
$webClient.DownloadFile($remoteUrl, $localPath);
|
85
|
-
WGET_PS
|
86
|
-
|
87
|
-
escape_and_echo(win_wget_ps)
|
88
|
-
end
|
89
|
-
|
90
|
-
# @return [String]
|
91
|
-
def install_chef
|
92
|
-
'msiexec /qb /i "%LOCAL_DESTINATION_MSI_PATH%"'
|
93
|
-
end
|
94
|
-
|
95
|
-
# @return [String]
|
96
|
-
def first_boot
|
97
|
-
escape_and_echo(super)
|
98
|
-
end
|
99
|
-
|
100
|
-
# @return [String]
|
101
|
-
def env_path
|
102
|
-
"C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin"
|
103
|
-
end
|
104
|
-
|
105
|
-
# @return [String]
|
106
|
-
def local_download_path
|
107
|
-
"%TEMP%\\chef-client-#{chef_version}.msi"
|
108
|
-
end
|
109
|
-
|
110
|
-
# escape WIN BATCH special chars
|
111
|
-
# and prefixes each line with an
|
112
|
-
# echo
|
113
|
-
def escape_and_echo(file_contents)
|
114
|
-
file_contents.gsub(/^(.*)$/, 'echo.\1').gsub(/([(<|>)^])/, '^\1')
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'erubis'
|
2
|
-
|
3
|
-
module Ridley
|
4
|
-
module CommandContext
|
5
|
-
# A base class to provide common functionality between OS specific command contexts. A
|
6
|
-
# command context takes an options hash and binds it against a template file. You can then
|
7
|
-
# retrieve the command to be run on a node by calling {CommandContext::Base#command}.
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
# my_context = MyCommandContext.new(message: "hello, world!")
|
11
|
-
# my_context.command #=> "echo 'hello, world!'"
|
12
|
-
class Base
|
13
|
-
class << self
|
14
|
-
# Build a command context and immediately run it's command
|
15
|
-
#
|
16
|
-
# @param [Hash] options
|
17
|
-
# an options hash to pass to the new CommandContext
|
18
|
-
def command(options = {})
|
19
|
-
new(options).command
|
20
|
-
end
|
21
|
-
|
22
|
-
# Set or get the path to the template file for the inheriting class
|
23
|
-
#
|
24
|
-
# @param [String] filename
|
25
|
-
# the filename (without extension) of the template file to use to bind
|
26
|
-
# the inheriting command context class to
|
27
|
-
#
|
28
|
-
# @return [Pathname]
|
29
|
-
def template_file(filename = nil)
|
30
|
-
return @template_file if filename.nil?
|
31
|
-
@template_file = Ridley.scripts.join("#{filename}.erb")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# @param [Hash] options
|
36
|
-
def initialize(options = {}); end
|
37
|
-
|
38
|
-
# @return [String]
|
39
|
-
def command
|
40
|
-
template.evaluate(self)
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
# @return [Erubis::Eruby]
|
46
|
-
def template
|
47
|
-
@template ||= Erubis::Eruby.new(IO.read(self.class.template_file).chomp)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# A command context for Unix based OSes
|
52
|
-
class Unix < Base
|
53
|
-
# @return [Boolean]
|
54
|
-
attr_reader :sudo
|
55
|
-
|
56
|
-
# @option options [Boolean] :sudo (true)
|
57
|
-
# bootstrap with sudo (default: true)
|
58
|
-
def initialize(options = {})
|
59
|
-
options = options.reverse_merge(sudo: true)
|
60
|
-
@sudo = options[:sudo]
|
61
|
-
end
|
62
|
-
|
63
|
-
# @return [String]
|
64
|
-
def command
|
65
|
-
sudo ? "sudo #{super}" : super
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# A command context for Windows based OSes
|
70
|
-
class Windows < Base; end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
Dir["#{File.dirname(__FILE__)}/command_context/*.rb"].sort.each do |path|
|
75
|
-
require_relative "command_context/#{File.basename(path, '.rb')}"
|
76
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Ridley
|
2
|
-
module CommandContext
|
3
|
-
# Context class for generating an uninstall command for Unix based OSes
|
4
|
-
class UnixUninstall < CommandContext::Unix
|
5
|
-
template_file 'unix_uninstall_omnibus'
|
6
|
-
|
7
|
-
# @return [Boolean]
|
8
|
-
attr_reader :skip_chef
|
9
|
-
|
10
|
-
# @option options [Boolena] :skip_chef (false)
|
11
|
-
# skip removal of the Chef package and the contents of the installation
|
12
|
-
# directory. Setting this to true will only remove any data and configurations
|
13
|
-
# generated by running Chef client.
|
14
|
-
def initialize(options = {})
|
15
|
-
super(options)
|
16
|
-
options = options.reverse_merge(skip_chef: false)
|
17
|
-
@skip_chef = options[:skip_chef]
|
18
|
-
end
|
19
|
-
|
20
|
-
# The path to the Chef configuration directory on the target host
|
21
|
-
#
|
22
|
-
# @return [String]
|
23
|
-
def config_directory
|
24
|
-
"/etc/chef"
|
25
|
-
end
|
26
|
-
|
27
|
-
# The path to the Chef data directory on the target host
|
28
|
-
#
|
29
|
-
# @return [String]
|
30
|
-
def data_directory
|
31
|
-
"/var/chef"
|
32
|
-
end
|
33
|
-
|
34
|
-
# The path to the Omnibus Chef installation on the target host
|
35
|
-
#
|
36
|
-
# @return [String]
|
37
|
-
def install_directory
|
38
|
-
"/opt/chef"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Ridley
|
2
|
-
module CommandContext
|
3
|
-
# Context class for generating an uninstall command for Unix based OSes
|
4
|
-
class WindowsUninstall < CommandContext::Windows
|
5
|
-
template_file 'windows_uninstall_omnibus'
|
6
|
-
|
7
|
-
# @return [Boolean]
|
8
|
-
attr_reader :skip_chef
|
9
|
-
|
10
|
-
# @option options [Boolena] :skip_chef (false)
|
11
|
-
# skip removal of the Chef package and the contents of the installation
|
12
|
-
# directory. Setting this to true will only remove any data and configurations
|
13
|
-
# generated by running Chef client.
|
14
|
-
def initialize(options = {})
|
15
|
-
super(options)
|
16
|
-
options = options.reverse_merge(skip_chef: false)
|
17
|
-
@skip_chef = options[:skip_chef]
|
18
|
-
end
|
19
|
-
|
20
|
-
# The path to the Chef configuration directory on the target host
|
21
|
-
#
|
22
|
-
# @return [String]
|
23
|
-
def config_directory
|
24
|
-
"C:\\chef"
|
25
|
-
end
|
26
|
-
|
27
|
-
# The path to the Omnibus Chef installation on the target host
|
28
|
-
#
|
29
|
-
# @return [String]
|
30
|
-
def install_directory
|
31
|
-
"C:\\opscode\\chef"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
bash -c '
|
2
|
-
if [ -f "/etc/lsb-release" ]; then
|
3
|
-
platform=$(grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr "[A-Z]" "[a-z]")
|
4
|
-
elif [ -f "/etc/debian_version" ]; then
|
5
|
-
platform="debian"
|
6
|
-
elif [ -f "/etc/redhat-release" ]; then
|
7
|
-
platform="el"
|
8
|
-
elif [ -f "/etc/system-release" ]; then
|
9
|
-
platform=$(sed "s/^\(.\+\) release.\+/\1/" /etc/system-release | tr "[A-Z]" "[a-z]")
|
10
|
-
if [ "$platform" = "amazon linux ami" ]; then
|
11
|
-
platform="el"
|
12
|
-
fi
|
13
|
-
elif [ -f "/etc/SuSE-release" ]; then
|
14
|
-
platform="el"
|
15
|
-
fi
|
16
|
-
|
17
|
-
<% unless skip_chef -%>
|
18
|
-
echo "Un-Installing installed Chef package"
|
19
|
-
case "$platform" in
|
20
|
-
"el") yum remove chef -y ;;
|
21
|
-
"debian") apt-get purge chef -y ;;
|
22
|
-
esac
|
23
|
-
<% end -%>
|
24
|
-
|
25
|
-
rm -Rdf <%= config_directory %>
|
26
|
-
rm -Rdf <%= data_directory %>
|
27
|
-
|
28
|
-
<% unless skip_chef -%>
|
29
|
-
rm -Rdf <%= install_directory %>
|
30
|
-
<% end -%>
|
31
|
-
'
|
@@ -1,10 +0,0 @@
|
|
1
|
-
$productName = "Chef"
|
2
|
-
$installDirectory = "<%= install_directory %>"
|
3
|
-
$configDirectory = "<%= config_directory %>"
|
4
|
-
|
5
|
-
<% unless skip_chef -%>
|
6
|
-
$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match $productName }
|
7
|
-
If ($app) { $app.Uninstall() }
|
8
|
-
If (Test-Path $installDirectory) { Remove-Item -Recurse -Force $installDirectory }
|
9
|
-
<% end -%>
|
10
|
-
If (Test-Path $configDirectory) { Remove-Item -Recurse -Force $configDirectory }
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Ridley::BootstrapContext::Unix do
|
4
|
-
let(:options) do
|
5
|
-
{
|
6
|
-
server_url: "https://api.opscode.com/organizations/vialstudios",
|
7
|
-
validator_client: "chef-validator",
|
8
|
-
validator_path: fixtures_path.join("reset.pem").to_s,
|
9
|
-
encrypted_data_bag_secret: File.read(fixtures_path.join("reset.pem"))
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "ClassMethods" do
|
14
|
-
subject { described_class }
|
15
|
-
|
16
|
-
describe "::new" do
|
17
|
-
context "when no sudo option is passed through" do
|
18
|
-
it "sets a default value of 'true' to 'sudo'" do
|
19
|
-
options.delete(:sudo)
|
20
|
-
obj = subject.new(options)
|
21
|
-
|
22
|
-
obj.send(:sudo).should be_true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when the sudo option is passed through as false" do
|
27
|
-
it "sets the value of sudo to 'false' if provided" do
|
28
|
-
options.merge!(sudo: false)
|
29
|
-
obj = subject.new(options)
|
30
|
-
|
31
|
-
obj.send(:sudo).should be_false
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
subject { described_class.new(options) }
|
38
|
-
|
39
|
-
describe "MixinMethods" do
|
40
|
-
|
41
|
-
describe "#templates_path" do
|
42
|
-
it "returns a pathname" do
|
43
|
-
subject.templates_path.should be_a(Pathname)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#first_boot" do
|
48
|
-
it "returns a string" do
|
49
|
-
subject.first_boot.should be_a(String)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#encrypted_data_bag_secret" do
|
54
|
-
it "returns a string" do
|
55
|
-
subject.encrypted_data_bag_secret.should be_a(String)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#validation_key" do
|
60
|
-
it "returns a string" do
|
61
|
-
subject.validation_key.should be_a(String)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "template" do
|
66
|
-
it "returns a string" do
|
67
|
-
subject.template.should be_a(Erubis::Eruby)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#boot_command" do
|
73
|
-
it "returns a string" do
|
74
|
-
subject.boot_command.should be_a(String)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#chef_run" do
|
79
|
-
it "returns a string" do
|
80
|
-
subject.chef_run.should be_a(String)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "#chef_config" do
|
85
|
-
it "returns a string" do
|
86
|
-
subject.chef_config.should be_a(String)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "#default_template" do
|
91
|
-
it "returns a string" do
|
92
|
-
subject.default_template.should be_a(String)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "#bootstrap_directory" do
|
97
|
-
it "returns a string" do
|
98
|
-
subject.bootstrap_directory.should be_a(String)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Ridley::BootstrapContext::Windows do
|
4
|
-
let(:options) do
|
5
|
-
{
|
6
|
-
server_url: "https://api.opscode.com/organizations/vialstudios",
|
7
|
-
validator_client: "chef-validator",
|
8
|
-
validator_path: fixtures_path.join("reset.pem").to_s,
|
9
|
-
encrypted_data_bag_secret: File.read(fixtures_path.join("reset.pem")),
|
10
|
-
chef_version: "11.4.0"
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "ClassMethods" do
|
15
|
-
subject { described_class }
|
16
|
-
|
17
|
-
describe "::new" do
|
18
|
-
context "when a chef_version is passed through" do
|
19
|
-
it "sets the chef_version attribute to the same value" do
|
20
|
-
subject.new(options).chef_version.should eq("11.4.0")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when the chef_version is not passed through" do
|
25
|
-
it "sets the chef_version to 'latest'" do
|
26
|
-
options.delete(:chef_version)
|
27
|
-
subject.new(options).chef_version.should eq("latest")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
subject { described_class.new(options) }
|
34
|
-
|
35
|
-
describe "MixinMethods" do
|
36
|
-
describe "#templates_path" do
|
37
|
-
it "returns a pathname" do
|
38
|
-
subject.templates_path.should be_a(Pathname)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#first_boot" do
|
43
|
-
it "returns a string" do
|
44
|
-
subject.first_boot.should be_a(String)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#encrypted_data_bag_secret" do
|
49
|
-
it "returns a string" do
|
50
|
-
subject.encrypted_data_bag_secret.should be_a(String)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#validation_key" do
|
55
|
-
it "returns a string" do
|
56
|
-
subject.validation_key.should be_a(String)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "template" do
|
61
|
-
it "returns a string" do
|
62
|
-
subject.template.should be_a(Erubis::Eruby)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "#boot_command" do
|
68
|
-
it "returns a string" do
|
69
|
-
subject.boot_command.should be_a(String)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#chef_run" do
|
74
|
-
it "returns a string" do
|
75
|
-
subject.chef_run.should be_a(String)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#chef_config" do
|
80
|
-
it "returns a string" do
|
81
|
-
subject.chef_config.should be_a(String)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "#env_path" do
|
86
|
-
it "returns a string" do
|
87
|
-
expect(subject.env_path).to be_a(String)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "#default_template" do
|
92
|
-
it "returns a string" do
|
93
|
-
subject.default_template.should be_a(String)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#bootstrap_directory" do
|
98
|
-
it "returns a string" do
|
99
|
-
subject.bootstrap_directory.should be_a(String)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe "#escape_and_echo" do
|
104
|
-
let(:output) { "foo()" }
|
105
|
-
|
106
|
-
it "adds 'echo.' to the beginning of each line and escapes special batch characters" do
|
107
|
-
subject.escape_and_echo(output).should eq("echo.foo^(^)")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#windows_wget_powershell" do
|
112
|
-
it "returns a string" do
|
113
|
-
subject.windows_wget_powershell.should be_a(String)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Ridley::BootstrapContext::Base do
|
4
|
-
let(:host) { "reset.riotgames.com" }
|
5
|
-
let(:options) do
|
6
|
-
{
|
7
|
-
server_url: "https://api.opscode.com/organizations/vialstudios",
|
8
|
-
validator_client: "chef-validator",
|
9
|
-
validator_path: fixtures_path.join("reset.pem").to_s,
|
10
|
-
encrypted_data_bag_secret: File.read(fixtures_path.join("reset.pem")),
|
11
|
-
chef_version: "11.4.0"
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "ClassMethods" do
|
16
|
-
subject { described_class }
|
17
|
-
|
18
|
-
describe ":included" do
|
19
|
-
context "when a class includes Ridley::BootstrapBinding" do
|
20
|
-
it "should have a validate_options class method`" do
|
21
|
-
subject.methods.should include(:validate_options)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ":validate_options" do
|
27
|
-
context "when server_url is not specified" do
|
28
|
-
let(:options) { Hash.new }
|
29
|
-
|
30
|
-
it "raises an ArgumentError" do
|
31
|
-
expect {
|
32
|
-
subject.validate_options(options)
|
33
|
-
}.to raise_error(Ridley::Errors::ArgumentError)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "when validator_path is not specified" do
|
39
|
-
let(:options) do
|
40
|
-
{
|
41
|
-
server_url: "https://api.opscode.com/organizations/vialstudios"
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
it "raises an ArgumentError" do
|
46
|
-
expect {
|
47
|
-
subject.validate_options(options)
|
48
|
-
}.to raise_error(Ridley::Errors::ArgumentError)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|