chef-apply 0.4.16 → 0.6.7
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.
- checksums.yaml +4 -4
- data/Gemfile +2 -8
- data/Rakefile +0 -7
- data/bin/chef-run +1 -1
- data/chef-apply.gemspec +9 -14
- data/i18n/en.yml +19 -25
- data/i18n/errors/en.yml +11 -11
- data/lib/chef_apply/action/converge_target.rb +3 -3
- data/lib/chef_apply/action/generate_local_policy.rb +1 -0
- data/lib/chef_apply/action/generate_temp_cookbook/recipe_lookup.rb +1 -1
- data/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb +3 -3
- data/lib/chef_apply/action/install_chef.rb +7 -1
- data/lib/chef_apply/action/install_chef/minimum_chef_version.rb +4 -0
- data/lib/chef_apply/cli.rb +5 -5
- data/lib/chef_apply/cli/validation.rb +2 -0
- data/lib/chef_apply/config.rb +3 -3
- data/lib/chef_apply/errors/standard_error_resolver.rb +2 -2
- data/lib/chef_apply/file_fetcher.rb +2 -2
- data/lib/chef_apply/startup.rb +8 -6
- data/lib/chef_apply/target_host.rb +8 -1
- data/lib/chef_apply/target_host/macos.rb +69 -0
- data/lib/chef_apply/ui/error_printer.rb +1 -1
- data/lib/chef_apply/ui/plain_text_header.rb +0 -1
- data/lib/chef_apply/version.rb +1 -1
- metadata +14 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc3b546ebf62d419f93571e38929862bbe15cc8d8bc7798ae9c2d241cba866f7
|
|
4
|
+
data.tar.gz: ea642c60686a1f36e3383b73dd58205d569749ee01f2457cd9d737236818bc78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a7e44af40ce24424eeee41da3e7694a1ad5d32a52ba0ebfa42db2ec2c716d2387bfd281ed3faef70e37560df97712e61120f5e3bd02dd67d500996dca7d0e2b
|
|
7
|
+
data.tar.gz: 52c394d2c66bce073082acde1a7d56f68c6d587725859bab6a58996ea968f0cfd5b9b9d9c095a4f6851318094f9ba894435678acae1436018da568a8ce4eb071
|
data/Gemfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c)
|
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -19,18 +19,12 @@ source "https://rubygems.org"
|
|
|
19
19
|
gemspec
|
|
20
20
|
|
|
21
21
|
group :development do
|
|
22
|
-
gem "chefstyle"
|
|
22
|
+
gem "chefstyle", "1.7.5"
|
|
23
23
|
gem "rake", ">= 10.1.0"
|
|
24
24
|
gem "rspec", "~> 3.0"
|
|
25
25
|
gem "simplecov"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
group :docs do
|
|
29
|
-
gem "yard"
|
|
30
|
-
gem "redcarpet"
|
|
31
|
-
gem "github-markup"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
28
|
group :debug do
|
|
35
29
|
gem "pry"
|
|
36
30
|
gem "pry-byebug"
|
data/Rakefile
CHANGED
|
@@ -24,13 +24,6 @@ rescue LoadError
|
|
|
24
24
|
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
begin
|
|
28
|
-
require "yard"
|
|
29
|
-
YARD::Rake::YardocTask.new(:docs)
|
|
30
|
-
rescue LoadError
|
|
31
|
-
puts "yard is not available. bundle install first to make sure all dependencies are installed."
|
|
32
|
-
end
|
|
33
|
-
|
|
34
27
|
task :console do
|
|
35
28
|
require "irb"
|
|
36
29
|
require "irb/completion"
|
data/bin/chef-run
CHANGED
data/chef-apply.gemspec
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
lib = File.expand_path("
|
|
18
|
+
lib = File.expand_path("lib", __dir__)
|
|
19
19
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
20
20
|
require "chef_apply/version"
|
|
21
21
|
|
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.description = "Ad-hoc management of individual nodes and devices."
|
|
30
30
|
spec.homepage = "https://github.com/chef/chef-apply"
|
|
31
31
|
spec.license = "Apache-2.0"
|
|
32
|
-
spec.required_ruby_version = ">= 2.
|
|
32
|
+
spec.required_ruby_version = ">= 2.6"
|
|
33
33
|
|
|
34
34
|
spec.files = %w{Rakefile LICENSE warning.txt} +
|
|
35
35
|
Dir.glob("Gemfile*") + # Includes Gemfile and locks
|
|
@@ -40,24 +40,19 @@ Gem::Specification.new do |spec|
|
|
|
40
40
|
spec.require_paths = ["lib"]
|
|
41
41
|
|
|
42
42
|
spec.add_dependency "mixlib-cli" # Provides argument handling DSL for CLI applications
|
|
43
|
-
spec.add_dependency "mixlib-config", ">= 3.0.5"
|
|
44
|
-
# simplifies managing a configuration file
|
|
43
|
+
spec.add_dependency "mixlib-config", ">= 3.0.5" # shared chef configuration library that simplifies managing a configuration file
|
|
45
44
|
spec.add_dependency "mixlib-log" # Basis for our traditional logger
|
|
46
45
|
spec.add_dependency "mixlib-install" # URL resolver + install tool for chef products
|
|
47
|
-
spec.add_dependency "r18n-desktop" # easy path to message text management via
|
|
48
|
-
|
|
49
|
-
spec.add_dependency "toml-rb" # This isn't ideal because mixlib-config uses 'tomlrb'
|
|
50
|
-
# but that library does not support a dumper
|
|
46
|
+
spec.add_dependency "r18n-desktop" # easy path to message text management via localization gem...
|
|
47
|
+
spec.add_dependency "toml-rb" # This isn't ideal because mixlib-config uses 'tomlrb' but that library does not support a dumper
|
|
51
48
|
spec.add_dependency "train-core", "~> 3.0" # remote connection management over ssh, winrm
|
|
52
49
|
spec.add_dependency "train-winrm" # winrm transports were pulled out into this plugin
|
|
53
50
|
spec.add_dependency "pastel" # A color library
|
|
54
51
|
spec.add_dependency "tty-spinner" # Pretty output for status updates in the CLI
|
|
55
|
-
spec.add_dependency "chef", ">=
|
|
56
|
-
spec.add_dependency "chef-cli", ">=
|
|
52
|
+
spec.add_dependency "chef", ">= 16.0" # Needed to load cookbooks
|
|
53
|
+
spec.add_dependency "chef-cli", ">= 2.0.10 " # Policyfile
|
|
57
54
|
spec.add_dependency "chef-telemetry", ">= 1.0.2"
|
|
58
|
-
spec.add_dependency "license-acceptance", "
|
|
55
|
+
spec.add_dependency "license-acceptance", ">= 1.0.11", "< 3"
|
|
59
56
|
|
|
60
|
-
spec.
|
|
61
|
-
|
|
62
|
-
spec.post_install_message = File.read(File.expand_path("../warning.txt", __FILE__))
|
|
57
|
+
spec.post_install_message = File.read(File.expand_path("warning.txt", __dir__))
|
|
63
58
|
end
|
data/i18n/en.yml
CHANGED
|
@@ -17,21 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
cli:
|
|
19
19
|
telemetry_enabled: |
|
|
20
|
-
Telemetry
|
|
21
|
-
|
|
22
|
-
determine how we can impove your chef-run experience.
|
|
20
|
+
Telemetry is enabled by default in chef-run. The anonymous data we gather
|
|
21
|
+
is used to determine how we can impove your chef-run experience.
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[telemetry]
|
|
28
|
-
enabled=false
|
|
29
|
-
|
|
30
|
-
For more information about what we data gather and additional opt-out
|
|
31
|
-
options, visit https://chef.sh/docs/chef-workstation/privacy/
|
|
23
|
+
For more information about what we data gather and opt-out options,
|
|
24
|
+
visit https://docs.chef.io/workstation/privacy/
|
|
32
25
|
|
|
33
26
|
description: |
|
|
34
|
-
Chef Run is a tool to execute ad-hoc tasks using Chef.
|
|
27
|
+
Chef Run is a tool to execute ad-hoc tasks using Chef Infra.
|
|
35
28
|
creating_config: "Creating config file in %1."
|
|
36
29
|
default_config_location: "Location of config file. Default: %1"
|
|
37
30
|
identity_file: "SSH identity file to use when connecting. Keys loaded into ssh-agent will also be used."
|
|
@@ -44,9 +37,9 @@ cli:
|
|
|
44
37
|
Current default: %1
|
|
45
38
|
cookbook_repo_paths: "Comma separated list of cookbook repository paths."
|
|
46
39
|
install_description: |
|
|
47
|
-
Install Chef
|
|
40
|
+
Install Chef Infra Client on the target host(s) if it is not installed.
|
|
48
41
|
This defaults to enabled - the installation will be performed
|
|
49
|
-
if there is no Chef
|
|
42
|
+
if there is no Chef Infra Client on the target(s).
|
|
50
43
|
user_description: |
|
|
51
44
|
Username to use for authentication to the target(s). The same
|
|
52
45
|
username will be used for all targets.
|
|
@@ -102,7 +95,7 @@ cli:
|
|
|
102
95
|
in the form:
|
|
103
96
|
|
|
104
97
|
ssh://[USERNAME]@example.com[:PORT]
|
|
105
|
-
<RESOURCE> A Chef resource, such as 'user' or 'package'
|
|
98
|
+
<RESOURCE> A Chef Infra resource, such as 'user' or 'package'
|
|
106
99
|
<RESOURCE_NAME> The name, usually used to specify what 'thing' to set up with
|
|
107
100
|
the resource. For example, given resource 'user', 'name' would be
|
|
108
101
|
the name of the user you wanted to create.
|
|
@@ -113,6 +106,7 @@ cli:
|
|
|
113
106
|
cookbook is found we run the default recipe.
|
|
114
107
|
3. This behaves similarly to 'cookbook name' above, but it also allows
|
|
115
108
|
you to specify which recipe to use from the cookbook.
|
|
109
|
+
Usage: cookbookname::recipename
|
|
116
110
|
error:
|
|
117
111
|
bad_config_file: |
|
|
118
112
|
|
|
@@ -178,16 +172,16 @@ status:
|
|
|
178
172
|
exporting: Generating local policyfile... exporting...
|
|
179
173
|
success: Generating local policyfile... exporting... done!
|
|
180
174
|
install_chef:
|
|
181
|
-
checking_for_client: Checking for Chef
|
|
182
|
-
verifying: Verifying Chef
|
|
183
|
-
downloading: Downloading Chef
|
|
184
|
-
uploading: Uploading Chef
|
|
185
|
-
installing: Installing Chef
|
|
186
|
-
upgrading: Upgrading Chef
|
|
187
|
-
already_present: Chef
|
|
188
|
-
install_success: Successfully installed Chef
|
|
189
|
-
upgrade_success: Successfully upgraded Chef
|
|
190
|
-
failure: "An error occurred while installing Chef
|
|
175
|
+
checking_for_client: Checking for Chef Infra Client.
|
|
176
|
+
verifying: Verifying Chef Infra Client installation.
|
|
177
|
+
downloading: Downloading Chef Infra Client installer into local cache.
|
|
178
|
+
uploading: Uploading Chef Infra Client installer to target.
|
|
179
|
+
installing: Installing Chef Infra Client version %1.
|
|
180
|
+
upgrading: Upgrading Chef Infra Client from version %1 to %2.
|
|
181
|
+
already_present: Chef Infra Client version %1 already installed on target.
|
|
182
|
+
install_success: Successfully installed Chef Infra Client version %1
|
|
183
|
+
upgrade_success: Successfully upgraded Chef Infra Client from version %1 to %2.
|
|
184
|
+
failure: "An error occurred while installing Chef Infra Client: %1"
|
|
191
185
|
converge:
|
|
192
186
|
header: !!pl
|
|
193
187
|
1: Applying %2 from %3 to target.
|
data/i18n/errors/en.yml
CHANGED
|
@@ -71,8 +71,8 @@ errors:
|
|
|
71
71
|
text: |
|
|
72
72
|
The target does not have chef-client installed.
|
|
73
73
|
|
|
74
|
-
This command is powered by the Chef
|
|
75
|
-
on this node, the Chef
|
|
74
|
+
This command is powered by the Chef Infra Client. In order to make use of it
|
|
75
|
+
on this node, the Chef Infra Client must be installed first.
|
|
76
76
|
|
|
77
77
|
Re-running this command without the '--no-install' flag will
|
|
78
78
|
automatically perform the installation.
|
|
@@ -91,12 +91,12 @@ errors:
|
|
|
91
91
|
|
|
92
92
|
CHEFINS003:
|
|
93
93
|
text: |
|
|
94
|
-
The target has an older version of Chef
|
|
94
|
+
The target has an older version of Chef Infra Client installed.
|
|
95
95
|
|
|
96
96
|
The target has version %1 installed, but this command
|
|
97
97
|
requires a minimum version of %2.
|
|
98
98
|
|
|
99
|
-
Please upgrade the Chef
|
|
99
|
+
Please upgrade the Chef Infra Client on this node to version %2 or later.
|
|
100
100
|
|
|
101
101
|
# Local errors trying to create policy to send to target
|
|
102
102
|
CHEFPOLICY001:
|
|
@@ -146,7 +146,7 @@ errors:
|
|
|
146
146
|
For more information, please consult the documentation
|
|
147
147
|
for this resource:
|
|
148
148
|
|
|
149
|
-
https://docs.chef.io/
|
|
149
|
+
https://docs.chef.io/resources/
|
|
150
150
|
|
|
151
151
|
CHEFCCR004:
|
|
152
152
|
text: |
|
|
@@ -157,7 +157,7 @@ errors:
|
|
|
157
157
|
Please consult the documentation for properties
|
|
158
158
|
supported by your resource and their valid values:
|
|
159
159
|
|
|
160
|
-
https://docs.chef.io/
|
|
160
|
+
https://docs.chef.io/resources/
|
|
161
161
|
|
|
162
162
|
CHEFCCR005:
|
|
163
163
|
text: |
|
|
@@ -165,7 +165,7 @@ errors:
|
|
|
165
165
|
|
|
166
166
|
Please consult the documentation for a list of valid resources:
|
|
167
167
|
|
|
168
|
-
https://docs.chef.io/
|
|
168
|
+
https://docs.chef.io/resources/
|
|
169
169
|
|
|
170
170
|
CHEFCCR006:
|
|
171
171
|
text: |
|
|
@@ -174,7 +174,7 @@ errors:
|
|
|
174
174
|
Please consult the documentation for %2 for a list of
|
|
175
175
|
valid properties:
|
|
176
176
|
|
|
177
|
-
https://docs.chef.io/
|
|
177
|
+
https://docs.chef.io/resources/
|
|
178
178
|
|
|
179
179
|
CHEFCCR099:
|
|
180
180
|
text: |
|
|
@@ -240,13 +240,13 @@ errors:
|
|
|
240
240
|
|
|
241
241
|
Try...
|
|
242
242
|
- Provide a password with "--password PASSWORD"
|
|
243
|
-
- Provide a key with "
|
|
243
|
+
- Provide a key with "--identity-file PATH/TO/FILE"
|
|
244
244
|
- Enable ssh-agent and add keys
|
|
245
245
|
- Add a host entry to your ssh configuration
|
|
246
246
|
|
|
247
247
|
Additional instructions can be found in the troubleshooting documentation:
|
|
248
248
|
|
|
249
|
-
https://
|
|
249
|
+
https://docs.chef.io/workstation/troubleshooting/#cheftrn007
|
|
250
250
|
|
|
251
251
|
CHEFTRN999:
|
|
252
252
|
text: |
|
|
@@ -319,7 +319,7 @@ errors:
|
|
|
319
319
|
CHEFVAL009:
|
|
320
320
|
display: { decorations: false }
|
|
321
321
|
text: |
|
|
322
|
-
File extension '%1' is unsupported. Currently recipes must be specified with a `.rb` extension.
|
|
322
|
+
File extension '%1' is unsupported. Currently recipes must be specified with a `.rb` or `.yml` extension.
|
|
323
323
|
|
|
324
324
|
CHEFVAL010:
|
|
325
325
|
display: { decorations: false }
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
require_relative "base"
|
|
19
|
-
require "pathname"
|
|
20
|
-
require "tempfile"
|
|
19
|
+
require "pathname" unless defined?(Pathname)
|
|
20
|
+
require "tempfile" unless defined?(Tempfile)
|
|
21
21
|
# FLAG: require "chef/util/path_helper"
|
|
22
22
|
require "chef/util/path_helper"
|
|
23
23
|
|
|
@@ -198,7 +198,7 @@ module ChefApply::Action
|
|
|
198
198
|
else
|
|
199
199
|
# cd is shell a builtin, so we'll invoke bash. This also means all commands are executed
|
|
200
200
|
# with sudo (as long as we are hardcoding our sudo use)
|
|
201
|
-
"bash -c 'cd #{working_dir}; chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'"
|
|
201
|
+
"bash -c 'cd #{working_dir}; /opt/chef/bin/chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'"
|
|
202
202
|
end
|
|
203
203
|
end
|
|
204
204
|
|
|
@@ -81,7 +81,7 @@ module ChefApply
|
|
|
81
81
|
# Find the specified recipe or default recipe if none is specified.
|
|
82
82
|
# Raise an error if recipe cannot be found.
|
|
83
83
|
def find_recipe(cookbook, recipe_name = nil)
|
|
84
|
-
recipes = cookbook.recipe_filenames_by_name
|
|
84
|
+
recipes = cookbook.recipe_filenames_by_name.merge(cookbook.recipe_yml_filenames_by_name)
|
|
85
85
|
if recipe_name.nil?
|
|
86
86
|
default_recipe = recipes["default"]
|
|
87
87
|
raise NoDefaultRecipe.new(cookbook.root_dir, cookbook.name) if default_recipe.nil?
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require "tmpdir"
|
|
19
|
-
require "fileutils"
|
|
18
|
+
require "tmpdir" unless defined?(Dir.mktmpdir)
|
|
19
|
+
require "fileutils" unless defined?(FileUtils)
|
|
20
20
|
require_relative "../../log"
|
|
21
21
|
require_relative "../../error"
|
|
22
22
|
require_relative "../generate_temp_cookbook"
|
|
@@ -34,7 +34,7 @@ module ChefApply
|
|
|
34
34
|
|
|
35
35
|
def from_existing_recipe(existing_recipe_path)
|
|
36
36
|
ext_name = File.extname(existing_recipe_path)
|
|
37
|
-
raise UnsupportedExtension.new(ext_name) unless ext_name == ".rb"
|
|
37
|
+
raise UnsupportedExtension.new(ext_name) unless ext_name == ".rb" || ext_name == ".yml"
|
|
38
38
|
|
|
39
39
|
cb = cookbook_for_recipe(existing_recipe_path)
|
|
40
40
|
if cb
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
require_relative "base"
|
|
19
19
|
require_relative "install_chef/minimum_chef_version"
|
|
20
|
-
require "fileutils"
|
|
20
|
+
require "fileutils" unless defined?(FileUtils)
|
|
21
21
|
|
|
22
22
|
module ChefApply
|
|
23
23
|
module Action
|
|
@@ -86,6 +86,12 @@ module ChefApply
|
|
|
86
86
|
platform_version_compatibility_mode: true,
|
|
87
87
|
}
|
|
88
88
|
case platform.name
|
|
89
|
+
when /mac_os_x/
|
|
90
|
+
if platform.release.to_i >= 17
|
|
91
|
+
opts[:platform_version] = "10.13"
|
|
92
|
+
else
|
|
93
|
+
raise NotImplementedError
|
|
94
|
+
end
|
|
89
95
|
when /windows/
|
|
90
96
|
opts[:platform] = "windows"
|
|
91
97
|
when "redhat", "centos"
|
data/lib/chef_apply/cli.rb
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
|
-
require "mixlib/cli"
|
|
18
|
+
require "mixlib/cli" unless defined?(Mixlib::CLI)
|
|
19
19
|
|
|
20
20
|
require_relative "config"
|
|
21
21
|
require "chef-config/config"
|
|
@@ -63,14 +63,14 @@ module ChefApply
|
|
|
63
63
|
super()
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
def run
|
|
66
|
+
def run(enforce_license: false)
|
|
67
67
|
# Perform a timing and capture of the run. Individual methods and actions may perform
|
|
68
68
|
# nested Chef::Telemeter.timed_*_capture or Chef::Telemeter.capture calls in their operation, and
|
|
69
69
|
# they will be captured in the same telemetry session.
|
|
70
70
|
|
|
71
71
|
Chef::Telemeter.timed_run_capture([:redacted]) do
|
|
72
72
|
begin
|
|
73
|
-
perform_run
|
|
73
|
+
perform_run(enforce_license: enforce_license)
|
|
74
74
|
rescue Exception => e
|
|
75
75
|
@rc = handle_run_error(e)
|
|
76
76
|
end
|
|
@@ -100,14 +100,14 @@ module ChefApply
|
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
def perform_run
|
|
103
|
+
def perform_run(enforce_license: false)
|
|
104
104
|
parse_options(@argv)
|
|
105
105
|
if @argv.empty? || parsed_options[:help]
|
|
106
106
|
show_help
|
|
107
107
|
elsif parsed_options[:version]
|
|
108
108
|
show_version
|
|
109
109
|
else
|
|
110
|
-
check_license_acceptance
|
|
110
|
+
check_license_acceptance if enforce_license
|
|
111
111
|
validate_params(cli_arguments)
|
|
112
112
|
target_hosts = resolve_targets(cli_arguments.shift, parsed_options)
|
|
113
113
|
render_cookbook_setup(cli_arguments)
|
data/lib/chef_apply/config.rb
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
require_relative "log"
|
|
19
|
-
require "mixlib/config"
|
|
20
|
-
require "fileutils"
|
|
21
|
-
require "pathname"
|
|
19
|
+
require "mixlib/config" unless defined?(Mixlib::Config)
|
|
20
|
+
require "fileutils" unless defined?(FileUtils)
|
|
21
|
+
require "pathname" unless defined?(Pathname)
|
|
22
22
|
require "chef-config/config"
|
|
23
23
|
require "chef-config/workstation_config_loader"
|
|
24
24
|
|
data/lib/chef_apply/startup.rb
CHANGED
|
@@ -33,7 +33,7 @@ module ChefApply
|
|
|
33
33
|
init_terminal
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def run
|
|
36
|
+
def run(enforce_license: false)
|
|
37
37
|
# This component is not supported in ChefDK; an exception will be raised
|
|
38
38
|
# if running in that context.
|
|
39
39
|
verify_not_in_chefdk
|
|
@@ -62,7 +62,7 @@ module ChefApply
|
|
|
62
62
|
start_telemeter_upload
|
|
63
63
|
|
|
64
64
|
# Launch the actual Chef Apply behavior
|
|
65
|
-
start_chef_apply
|
|
65
|
+
start_chef_apply(enforce_license: enforce_license)
|
|
66
66
|
|
|
67
67
|
# NOTE: Because these exceptions occur outside of the
|
|
68
68
|
# CLI handling, they won't be tracked in telemtry.
|
|
@@ -119,7 +119,7 @@ module ChefApply
|
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
def setup_telemetry
|
|
122
|
-
require "securerandom"
|
|
122
|
+
require "securerandom" unless defined?(SecureRandom)
|
|
123
123
|
installation_id = SecureRandom.uuid
|
|
124
124
|
File.write(Config.telemetry_installation_identifier_file, installation_id)
|
|
125
125
|
|
|
@@ -194,24 +194,26 @@ module ChefApply
|
|
|
194
194
|
Chef::Log.level = ChefApply::Log.level
|
|
195
195
|
end
|
|
196
196
|
|
|
197
|
-
def start_chef_apply
|
|
197
|
+
def start_chef_apply(enforce_license: false)
|
|
198
198
|
require_relative "cli"
|
|
199
|
-
ChefApply::CLI.new(@argv).run
|
|
199
|
+
ChefApply::CLI.new(@argv).run(enforce_license: enforce_license)
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
private
|
|
203
203
|
|
|
204
204
|
def script_path
|
|
205
|
-
|
|
205
|
+
__dir__
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
class ConfigPathNotProvided < StandardError; end
|
|
209
|
+
|
|
209
210
|
class ConfigPathInvalid < StandardError
|
|
210
211
|
attr_reader :path
|
|
211
212
|
def initialize(path)
|
|
212
213
|
@path = path
|
|
213
214
|
end
|
|
214
215
|
end
|
|
216
|
+
|
|
215
217
|
class UnsupportedInstallation < StandardError; end
|
|
216
218
|
end
|
|
217
219
|
end
|
|
@@ -139,6 +139,9 @@ module ChefApply
|
|
|
139
139
|
when :windows
|
|
140
140
|
require_relative "target_host/windows"
|
|
141
141
|
class << self; include ChefApply::TargetHost::Windows; end
|
|
142
|
+
when :macos
|
|
143
|
+
require_relative "target_host/macos"
|
|
144
|
+
class << self; include ChefApply::TargetHost::MacOS; end
|
|
142
145
|
when :other
|
|
143
146
|
raise ChefApply::TargetHost::UnsupportedTargetOS.new(platform.name)
|
|
144
147
|
end
|
|
@@ -169,6 +172,8 @@ module ChefApply
|
|
|
169
172
|
:windows
|
|
170
173
|
elsif platform.linux?
|
|
171
174
|
:linux
|
|
175
|
+
elsif platform.darwin?
|
|
176
|
+
:macos
|
|
172
177
|
else
|
|
173
178
|
:other
|
|
174
179
|
end
|
|
@@ -280,7 +285,7 @@ module ChefApply
|
|
|
280
285
|
end
|
|
281
286
|
|
|
282
287
|
def ssh_config_for_host(host)
|
|
283
|
-
require "net/ssh"
|
|
288
|
+
require "net/ssh" unless defined?(Net::SSH)
|
|
284
289
|
Net::SSH::Config.for(host)
|
|
285
290
|
end
|
|
286
291
|
|
|
@@ -323,7 +328,9 @@ module ChefApply
|
|
|
323
328
|
super(*(Array(init_params).flatten))
|
|
324
329
|
end
|
|
325
330
|
end
|
|
331
|
+
|
|
326
332
|
class ChefNotInstalled < StandardError; end
|
|
333
|
+
|
|
327
334
|
class UnsupportedTargetOS < ChefApply::ErrorNoLogs
|
|
328
335
|
def initialize(os_name); super("CHEFTARG001", os_name); end
|
|
329
336
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) 2017 Chef Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
module ChefApply
|
|
19
|
+
class TargetHost
|
|
20
|
+
module MacOS
|
|
21
|
+
def omnibus_manifest_path
|
|
22
|
+
# TODO - if habitat install on target, this won't work
|
|
23
|
+
# Note that we can't use File::Join, because that will render for the
|
|
24
|
+
# CURRENT platform - not the platform of the target.
|
|
25
|
+
"/opt/chef/version-manifest.json"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def mkdir(path)
|
|
29
|
+
run_command!("mkdir -p #{path}")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def chown(path, owner)
|
|
33
|
+
owner ||= user
|
|
34
|
+
run_command!("chown #{owner} '#{path}'")
|
|
35
|
+
nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def install_package(remote_path)
|
|
39
|
+
install_cmd = <<-EOS
|
|
40
|
+
hdiutil detach "/Volumes/chef_software" >/dev/null 2>&1 || true
|
|
41
|
+
hdiutil attach #{remote_path} -mountpoint "/Volumes/chef_software"
|
|
42
|
+
cd / && sudo /usr/sbin/installer -pkg `sudo find "/Volumes/chef_software" -name \\*.pkg` -target /
|
|
43
|
+
EOS
|
|
44
|
+
run_command!(install_cmd)
|
|
45
|
+
nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def del_file(path)
|
|
49
|
+
run_command!("rm -rf #{path}")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def del_dir(path)
|
|
53
|
+
del_file(path)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def make_temp_dir
|
|
57
|
+
installer_dir = "/tmp/chef-installer"
|
|
58
|
+
run_command!("mkdir -p #{installer_dir}")
|
|
59
|
+
run_command!("chmod 777 #{installer_dir}")
|
|
60
|
+
installer_dir
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def ws_cache_path
|
|
64
|
+
"/var/chef-workstation"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/lib/chef_apply/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chef-apply
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chef Software, Inc
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mixlib-cli
|
|
@@ -156,28 +156,28 @@ dependencies:
|
|
|
156
156
|
requirements:
|
|
157
157
|
- - ">="
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: '
|
|
159
|
+
version: '16.0'
|
|
160
160
|
type: :runtime
|
|
161
161
|
prerelease: false
|
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
163
|
requirements:
|
|
164
164
|
- - ">="
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: '
|
|
166
|
+
version: '16.0'
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
168
|
name: chef-cli
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
|
170
170
|
requirements:
|
|
171
171
|
- - ">="
|
|
172
172
|
- !ruby/object:Gem::Version
|
|
173
|
-
version:
|
|
173
|
+
version: 2.0.10
|
|
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:
|
|
180
|
+
version: 2.0.10
|
|
181
181
|
- !ruby/object:Gem::Dependency
|
|
182
182
|
name: chef-telemetry
|
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -196,36 +196,22 @@ dependencies:
|
|
|
196
196
|
name: license-acceptance
|
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
|
198
198
|
requirements:
|
|
199
|
-
- - "~>"
|
|
200
|
-
- !ruby/object:Gem::Version
|
|
201
|
-
version: '1.0'
|
|
202
199
|
- - ">="
|
|
203
200
|
- !ruby/object:Gem::Version
|
|
204
201
|
version: 1.0.11
|
|
202
|
+
- - "<"
|
|
203
|
+
- !ruby/object:Gem::Version
|
|
204
|
+
version: '3'
|
|
205
205
|
type: :runtime
|
|
206
206
|
prerelease: false
|
|
207
207
|
version_requirements: !ruby/object:Gem::Requirement
|
|
208
208
|
requirements:
|
|
209
|
-
- - "~>"
|
|
210
|
-
- !ruby/object:Gem::Version
|
|
211
|
-
version: '1.0'
|
|
212
209
|
- - ">="
|
|
213
210
|
- !ruby/object:Gem::Version
|
|
214
211
|
version: 1.0.11
|
|
215
|
-
-
|
|
216
|
-
name: bundler
|
|
217
|
-
requirement: !ruby/object:Gem::Requirement
|
|
218
|
-
requirements:
|
|
219
|
-
- - ">="
|
|
220
|
-
- !ruby/object:Gem::Version
|
|
221
|
-
version: '0'
|
|
222
|
-
type: :development
|
|
223
|
-
prerelease: false
|
|
224
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
225
|
-
requirements:
|
|
226
|
-
- - ">="
|
|
212
|
+
- - "<"
|
|
227
213
|
- !ruby/object:Gem::Version
|
|
228
|
-
version: '
|
|
214
|
+
version: '3'
|
|
229
215
|
description: Ad-hoc management of individual nodes and devices.
|
|
230
216
|
email:
|
|
231
217
|
- workstation@chef.io
|
|
@@ -265,6 +251,7 @@ files:
|
|
|
265
251
|
- lib/chef_apply/status_reporter.rb
|
|
266
252
|
- lib/chef_apply/target_host.rb
|
|
267
253
|
- lib/chef_apply/target_host/linux.rb
|
|
254
|
+
- lib/chef_apply/target_host/macos.rb
|
|
268
255
|
- lib/chef_apply/target_host/windows.rb
|
|
269
256
|
- lib/chef_apply/target_resolver.rb
|
|
270
257
|
- lib/chef_apply/telemeter.rb
|
|
@@ -294,14 +281,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
294
281
|
requirements:
|
|
295
282
|
- - ">="
|
|
296
283
|
- !ruby/object:Gem::Version
|
|
297
|
-
version: 2.
|
|
284
|
+
version: '2.6'
|
|
298
285
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
286
|
requirements:
|
|
300
287
|
- - ">="
|
|
301
288
|
- !ruby/object:Gem::Version
|
|
302
289
|
version: '0'
|
|
303
290
|
requirements: []
|
|
304
|
-
rubygems_version: 3.
|
|
291
|
+
rubygems_version: 3.1.4
|
|
305
292
|
signing_key:
|
|
306
293
|
specification_version: 4
|
|
307
294
|
summary: The ad-hoc execution tool for the Chef ecosystem.
|