chef 16.6.14 → 16.7.61
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 +4 -11
- data/Rakefile +21 -14
- data/chef-universal-mingw32.gemspec +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/client.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +2 -5
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_access_control/windows.rb +1 -4
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +4 -4
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +28 -39
- data/lib/chef/http.rb +2 -12
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/json_compat.rb +2 -7
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +2 -1
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
- data/lib/chef/knife/config_show.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +7 -4
- data/lib/chef/mixin/convert_to_class_name.rb +0 -56
- data/lib/chef/mixin/openssl_helper.rb +1 -1
- data/lib/chef/mixin/properties.rb +2 -0
- data/lib/chef/mixin/unformatter.rb +1 -1
- data/lib/chef/node/attribute_collections.rb +2 -6
- data/lib/chef/powershell.rb +5 -2
- data/lib/chef/property.rb +1 -1
- data/lib/chef/provider/cron.rb +2 -13
- data/lib/chef/provider/group.rb +14 -6
- data/lib/chef/provider/group/windows.rb +12 -1
- data/lib/chef/provider/ifconfig.rb +7 -7
- data/lib/chef/provider/ifconfig/debian.rb +5 -7
- data/lib/chef/provider/ifconfig/redhat.rb +3 -1
- data/lib/chef/provider/launchd.rb +1 -11
- data/lib/chef/provider/mount.rb +18 -1
- data/lib/chef/provider/mount/linux.rb +4 -0
- data/lib/chef/provider/mount/mount.rb +41 -43
- data/lib/chef/provider/package.rb +3 -0
- data/lib/chef/provider/package/apt.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +6 -6
- data/lib/chef/provider/package/freebsd/base.rb +3 -2
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/ips.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +2 -3
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/snap.rb +1 -3
- data/lib/chef/provider/package/solaris.rb +0 -2
- data/lib/chef/provider/package/yum/rpm_utils.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +98 -71
- data/lib/chef/provider/registry_key.rb +4 -3
- data/lib/chef/provider/route.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -1
- data/lib/chef/provider/user.rb +17 -9
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/mac.rb +12 -4
- data/lib/chef/provider/user/solaris.rb +1 -1
- data/lib/chef/provider/user/windows.rb +10 -3
- data/lib/chef/providers.rb +0 -3
- data/lib/chef/pwsh.rb +7 -0
- data/lib/chef/resource/bash.rb +119 -1
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +5 -8
- data/lib/chef/resource/csh.rb +2 -2
- data/lib/chef/resource/execute.rb +6 -4
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/homebrew_update.rb +4 -1
- data/lib/chef/resource/hostname.rb +2 -2
- data/lib/chef/resource/ifconfig.rb +52 -5
- data/lib/chef/resource/ksh.rb +3 -3
- data/lib/chef/resource/lwrp_base.rb +3 -5
- data/lib/chef/resource/mount.rb +7 -1
- data/lib/chef/resource/perl.rb +2 -2
- data/lib/chef/resource/plist.rb +2 -6
- data/lib/chef/resource/powershell_package_source.rb +19 -18
- data/lib/chef/resource/powershell_script.rb +7 -10
- data/lib/chef/resource/python.rb +2 -2
- data/lib/chef/resource/registry_key.rb +93 -2
- data/lib/chef/resource/route.rb +1 -1
- data/lib/chef/resource/ruby.rb +2 -2
- data/lib/chef/resource/scm/_scm.rb +2 -1
- data/lib/chef/resource/scm/git.rb +82 -1
- data/lib/chef/resource/scm/subversion.rb +12 -0
- data/lib/chef/resource/script.rb +2 -2
- data/lib/chef/resource/solaris_package.rb +0 -2
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/support/client.erb +4 -5
- data/lib/chef/resource/systemd_unit.rb +42 -1
- data/lib/chef/resource/windows_ad_join.rb +9 -9
- data/lib/chef/resource/windows_certificate.rb +6 -6
- data/lib/chef/resource/windows_dfs_server.rb +7 -4
- data/lib/chef/resource/windows_env.rb +173 -0
- data/lib/chef/resource/windows_feature.rb +2 -0
- data/lib/chef/resource/windows_firewall_profile.rb +7 -12
- data/lib/chef/resource/windows_firewall_rule.rb +9 -11
- data/lib/chef/resource/windows_font.rb +1 -1
- data/lib/chef/resource/windows_package.rb +1 -0
- data/lib/chef/resource/windows_path.rb +38 -0
- data/lib/chef/resource/windows_security_policy.rb +5 -5
- data/lib/chef/resource/windows_service.rb +108 -0
- data/lib/chef/resource/windows_share.rb +18 -18
- data/lib/chef/resource/windows_task.rb +629 -28
- data/lib/chef/resource/windows_workgroup.rb +6 -4
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_collection/resource_set.rb +1 -5
- data/lib/chef/resource_inspector.rb +77 -75
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/server_api.rb +0 -4
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -3
- data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +3 -9
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/spec/functional/mixin/powershell_out_spec.rb +4 -4
- data/spec/functional/resource/apt_package_spec.rb +4 -6
- data/spec/functional/resource/chocolatey_package_spec.rb +3 -3
- data/spec/functional/resource/cron_spec.rb +3 -3
- data/spec/functional/resource/dsc_script_spec.rb +3 -3
- data/spec/functional/resource/mount_spec.rb +10 -2
- data/spec/functional/resource/powershell_package_source_spec.rb +107 -0
- data/spec/functional/resource/windows_certificate_spec.rb +10 -6
- data/spec/functional/resource/windows_firewall_rule_spec.rb +93 -0
- data/spec/functional/resource/windows_package_spec.rb +36 -10
- data/spec/functional/resource/windows_share_spec.rb +103 -0
- data/spec/functional/resource/windows_task_spec.rb +2 -3
- data/spec/functional/resource/zypper_package_spec.rb +11 -0
- data/spec/integration/knife/client_key_create_spec.rb +1 -1
- data/spec/integration/knife/node_create_spec.rb +1 -1
- data/spec/integration/knife/node_environment_set_spec.rb +1 -1
- data/spec/integration/knife/node_run_list_add_spec.rb +4 -4
- data/spec/integration/knife/node_run_list_remove_spec.rb +1 -1
- data/spec/integration/knife/node_run_list_set_spec.rb +1 -1
- data/spec/integration/knife/node_show_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/provider_choice.rb +2 -2
- data/spec/support/lib/chef/resource/cat.rb +1 -1
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -1
- data/spec/support/mock/platform.rb +24 -16
- data/spec/support/platform_helpers.rb +6 -4
- data/spec/support/shared/unit/knife_shared.rb +1 -1
- data/spec/support/shared/unit/script_resource.rb +4 -4
- data/spec/support/shared/unit/windows_script_resource.rb +1 -1
- data/spec/unit/client_spec.rb +16 -0
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +11 -11
- data/spec/unit/knife/client_create_spec.rb +2 -2
- data/spec/unit/knife/configure_client_spec.rb +5 -5
- data/spec/unit/knife/configure_spec.rb +3 -3
- data/spec/unit/knife/cookbook_delete_spec.rb +2 -2
- data/spec/unit/knife/cookbook_download_spec.rb +2 -2
- data/spec/unit/knife/cookbook_list_spec.rb +2 -2
- data/spec/unit/knife/cookbook_metadata_spec.rb +3 -3
- data/spec/unit/knife/environment_compare_spec.rb +3 -3
- data/spec/unit/knife/supermarket_download_spec.rb +8 -8
- data/spec/unit/knife/supermarket_list_spec.rb +3 -3
- data/spec/unit/knife/supermarket_search_spec.rb +1 -1
- data/spec/unit/knife/tag_create_spec.rb +1 -1
- data/spec/unit/knife/tag_delete_spec.rb +1 -1
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/mixin/which.rb +1 -1
- data/spec/unit/provider/group/windows_spec.rb +6 -0
- data/spec/unit/provider/group_spec.rb +1 -1
- data/spec/unit/provider/mount/linux_spec.rb +10 -0
- data/spec/unit/provider/mount/mount_spec.rb +21 -10
- data/spec/unit/provider/mount/solaris_spec.rb +1 -1
- data/spec/unit/provider/mount_spec.rb +31 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -2
- data/spec/unit/provider/package/powershell_spec.rb +87 -95
- data/spec/unit/provider/package/zypper_spec.rb +0 -25
- data/spec/unit/provider/package_spec.rb +2 -2
- data/spec/unit/provider/subversion_spec.rb +0 -3
- data/spec/unit/provider/user_spec.rb +7 -1
- data/spec/unit/provider/windows_env_spec.rb +18 -34
- data/spec/unit/provider/windows_path_spec.rb +6 -11
- data/spec/unit/provider/windows_task_spec.rb +7 -6
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/build_essential_spec.rb +0 -12
- data/spec/unit/resource/ifconfig_spec.rb +2 -10
- data/spec/unit/resource/mount_spec.rb +18 -5
- data/spec/unit/resource/powershell_package_source_spec.rb +20 -20
- data/spec/unit/resource/powershell_script_spec.rb +4 -74
- data/spec/unit/resource/service_spec.rb +2 -2
- data/spec/unit/resource/solaris_package_spec.rb +8 -10
- data/spec/unit/resource_inspector_spec.rb +3 -3
- data/spec/unit/shell_spec.rb +2 -2
- data/tasks/rspec.rb +1 -1
- metadata +9 -15
- data/lib/chef/monkey_patches/net_http.rb +0 -22
- data/lib/chef/provider/windows_env.rb +0 -210
- data/lib/chef/provider/windows_path.rb +0 -61
- data/lib/chef/provider/windows_task.rb +0 -631
- data/spec/support/mock/constant.rb +0 -52
- data/spec/unit/monkey_patches/uri_spec.rb +0 -34
- data/spec/unit/provider_resolver_spec.rb +0 -885
- data/spec/unit/resource/data/InstallHistory_with_CLT.plist +0 -92
- data/spec/unit/resource/data/InstallHistory_without_CLT.plist +0 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45d0c49c6265534a875b8044449678109b0c11a22b83027f28826e3ea14ee792
|
|
4
|
+
data.tar.gz: a6375a107a0ece5bbd866f42c0d415e582135d24512d8815b894786e64c685b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8cf6a1c8dd0316944eaa700f6c788e2ff6843dc9bd9252b2710e2465498041e1eb8a6990ace8bbef2bb265e3254e1460a56e9f85489d133a0dffbc03b140c928
|
|
7
|
+
data.tar.gz: e57ee2f117d322936e53b384202691b7d9be946b4be9b4cc697d162163f3b65885109ef5977448861fa6f8db3cafbe364294ab2e30d78b61f7e51d8fc7eed16a
|
data/Gemfile
CHANGED
|
@@ -30,21 +30,14 @@ group(:omnibus_package) do
|
|
|
30
30
|
gem "inspec-core", "~> 4.18"
|
|
31
31
|
gem "inspec-core-bin", "~> 4.18" # need to provide the binaries for inspec
|
|
32
32
|
gem "chef-vault"
|
|
33
|
-
gem "ed25519" # ed25519 ssh key support done here as it's a native gem we can't put in train
|
|
34
|
-
gem "bcrypt_pbkdf", ">= 1.1.0.rc1" # ed25519 ssh key support done here as it's a native gem we can't put in train
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
group(:omnibus_package, :pry) do
|
|
38
36
|
gem "pry"
|
|
39
37
|
gem "pry-byebug"
|
|
40
|
-
gem "pry-remote"
|
|
41
38
|
gem "pry-stack_explorer"
|
|
42
39
|
end
|
|
43
40
|
|
|
44
|
-
group(:docgen) do
|
|
45
|
-
gem "yard"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
41
|
# Everything except AIX
|
|
49
42
|
group(:ruby_prof) do
|
|
50
43
|
# ruby-prof 1.3.0 does not compile on our centos6 builders/kitchen testers
|
|
@@ -58,10 +51,7 @@ end
|
|
|
58
51
|
|
|
59
52
|
group(:development, :test) do
|
|
60
53
|
gem "rake"
|
|
61
|
-
gem "rspec
|
|
62
|
-
gem "rspec-mocks", "~> 3.5"
|
|
63
|
-
gem "rspec-expectations", "~> 3.5"
|
|
64
|
-
gem "rspec_junit_formatter", "~> 0.2.0"
|
|
54
|
+
gem "rspec"
|
|
65
55
|
gem "webmock"
|
|
66
56
|
gem "fauxhai-ng" # for chef-utils gem
|
|
67
57
|
end
|
|
@@ -81,6 +71,9 @@ eval_gemfile("./Gemfile.local") if File.exist?("./Gemfile.local")
|
|
|
81
71
|
# For FFI to call into PowerShell we need the binaries and assemblies located
|
|
82
72
|
# in the Ruby bindir.
|
|
83
73
|
# The Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim
|
|
74
|
+
# Every merge into that repo triggers a Habitat build and promotion. Running
|
|
75
|
+
# the rake :update_chef_exec_dll task in this (chef/chef) repo will pull down
|
|
76
|
+
# the built packages and copy the binaries to distro/ruby_bin_folder.
|
|
84
77
|
#
|
|
85
78
|
# We copy (and overwrite) these files every time "bundle <exec|install>" is
|
|
86
79
|
# executed, just in case they have changed.
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
|
3
3
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
|
4
|
-
# Copyright:: Copyright
|
|
4
|
+
# Copyright:: Copyright, Chef Software Inc.
|
|
5
5
|
# License:: Apache License, Version 2.0
|
|
6
6
|
#
|
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -23,7 +23,6 @@ $LOAD_PATH.unshift(File.expand_path("chef-config/lib", __dir__))
|
|
|
23
23
|
begin
|
|
24
24
|
require_relative "tasks/rspec"
|
|
25
25
|
require_relative "tasks/dependencies"
|
|
26
|
-
require_relative "tasks/announce"
|
|
27
26
|
require_relative "tasks/docs"
|
|
28
27
|
require_relative "tasks/spellcheck"
|
|
29
28
|
require_relative "chef-utils/lib/chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
@@ -48,6 +47,7 @@ namespace :pre_install do
|
|
|
48
47
|
|
|
49
48
|
desc "Renders the powershell extensions with distro flavoring"
|
|
50
49
|
task :render_powershell_extension do
|
|
50
|
+
require "erb"
|
|
51
51
|
template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
|
|
52
52
|
psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
|
|
53
53
|
FileUtils.mkdir_p psm1_path
|
|
@@ -88,6 +88,25 @@ task :register_eventlog do
|
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
desc "Copies powershell_exec related binaries from the latest built Habitat Packages"
|
|
92
|
+
task :update_chef_exec_dll do
|
|
93
|
+
raise "This task must be run on Windows since we are installing a Windows targeted package!" unless Gem.win_platform?
|
|
94
|
+
|
|
95
|
+
require "mkmf"
|
|
96
|
+
raise "Unable to locate Habitat cli. Please install Habitat cli before invoking this task!" unless find_executable "hab"
|
|
97
|
+
|
|
98
|
+
sh("hab pkg install chef/chef-powershell-shim")
|
|
99
|
+
sh("hab pkg install chef/chef-powershell-shim-x86")
|
|
100
|
+
x64 = `hab pkg path chef/chef-powershell-shim`.chomp.gsub(/\\/, "/")
|
|
101
|
+
x86 = `hab pkg path chef/chef-powershell-shim-x86`.chomp.gsub(/\\/, "/")
|
|
102
|
+
FileUtils.rm_rf(Dir["distro/ruby_bin_folder/AMD64/*"])
|
|
103
|
+
FileUtils.rm_rf(Dir["distro/ruby_bin_folder/x86/*"])
|
|
104
|
+
puts "Copying #{x64}/bin/* to distro/ruby_bin_folder/AMD64"
|
|
105
|
+
FileUtils.cp_r(Dir["#{x64}/bin/*"], "distro/ruby_bin_folder/AMD64")
|
|
106
|
+
puts "Copying #{x86}/bin/* to distro/ruby_bin_folder/x86"
|
|
107
|
+
FileUtils.cp_r(Dir["#{x86}/bin/*"], "distro/ruby_bin_folder/x86")
|
|
108
|
+
end
|
|
109
|
+
|
|
91
110
|
begin
|
|
92
111
|
require "chefstyle"
|
|
93
112
|
require "rubocop/rake_task"
|
|
@@ -97,15 +116,3 @@ begin
|
|
|
97
116
|
rescue LoadError
|
|
98
117
|
puts "chefstyle/rubocop is not available. bundle install first to make sure all dependencies are installed."
|
|
99
118
|
end
|
|
100
|
-
|
|
101
|
-
begin
|
|
102
|
-
require "yard"
|
|
103
|
-
DOC_FILES = [ "spec/tiny_server.rb", "lib/**/*.rb" ].freeze
|
|
104
|
-
|
|
105
|
-
YARD::Rake::YardocTask.new(:docs) do |t|
|
|
106
|
-
t.files = DOC_FILES
|
|
107
|
-
t.options = ["--format", "html"]
|
|
108
|
-
end
|
|
109
|
-
rescue LoadError
|
|
110
|
-
puts "yard is not available. bundle install first to make sure all dependencies are installed."
|
|
111
|
-
end
|
|
@@ -9,7 +9,7 @@ gemspec.add_dependency "win32-event", "~> 0.6.1"
|
|
|
9
9
|
gemspec.add_dependency "win32-eventlog", "0.6.3"
|
|
10
10
|
gemspec.add_dependency "win32-mmap", "~> 0.4.1"
|
|
11
11
|
gemspec.add_dependency "win32-mutex", "~> 0.4.2"
|
|
12
|
-
gemspec.add_dependency "win32-process", "~> 0.
|
|
12
|
+
gemspec.add_dependency "win32-process", "~> 0.9"
|
|
13
13
|
gemspec.add_dependency "win32-service", ">= 2.1.5", "< 3.0"
|
|
14
14
|
gemspec.add_dependency "wmi-lite", "~> 1.0"
|
|
15
15
|
gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
|
|
@@ -20,7 +20,7 @@ require_relative "../application"
|
|
|
20
20
|
require "mixlib/log"
|
|
21
21
|
require "ohai/config"
|
|
22
22
|
module Net
|
|
23
|
-
autoload :HTTP,
|
|
23
|
+
autoload :HTTP, "net/http"
|
|
24
24
|
end
|
|
25
25
|
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
26
26
|
|
data/lib/chef/client.rb
CHANGED
|
@@ -243,12 +243,12 @@ class Chef
|
|
|
243
243
|
run_status.run_context = run_context
|
|
244
244
|
|
|
245
245
|
events.run_start(Chef::VERSION, run_status)
|
|
246
|
-
|
|
247
246
|
logger.info("*** #{ChefUtils::Dist::Infra::PRODUCT} #{Chef::VERSION} ***")
|
|
248
247
|
logger.info("Platform: #{RUBY_PLATFORM}")
|
|
249
248
|
logger.info "#{ChefUtils::Dist::Infra::CLIENT.capitalize} pid: #{Process.pid}"
|
|
250
249
|
logger.info "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode?
|
|
251
250
|
logger.debug("#{ChefUtils::Dist::Infra::CLIENT.capitalize} request_id: #{request_id}")
|
|
251
|
+
logger.warn("`enforce_path_sanity` is deprecated, please use `enforce_default_paths` instead!") if Chef::Config[:enforce_path_sanity]
|
|
252
252
|
ENV["PATH"] = ChefUtils::DSL::DefaultPaths.default_paths if Chef::Config[:enforce_default_paths] || Chef::Config[:enforce_path_sanity]
|
|
253
253
|
|
|
254
254
|
run_ohai
|
|
@@ -282,7 +282,7 @@ class Chef
|
|
|
282
282
|
|
|
283
283
|
name = File.join(segment, pathname.basename.to_s)
|
|
284
284
|
|
|
285
|
-
if
|
|
285
|
+
if %w{templates files}.include?(segment)
|
|
286
286
|
# Check if pathname looks like files/foo or templates/foo (unscoped)
|
|
287
287
|
if pathname.each_filename.to_a.length == 2
|
|
288
288
|
# Use root_default in case the same path exists at root_default and default
|
|
@@ -264,7 +264,7 @@ class Chef
|
|
|
264
264
|
if found_pref
|
|
265
265
|
manifest_records_by_path[found_pref]
|
|
266
266
|
else
|
|
267
|
-
if
|
|
267
|
+
if %i{files templates}.include?(segment)
|
|
268
268
|
error_message = "Cookbook '#{name}' (#{version}) does not contain a file at any of these locations:\n"
|
|
269
269
|
error_locations = if filename.is_a?(Array)
|
|
270
270
|
filename.map { |name| " #{File.join(segment.to_s, name)}" }
|
|
@@ -587,10 +587,7 @@ class Chef
|
|
|
587
587
|
end
|
|
588
588
|
|
|
589
589
|
def file_vendor
|
|
590
|
-
|
|
591
|
-
@file_vendor = Chef::Cookbook::FileVendor.create_from_manifest(cookbook_manifest)
|
|
592
|
-
end
|
|
593
|
-
@file_vendor
|
|
590
|
+
@file_vendor ||= Chef::Cookbook::FileVendor.create_from_manifest(cookbook_manifest)
|
|
594
591
|
end
|
|
595
592
|
|
|
596
593
|
end
|
data/lib/chef/environment.rb
CHANGED
|
@@ -35,7 +35,7 @@ class Chef
|
|
|
35
35
|
include Chef::Mixin::ParamsValidate
|
|
36
36
|
include Chef::Mixin::FromFile
|
|
37
37
|
|
|
38
|
-
COMBINED_COOKBOOK_CONSTRAINT = /(.+)(
|
|
38
|
+
COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:\s+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:\s+).+)$/.freeze
|
|
39
39
|
|
|
40
40
|
def initialize(chef_server_rest: nil)
|
|
41
41
|
@name = ""
|
data/lib/chef/exceptions.rb
CHANGED
|
@@ -451,7 +451,7 @@ class Chef
|
|
|
451
451
|
attr_reader :wrapped_errors
|
|
452
452
|
|
|
453
453
|
def initialize(*errors)
|
|
454
|
-
errors = errors.
|
|
454
|
+
errors = errors.compact
|
|
455
455
|
output = "Found #{errors.size} errors, they are stored in the backtrace"
|
|
456
456
|
@wrapped_errors = errors
|
|
457
457
|
super output
|
|
@@ -255,10 +255,7 @@ class Chef
|
|
|
255
255
|
flags |= CONTAINER_INHERIT_ACE
|
|
256
256
|
when :objects_only
|
|
257
257
|
flags |= OBJECT_INHERIT_ACE
|
|
258
|
-
when true
|
|
259
|
-
flags |= CONTAINER_INHERIT_ACE
|
|
260
|
-
flags |= OBJECT_INHERIT_ACE
|
|
261
|
-
when nil
|
|
258
|
+
when true, nil
|
|
262
259
|
flags |= CONTAINER_INHERIT_ACE
|
|
263
260
|
flags |= OBJECT_INHERIT_ACE
|
|
264
261
|
end
|
|
@@ -115,14 +115,14 @@ class Chef
|
|
|
115
115
|
|
|
116
116
|
def culprit_line
|
|
117
117
|
@culprit_line ||= begin
|
|
118
|
-
line_number = culprit_backtrace_entry[/^(?:.\:)?[^:]+:(
|
|
118
|
+
line_number = culprit_backtrace_entry[/^(?:.\:)?[^:]+:(\d+)/, 1].to_i
|
|
119
119
|
Chef::Log.trace("Line number of compile error: '#{line_number}'")
|
|
120
120
|
line_number
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
def culprit_file
|
|
125
|
-
@culprit_file ||= culprit_backtrace_entry[/^((?:.\:)?[^:]+):(
|
|
125
|
+
@culprit_file ||= culprit_backtrace_entry[/^((?:.\:)?[^:]+):(\d+)/, 1]
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
def filtered_bt
|
|
@@ -79,8 +79,8 @@ class Chef
|
|
|
79
79
|
loop do
|
|
80
80
|
|
|
81
81
|
# low rent parser. try to gracefully handle nested blocks in resources
|
|
82
|
-
nesting += 1 if
|
|
83
|
-
nesting -= 1 if /end
|
|
82
|
+
nesting += 1 if /\s+do\s*/.match?(lines[current_line])
|
|
83
|
+
nesting -= 1 if /end\s*$/.match?(lines[current_line])
|
|
84
84
|
|
|
85
85
|
relevant_lines << format_line(current_line, lines[current_line])
|
|
86
86
|
|
|
@@ -114,11 +114,11 @@ class Chef
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def parse_source
|
|
117
|
-
resource.source_line[/^((
|
|
117
|
+
resource.source_line[/^((\w:)?[^:]+):(\d+)/, 1]
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
def parse_line(source)
|
|
121
|
-
resource.source_line[/^#{Regexp.escape(source)}:(
|
|
121
|
+
resource.source_line[/^#{Regexp.escape(source)}:(\d+)/, 1].to_i
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
end
|
|
@@ -20,19 +20,30 @@ require_relative "../guard_interpreter"
|
|
|
20
20
|
|
|
21
21
|
class Chef
|
|
22
22
|
class GuardInterpreter
|
|
23
|
-
class ResourceGuardInterpreter
|
|
24
|
-
|
|
23
|
+
class ResourceGuardInterpreter
|
|
25
24
|
def initialize(parent_resource, command, opts)
|
|
26
|
-
|
|
25
|
+
@command = command
|
|
26
|
+
@opts = opts
|
|
27
|
+
|
|
27
28
|
@parent_resource = parent_resource
|
|
28
29
|
@resource = get_interpreter_resource(parent_resource)
|
|
29
30
|
end
|
|
30
31
|
|
|
32
|
+
# This class used to inherit from DefaultGuardInterpreter and it responds
|
|
33
|
+
# to #output, so leave this in for potential backwards compatibility.
|
|
34
|
+
def output
|
|
35
|
+
nil
|
|
36
|
+
end
|
|
37
|
+
|
|
31
38
|
def evaluate
|
|
32
39
|
# Add attributes inherited from the parent class
|
|
33
40
|
# to the resource
|
|
34
41
|
merge_inherited_attributes
|
|
35
42
|
|
|
43
|
+
@opts.each do |attribute, value|
|
|
44
|
+
@resource.send(attribute, value)
|
|
45
|
+
end
|
|
46
|
+
|
|
36
47
|
# Only execute and script resources and use guard attributes.
|
|
37
48
|
# The command to be executed on them are passed via different attributes.
|
|
38
49
|
# Script resources use code attribute and execute resources use
|
|
@@ -42,9 +53,9 @@ class Chef
|
|
|
42
53
|
# We need to make sure we check for Script first because any resource
|
|
43
54
|
# that can get to here is an Execute resource.
|
|
44
55
|
if @resource.is_a? Chef::Resource::Script
|
|
45
|
-
|
|
56
|
+
@resource.code @command
|
|
46
57
|
else
|
|
47
|
-
|
|
58
|
+
@resource.command @command
|
|
48
59
|
end
|
|
49
60
|
|
|
50
61
|
# Handles cases like powershell_script where default
|
|
@@ -53,33 +64,24 @@ class Chef
|
|
|
53
64
|
# the one attribute that causes this changes its default to be
|
|
54
65
|
# the same after some period to prepare for deprecation
|
|
55
66
|
if @resource.class.respond_to?(:get_default_attributes)
|
|
56
|
-
|
|
67
|
+
@resource.class.send(:get_default_attributes).each do |attribute, value|
|
|
68
|
+
@resource.send(attribute, value)
|
|
69
|
+
end
|
|
57
70
|
end
|
|
58
71
|
|
|
59
|
-
resource_block = block_from_attributes(block_attributes)
|
|
60
|
-
evaluate_action(nil, &resource_block)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
protected
|
|
64
|
-
|
|
65
|
-
def evaluate_action(action = nil, &block)
|
|
66
|
-
@resource.instance_eval(&block)
|
|
67
|
-
|
|
68
|
-
run_action = action || @resource.action
|
|
69
|
-
|
|
70
72
|
begin
|
|
71
73
|
# Coerce to an array to be safe. This could happen with a legacy
|
|
72
74
|
# resource or something overriding the default_action code in a
|
|
73
75
|
# subclass.
|
|
74
|
-
Array(
|
|
75
|
-
|
|
76
|
+
Array(@resource.action).each { |action_to_run| @resource.run_action(action_to_run) }
|
|
77
|
+
@resource.updated
|
|
76
78
|
rescue Mixlib::ShellOut::ShellCommandFailed
|
|
77
|
-
|
|
79
|
+
nil
|
|
78
80
|
end
|
|
79
|
-
|
|
80
|
-
resource_updated
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
private
|
|
84
|
+
|
|
83
85
|
def get_interpreter_resource(parent_resource)
|
|
84
86
|
if parent_resource.nil? || parent_resource.node.nil?
|
|
85
87
|
raise ArgumentError, "Node for guard resource parent must not be nil"
|
|
@@ -106,14 +108,6 @@ class Chef
|
|
|
106
108
|
interpreter_resource
|
|
107
109
|
end
|
|
108
110
|
|
|
109
|
-
def block_from_attributes(attributes)
|
|
110
|
-
Proc.new do
|
|
111
|
-
attributes.each_key do |attribute_name|
|
|
112
|
-
send(attribute_name, attributes[attribute_name]) if respond_to?(attribute_name)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
111
|
def merge_inherited_attributes
|
|
118
112
|
inherited_attributes = []
|
|
119
113
|
|
|
@@ -121,15 +115,10 @@ class Chef
|
|
|
121
115
|
inherited_attributes = @parent_resource.class.send(:guard_inherited_attributes)
|
|
122
116
|
end
|
|
123
117
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
child_value = @resource.send(attribute)
|
|
129
|
-
if parent_value || child_value
|
|
130
|
-
@resource.send(attribute, parent_value)
|
|
131
|
-
end
|
|
132
|
-
end
|
|
118
|
+
inherited_attributes.each do |attribute|
|
|
119
|
+
if @parent_resource.respond_to?(attribute) && @resource.respond_to?(attribute)
|
|
120
|
+
parent_value = @parent_resource.send(attribute)
|
|
121
|
+
@resource.send(attribute, parent_value)
|
|
133
122
|
end
|
|
134
123
|
end
|
|
135
124
|
end
|
data/lib/chef/http.rb
CHANGED
|
@@ -25,8 +25,8 @@ require "tempfile" unless defined?(Tempfile)
|
|
|
25
25
|
autoload :OpenSSL, "openssl"
|
|
26
26
|
autoload :URI, "uri"
|
|
27
27
|
module Net
|
|
28
|
-
autoload :HTTP,
|
|
29
|
-
autoload :HTTPClientException,
|
|
28
|
+
autoload :HTTP, "net/http"
|
|
29
|
+
autoload :HTTPClientException, "net/http"
|
|
30
30
|
end
|
|
31
31
|
require_relative "http/basic_client"
|
|
32
32
|
require_relative "config"
|
|
@@ -165,10 +165,6 @@ class Chef
|
|
|
165
165
|
end
|
|
166
166
|
rescue Exception => exception
|
|
167
167
|
log_failed_request(response, return_value) unless response.nil?
|
|
168
|
-
|
|
169
|
-
if exception.respond_to?(:chef_rest_request=)
|
|
170
|
-
exception.chef_rest_request = rest_request
|
|
171
|
-
end
|
|
172
168
|
raise
|
|
173
169
|
end
|
|
174
170
|
|
|
@@ -204,9 +200,6 @@ class Chef
|
|
|
204
200
|
end
|
|
205
201
|
rescue Exception => e
|
|
206
202
|
log_failed_request(response, return_value) unless response.nil?
|
|
207
|
-
if e.respond_to?(:chef_rest_request=)
|
|
208
|
-
e.chef_rest_request = rest_request
|
|
209
|
-
end
|
|
210
203
|
raise
|
|
211
204
|
end
|
|
212
205
|
|
|
@@ -260,9 +253,6 @@ class Chef
|
|
|
260
253
|
end
|
|
261
254
|
rescue Exception => e
|
|
262
255
|
log_failed_request(response, return_value) unless response.nil?
|
|
263
|
-
if e.respond_to?(:chef_rest_request=)
|
|
264
|
-
e.chef_rest_request = rest_request
|
|
265
|
-
end
|
|
266
256
|
raise
|
|
267
257
|
end
|
|
268
258
|
|