chef 16.5.64 → 16.8.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -14
- data/README.md +1 -1
- data/Rakefile +21 -14
- data/chef-universal-mingw32.gemspec +1 -1
- data/chef.gemspec +3 -2
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/base.rb +1 -1
- data/lib/chef/application/client.rb +7 -2
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.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/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/client.rb +6 -32
- data/lib/chef/compliance/default_attributes.rb +89 -0
- data/lib/chef/compliance/fetcher/automate.rb +69 -0
- data/lib/chef/compliance/fetcher/chef_server.rb +134 -0
- data/lib/chef/compliance/reporter/automate.rb +202 -0
- data/lib/chef/compliance/reporter/chef_server_automate.rb +94 -0
- data/lib/chef/compliance/reporter/compliance_enforcer.rb +20 -0
- data/lib/chef/compliance/reporter/json_file.rb +19 -0
- data/lib/chef/compliance/runner.rb +261 -0
- data/lib/chef/cookbook/gem_installer.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +2 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +2 -5
- data/lib/chef/data_collector.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/assertions.rb +1 -1
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +5 -1
- data/lib/chef/file_access_control/windows.rb +1 -4
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +5 -5
- data/lib/chef/formatters/indentable_output_stream.rb +2 -2
- 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/http/ssl_policies.rb +6 -0
- 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/bootstrap/train_connector.rb +1 -1
- 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/ui.rb +5 -2
- data/lib/chef/knife/core/windows_bootstrap_context.rb +7 -4
- data/lib/chef/knife/node_policy_set.rb +2 -2
- data/lib/chef/knife/node_run_list_add.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/node_run_list_set.rb +1 -1
- data/lib/chef/knife/role_env_run_list_add.rb +1 -1
- data/lib/chef/knife/role_env_run_list_set.rb +1 -1
- data/lib/chef/knife/role_run_list_add.rb +1 -1
- data/lib/chef/knife/role_run_list_set.rb +1 -1
- data/lib/chef/knife/search.rb +0 -1
- data/lib/chef/knife/ssh.rb +5 -3
- data/lib/chef/knife/tag_create.rb +1 -1
- data/lib/chef/knife/tag_delete.rb +1 -1
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mixin/convert_to_class_name.rb +0 -56
- data/lib/chef/mixin/openssl_helper.rb +1 -1
- data/lib/chef/mixin/powershell_exec.rb +24 -10
- data/lib/chef/mixin/powershell_out.rb +12 -5
- data/lib/chef/mixin/properties.rb +2 -0
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/unformatter.rb +1 -1
- data/lib/chef/mixin/uris.rb +3 -1
- data/lib/chef/node/attribute_collections.rb +2 -6
- data/lib/chef/node/mixin/immutablize_hash.rb +2 -0
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/query_helpers.rb +4 -4
- data/lib/chef/policy_builder/dynamic.rb +2 -0
- data/lib/chef/powershell.rb +10 -4
- data/lib/chef/property.rb +1 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/provider/cron.rb +2 -13
- data/lib/chef/provider/dsc_resource.rb +12 -24
- data/lib/chef/provider/dsc_script.rb +16 -20
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/git.rb +5 -5
- data/lib/chef/provider/group.rb +14 -6
- data/lib/chef/provider/group/windows.rb +12 -1
- data/lib/chef/provider/ifconfig.rb +8 -8
- data/lib/chef/provider/ifconfig/debian.rb +38 -22
- data/lib/chef/provider/ifconfig/redhat.rb +54 -18
- data/lib/chef/provider/launchd.rb +1 -11
- data/lib/chef/provider/link.rb +0 -9
- 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/dpkg.rb +3 -12
- 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/homebrew.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/powershell_script.rb +12 -1
- 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/service/redhat.rb +1 -1
- data/lib/chef/provider/user.rb +17 -9
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +2 -2
- data/lib/chef/provider/user/mac.rb +14 -6
- 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 +71 -0
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/resource/apt_repository.rb +6 -5
- 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/chef_client_config.rb +313 -0
- data/lib/chef/resource/chef_client_cron.rb +5 -5
- data/lib/chef/resource/chef_client_scheduled_task.rb +4 -4
- data/lib/chef/resource/chef_client_systemd_timer.rb +5 -5
- data/lib/chef/resource/chef_handler.rb +1 -0
- data/lib/chef/resource/chef_sleep.rb +1 -1
- data/lib/chef/resource/cron/_cron_shared.rb +1 -0
- data/lib/chef/resource/cron/cron_d.rb +2 -2
- data/lib/chef/resource/csh.rb +2 -2
- data/lib/chef/resource/dsc_script.rb +8 -1
- data/lib/chef/resource/execute.rb +6 -4
- data/lib/chef/resource/file.rb +2 -2
- data/lib/chef/resource/homebrew_update.rb +4 -1
- data/lib/chef/resource/hostname.rb +5 -5
- data/lib/chef/resource/ifconfig.rb +52 -5
- data/lib/chef/resource/kernel_module.rb +1 -1
- data/lib/chef/resource/ksh.rb +3 -3
- data/lib/chef/resource/launchd.rb +15 -15
- data/lib/chef/resource/lwrp_base.rb +3 -5
- data/lib/chef/resource/mount.rb +8 -2
- 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 +14 -11
- 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 +64 -0
- data/lib/chef/resource/systemd_unit.rb +42 -1
- data/lib/chef/resource/template.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +9 -9
- data/lib/chef/resource/windows_audit_policy.rb +26 -24
- data/lib/chef/resource/windows_certificate.rb +13 -7
- 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 +2 -6
- data/lib/chef/resource_inspector.rb +77 -75
- data/lib/chef/resource_reporter.rb +0 -2
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_lock.rb +2 -2
- data/lib/chef/search/query.rb +3 -1
- data/lib/chef/server_api.rb +0 -4
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/backup.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +52 -11
- data/lib/chef/util/dsc/lcm_output_parser.rb +4 -7
- data/lib/chef/util/dsc/local_configuration_manager.rb +18 -15
- data/lib/chef/util/dsc/resource_store.rb +5 -11
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +4 -0
- data/lib/chef/win32/file.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/lib/chef/win32/unicode.rb +1 -1
- data/spec/functional/mixin/powershell_out_spec.rb +11 -3
- 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 +6 -9
- data/spec/functional/resource/mount_spec.rb +10 -2
- data/spec/functional/resource/powershell_package_source_spec.rb +107 -0
- data/spec/functional/resource/powershell_script_spec.rb +57 -14
- 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/client/client_spec.rb +2 -1
- data/spec/integration/compliance/compliance_spec.rb +81 -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/integration/recipes/recipe_dsl_spec.rb +1 -0
- data/spec/spec_helper.rb +3 -4
- 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 +11 -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/chef_fs/config_spec.rb +1 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/spec/unit/client_spec.rb +17 -0
- data/spec/unit/compliance/fetcher/automate_spec.rb +134 -0
- data/spec/unit/compliance/fetcher/chef_server_spec.rb +93 -0
- data/spec/unit/compliance/reporter/automate_spec.rb +427 -0
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +177 -0
- data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +48 -0
- data/spec/unit/compliance/runner_spec.rb +140 -0
- data/spec/unit/data_collector_spec.rb +0 -4
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +11 -11
- data/spec/unit/http/ssl_policies_spec.rb +11 -0
- 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/core/node_editor_spec.rb +1 -1
- 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/powershell_exec_spec.rb +41 -4
- data/spec/unit/mixin/powershell_out_spec.rb +14 -0
- data/spec/unit/mixin/which.rb +1 -1
- data/spec/unit/platform/query_helpers_spec.rb +11 -12
- data/spec/unit/provider/dsc_resource_spec.rb +10 -27
- data/spec/unit/provider/dsc_script_spec.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/windows_spec.rb +1 -0
- 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/powershell_script_spec.rb +11 -0
- data/spec/unit/provider/subversion_spec.rb +0 -3
- data/spec/unit/provider/systemd_unit_spec.rb +1 -1
- 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/chef_client_config_spec.rb +137 -0
- 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/windows_certificate_spec.rb +12 -0
- data/spec/unit/resource_inspector_spec.rb +3 -3
- data/spec/unit/shell_spec.rb +2 -2
- data/spec/unit/util/dsc/configuration_generator_spec.rb +79 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +27 -35
- data/tasks/rspec.rb +1 -1
- metadata +47 -24
- 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/lib/chef/util/powershell/cmdlet.rb +0 -175
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -61
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -111
- 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
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -76,7 +76,7 @@ class Chef
|
|
76
76
|
# complexity here is due to supporting mangling non-UTF8 strings (e.g. latin-1 filenames with characters that are illegal in UTF-8)
|
77
77
|
b = File.basename(@new_resource.path)
|
78
78
|
i = b.index(".")
|
79
|
-
i.nil? ? "" : b[i
|
79
|
+
i.nil? ? "" : b[i..].scrub
|
80
80
|
end
|
81
81
|
|
82
82
|
# Returns the possible directories for the tempfile to be created in.
|
@@ -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
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
|
-
require "chef-utils" unless defined?(ChefUtils)
|
19
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
module Formatters
|
@@ -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,7 +20,7 @@ class Chef
|
|
20
20
|
# pastel.decorate is a lightweight replacement for highline.color
|
21
21
|
def pastel
|
22
22
|
@pastel ||= begin
|
23
|
-
require "pastel"
|
23
|
+
require "pastel" unless defined?(Pastel)
|
24
24
|
Pastel.new
|
25
25
|
end
|
26
26
|
end
|
@@ -126,7 +126,7 @@ class Chef
|
|
126
126
|
indent_line(options)
|
127
127
|
|
128
128
|
# Note that the next line will need to be started
|
129
|
-
if line[-1
|
129
|
+
if line[-1..] == "\n"
|
130
130
|
@line_started = false
|
131
131
|
end
|
132
132
|
|
@@ -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
|
|
@@ -70,6 +70,12 @@ class Chef
|
|
70
70
|
end
|
71
71
|
|
72
72
|
http_client.ca_file = config[:ssl_ca_file]
|
73
|
+
elsif ENV["SSL_CERT_FILE"]
|
74
|
+
unless ::File.exist?(ENV["SSL_CERT_FILE"])
|
75
|
+
raise Chef::Exceptions::ConfigurationError, "The configured ssl_ca_file #{ENV["SSL_CERT_FILE"]} does not exist"
|
76
|
+
end
|
77
|
+
|
78
|
+
http_client.ca_file = ENV["SSL_CERT_FILE"]
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
data/lib/chef/json_compat.rb
CHANGED
@@ -24,18 +24,15 @@ require "json" unless defined?(JSON)
|
|
24
24
|
|
25
25
|
class Chef
|
26
26
|
class JSONCompat
|
27
|
-
JSON_MAX_NESTING = 1000
|
28
27
|
|
29
28
|
class <<self
|
30
29
|
|
31
|
-
# API to use to avoid create_additions
|
32
30
|
def parse(source, opts = {})
|
33
31
|
FFI_Yajl::Parser.parse(source, opts)
|
34
32
|
rescue FFI_Yajl::ParseError => e
|
35
33
|
raise Chef::Exceptions::JSON::ParseError, e.message
|
36
34
|
end
|
37
35
|
|
38
|
-
# Just call the JSON gem's parse method with a modified :max_nesting field
|
39
36
|
def from_json(source, opts = {})
|
40
37
|
obj = parse(source, opts)
|
41
38
|
|
@@ -56,10 +53,8 @@ class Chef
|
|
56
53
|
end
|
57
54
|
|
58
55
|
def to_json_pretty(obj, opts = nil)
|
59
|
-
|
60
|
-
options_map =
|
61
|
-
options_map[:pretty] = true
|
62
|
-
options_map[:indent] = opts[:indent] if opts.key?(:indent)
|
56
|
+
options_map = { pretty: true }
|
57
|
+
options_map[:indent] = opts[:indent] if opts.respond_to?(:key?) && opts.key?(:indent)
|
63
58
|
to_json(obj, options_map).chomp
|
64
59
|
end
|
65
60
|
|
data/lib/chef/key.rb
CHANGED
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
# Actor that the key is for, either a client or a user.
|
47
47
|
@actor = actor
|
48
48
|
|
49
|
-
unless
|
49
|
+
unless %w{user client}.include?(actor_field_name)
|
50
50
|
raise Chef::Exceptions::InvalidKeyArgument, "the second argument to initialize must be either 'user' or 'client'"
|
51
51
|
end
|
52
52
|
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -330,7 +330,7 @@ class Chef
|
|
330
330
|
long: "--bootstrap-vault-item VAULT_ITEM",
|
331
331
|
description: 'A single vault and item to update as "vault:item".',
|
332
332
|
proc: Proc.new { |i, accumulator|
|
333
|
-
(vault, item) = i.split(
|
333
|
+
(vault, item) = i.split(":")
|
334
334
|
accumulator ||= {}
|
335
335
|
accumulator[vault] ||= []
|
336
336
|
accumulator[vault].push(item)
|
@@ -407,6 +407,7 @@ class Chef
|
|
407
407
|
deps do
|
408
408
|
require "erubis" unless defined?(Erubis)
|
409
409
|
|
410
|
+
require "net/ssh" unless defined?(Net::SSH)
|
410
411
|
require_relative "../json_compat"
|
411
412
|
require_relative "../util/path_helper"
|
412
413
|
require_relative "bootstrap/chef_vault_handler"
|
@@ -230,9 +230,9 @@ echo Writing validation key...
|
|
230
230
|
echo Validation key written.
|
231
231
|
@echo on
|
232
232
|
|
233
|
-
<% if
|
233
|
+
<% if secret -%>
|
234
234
|
> <%= bootstrap_directory %>\encrypted_data_bag_secret (
|
235
|
-
<%=
|
235
|
+
<%= encrypted_data_bag_secret %>
|
236
236
|
)
|
237
237
|
<% end -%>
|
238
238
|
|
@@ -285,7 +285,7 @@ class Chef
|
|
285
285
|
# Train.unpack_target_from_uri only works for complete URIs in
|
286
286
|
# form of proto://[user[:pass]@]host[:port]/
|
287
287
|
# So we'll add the protocol prefix if it's not supplied.
|
288
|
-
uri_to_check = if URI.
|
288
|
+
uri_to_check = if URI::DEFAULT_PARSER.make_regexp.match(uri)
|
289
289
|
uri
|
290
290
|
else
|
291
291
|
"#{default_protocol}://#{uri}"
|
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
class Knife
|
23
23
|
class SubcommandLoader
|
24
24
|
class GemGlobLoader < Chef::Knife::SubcommandLoader
|
25
|
-
MATCHES_CHEF_GEM ||= %r{/chef
|
25
|
+
MATCHES_CHEF_GEM ||= %r{/chef-\d+\.\d+\.\d+}.freeze
|
26
26
|
MATCHES_THIS_CHEF_GEM ||= %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/}.freeze
|
27
27
|
|
28
28
|
def subcommand_files
|
data/lib/chef/knife/core/ui.rb
CHANGED
@@ -64,13 +64,16 @@ class Chef
|
|
64
64
|
# Creates a new object of class TTY::Prompt
|
65
65
|
# with interrupt as exit so that it can be terminated with status code.
|
66
66
|
def prompt
|
67
|
-
@prompt ||=
|
67
|
+
@prompt ||= begin
|
68
|
+
require "tty-prompt"
|
69
|
+
TTY::Prompt.new(interrupt: :exit)
|
70
|
+
end
|
68
71
|
end
|
69
72
|
|
70
73
|
# pastel.decorate is a lightweight replacement for highline.color
|
71
74
|
def pastel
|
72
75
|
@pastel ||= begin
|
73
|
-
require "pastel"
|
76
|
+
require "pastel" unless defined?(Pastel)
|
74
77
|
Pastel.new
|
75
78
|
end
|
76
79
|
end
|
@@ -32,6 +32,7 @@ class Chef
|
|
32
32
|
class WindowsBootstrapContext < BootstrapContext
|
33
33
|
attr_accessor :config
|
34
34
|
attr_accessor :chef_config
|
35
|
+
attr_accessor :secret
|
35
36
|
|
36
37
|
def initialize(config, run_list, chef_config, secret = nil)
|
37
38
|
@config = config
|
@@ -49,8 +50,8 @@ class Chef
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
-
escape_and_echo(
|
53
|
+
def encrypted_data_bag_secret
|
54
|
+
escape_and_echo(@secret)
|
54
55
|
end
|
55
56
|
|
56
57
|
def trusted_certs_script
|
@@ -134,8 +135,8 @@ class Chef
|
|
134
135
|
client_rb << %Q{no_proxy "#{config[:bootstrap_no_proxy]}"\n}
|
135
136
|
end
|
136
137
|
|
137
|
-
if
|
138
|
-
client_rb << %Q{encrypted_data_bag_secret "#{ChefConfig::Config.etc_chef_dir(windows: true)}
|
138
|
+
if secret
|
139
|
+
client_rb << %Q{encrypted_data_bag_secret "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.etc_chef_dir(windows: true))}\\\\encrypted_data_bag_secret"\n}
|
139
140
|
end
|
140
141
|
|
141
142
|
unless trusted_certs_script.empty?
|
@@ -255,6 +256,8 @@ class Chef
|
|
255
256
|
[String] $localPath
|
256
257
|
)
|
257
258
|
|
259
|
+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
260
|
+
|
258
261
|
$ProxyUrl = $env:http_proxy;
|
259
262
|
$webClient = new-object System.Net.WebClient;
|
260
263
|
|