chef 12.13.37-universal-mingw32 → 12.14.60-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +48 -95
- data/Gemfile +6 -1
- data/README.md +9 -11
- data/VERSION +1 -1
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
- data/acceptance/Gemfile +4 -7
- data/acceptance/Gemfile.lock +59 -92
- data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
- data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
- data/chef.gemspec +3 -2
- data/lib/chef/application/client.rb +4 -4
- data/lib/chef/application/solo.rb +2 -2
- data/lib/chef/chef_fs/command_line.rb +36 -34
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +139 -137
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
- data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +3 -3
- data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -6
- data/lib/chef/dsl/powershell.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_cache.rb +1 -1
- data/lib/chef/formatters/base.rb +2 -2
- data/lib/chef/formatters/doc.rb +2 -2
- data/lib/chef/http.rb +48 -18
- data/lib/chef/http/auth_credentials.rb +1 -1
- data/lib/chef/http/basic_client.rb +11 -2
- data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
- data/lib/chef/key.rb +55 -56
- data/lib/chef/knife.rb +70 -61
- data/lib/chef/knife/client_delete.rb +2 -2
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_show.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +19 -21
- data/lib/chef/knife/status.rb +2 -2
- data/lib/chef/mixin/command/unix.rb +2 -2
- data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
- data/lib/chef/mixin/properties.rb +3 -0
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +30 -0
- data/lib/chef/mixin/uris.rb +2 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
- data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
- data/lib/chef/monologger.rb +1 -1
- data/lib/chef/node.rb +2 -2
- data/lib/chef/node/attribute.rb +3 -3
- data/lib/chef/platform/provider_mapping.rb +5 -2
- data/lib/chef/property.rb +14 -3
- data/lib/chef/provider/apt_repository.rb +3 -7
- data/lib/chef/provider/apt_update.rb +4 -6
- data/lib/chef/provider/cron.rb +1 -2
- data/lib/chef/provider/dsc_script.rb +4 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/link.rb +10 -3
- data/lib/chef/provider/osx_profile.rb +10 -10
- data/lib/chef/provider/package.rb +2 -12
- data/lib/chef/provider/package/rubygems.rb +17 -16
- data/lib/chef/provider/package/windows.rb +2 -0
- data/lib/chef/provider/package/windows/exe.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
- data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/remote_file/ftp.rb +2 -2
- data/lib/chef/provider/remote_file/sftp.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/simple.rb +4 -3
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +8 -5
- data/lib/chef/provider/support/yum_repo.erb +125 -0
- data/lib/chef/provider/systemd_unit.rb +11 -2
- data/lib/chef/provider/template_finder.rb +1 -1
- data/lib/chef/provider/user.rb +20 -16
- data/lib/chef/provider/user/aix.rb +5 -2
- data/lib/chef/provider/user/dscl.rb +1 -0
- data/lib/chef/provider/user/linux.rb +128 -0
- data/lib/chef/provider/user/pw.rb +2 -1
- data/lib/chef/provider/user/solaris.rb +3 -2
- data/lib/chef/provider/user/useradd.rb +5 -4
- data/lib/chef/provider/user/windows.rb +1 -1
- data/lib/chef/provider/windows_script.rb +5 -2
- data/lib/chef/provider/yum_repository.rb +121 -0
- data/lib/chef/providers.rb +4 -2
- data/lib/chef/resource.rb +7 -9
- data/lib/chef/resource/conditional.rb +9 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/user.rb +3 -3
- data/lib/chef/resource/user/aix_user.rb +31 -0
- data/lib/chef/resource/user/dscl_user.rb +31 -0
- data/lib/chef/resource/user/linux_user.rb +51 -0
- data/lib/chef/resource/user/pw_user.rb +31 -0
- data/lib/chef/resource/user/solaris_user.rb +31 -0
- data/lib/chef/resource/user/windows_user.rb +31 -0
- data/lib/chef/resource/yum_package.rb +13 -12
- data/lib/chef/resource/yum_repository.rb +76 -0
- data/lib/chef/resource_builder.rb +1 -1
- data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
- data/lib/chef/resource_reporter.rb +5 -5
- data/lib/chef/resources.rb +7 -0
- data/lib/chef/run_context.rb +5 -3
- data/lib/chef/run_context/cookbook_compiler.rb +3 -2
- data/lib/chef/run_list.rb +2 -2
- data/lib/chef/search/query.rb +11 -8
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +5 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +2 -2
- data/lib/chef/version_constraint.rb +2 -2
- data/lib/chef/win32/api/error.rb +2 -2
- data/lib/chef/win32/api/net.rb +1 -1
- data/lib/chef/win32/eventlog.rb +1 -1
- data/lib/chef/win32/net.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/spec/functional/assets/testchefsubsys +2 -3
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
- data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
- data/spec/functional/http/simple_spec.rb +2 -2
- data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
- data/spec/functional/knife/exec_spec.rb +6 -6
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/notifications_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +5 -5
- data/spec/functional/resource/bash_spec.rb +2 -2
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dpkg_package_spec.rb +2 -2
- data/spec/functional/resource/dsc_resource_spec.rb +5 -5
- data/spec/functional/resource/dsc_script_spec.rb +27 -22
- data/spec/functional/resource/env_spec.rb +4 -4
- data/spec/functional/resource/execute_spec.rb +4 -4
- data/spec/functional/resource/group_spec.rb +20 -8
- data/spec/functional/resource/link_spec.rb +34 -0
- data/spec/functional/resource/ohai_spec.rb +6 -6
- data/spec/functional/resource/reboot_spec.rb +2 -2
- data/spec/functional/resource/remote_file_spec.rb +16 -7
- data/spec/functional/resource/user/dscl_spec.rb +3 -3
- data/spec/functional/resource/user/useradd_spec.rb +32 -26
- data/spec/functional/resource/windows_service_spec.rb +15 -15
- data/spec/functional/rest_spec.rb +2 -2
- data/spec/functional/run_lock_spec.rb +9 -9
- data/spec/functional/tiny_server_spec.rb +9 -8
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +8 -8
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
- data/spec/integration/recipes/noop_resource_spec.rb +4 -4
- data/spec/integration/recipes/provider_choice.rb +3 -3
- data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
- data/spec/integration/recipes/resource_action_spec.rb +50 -54
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
- data/spec/integration/recipes/resource_load_spec.rb +24 -24
- data/spec/integration/solo/solo_spec.rb +21 -30
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/stress/win32/security_spec.rb +4 -4
- data/spec/support/chef_helpers.rb +22 -0
- data/spec/support/platform_helpers.rb +5 -1
- data/spec/support/shared/context/client.rb +3 -2
- data/spec/support/shared/functional/file_resource.rb +5 -4
- data/spec/support/shared/functional/http.rb +16 -16
- data/spec/support/shared/functional/securable_resource.rb +5 -5
- data/spec/support/shared/functional/win32_service.rb +5 -7
- data/spec/support/shared/integration/app_server_support.rb +1 -3
- data/spec/support/shared/integration/knife_support.rb +0 -2
- data/spec/support/shared/shared_examples.rb +2 -2
- data/spec/support/shared/unit/api_versioning.rb +2 -2
- data/spec/support/shared/unit/application_dot_d.rb +9 -6
- data/spec/support/shared/unit/provider/file.rb +2 -2
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
- data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
- data/spec/support/shared/unit/script_resource.rb +4 -4
- data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
- data/spec/tiny_server.rb +51 -66
- data/spec/unit/api_client_v1_spec.rb +2 -2
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
- data/spec/unit/audit/audit_reporter_spec.rb +32 -23
- data/spec/unit/audit/control_group_data_spec.rb +19 -14
- data/spec/unit/chef_class_spec.rb +1 -1
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system_spec.rb +2 -2
- data/spec/unit/chef_fs/parallelizer.rb +5 -7
- data/spec/unit/cookbook/metadata_spec.rb +98 -98
- data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
- data/spec/unit/cookbook_loader_spec.rb +24 -24
- data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/data_bag_item_spec.rb +18 -18
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
- data/spec/unit/data_collector/messages_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +19 -19
- data/spec/unit/dsl/audit_spec.rb +3 -3
- data/spec/unit/dsl/data_query_spec.rb +3 -2
- data/spec/unit/dsl/declare_resource_spec.rb +10 -10
- data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
- data/spec/unit/environment_spec.rb +6 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
- data/spec/unit/file_access_control_spec.rb +3 -3
- data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
- data/spec/unit/http/basic_client_spec.rb +20 -0
- data/spec/unit/http/validate_content_length_spec.rb +8 -8
- data/spec/unit/http_spec.rb +14 -0
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
- data/spec/unit/knife/bootstrap_spec.rb +8 -6
- data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
- data/spec/unit/knife/client_edit_spec.rb +2 -2
- data/spec/unit/knife/configure_client_spec.rb +2 -2
- data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
- data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
- data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
- data/spec/unit/knife/core/node_editor_spec.rb +3 -3
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
- data/spec/unit/knife/data_bag_show_spec.rb +3 -2
- data/spec/unit/knife/key_create_spec.rb +14 -14
- data/spec/unit/knife/key_delete_spec.rb +2 -2
- data/spec/unit/knife/key_edit_spec.rb +16 -16
- data/spec/unit/knife/key_list_spec.rb +6 -6
- data/spec/unit/knife/key_show_spec.rb +4 -4
- data/spec/unit/knife/status_spec.rb +3 -2
- data/spec/unit/knife/user_create_spec.rb +4 -4
- data/spec/unit/knife_spec.rb +7 -6
- data/spec/unit/lwrp_spec.rb +6 -6
- data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
- data/spec/unit/mixin/command_spec.rb +17 -14
- data/spec/unit/mixin/deprecation_spec.rb +1 -1
- data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
- data/spec/unit/mixin/params_validate_spec.rb +53 -52
- data/spec/unit/mixin/powershell_out_spec.rb +2 -2
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
- data/spec/unit/mixin/shell_out_spec.rb +1 -1
- data/spec/unit/mixin/xml_escape_spec.rb +3 -3
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/platform/query_helpers_spec.rb +3 -3
- data/spec/unit/property_spec.rb +4 -4
- data/spec/unit/provider/cookbook_file_spec.rb +4 -4
- data/spec/unit/provider/cron/unix_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +2 -2
- data/spec/unit/provider/deploy_spec.rb +8 -8
- data/spec/unit/provider/dsc_resource_spec.rb +11 -10
- data/spec/unit/provider/dsc_script_spec.rb +9 -9
- data/spec/unit/provider/env/windows_spec.rb +8 -8
- data/spec/unit/provider/file/content_spec.rb +6 -6
- data/spec/unit/provider/file_spec.rb +4 -4
- data/spec/unit/provider/launchd_spec.rb +2 -1
- data/spec/unit/provider/link_spec.rb +155 -0
- data/spec/unit/provider/mount/mount_spec.rb +5 -5
- data/spec/unit/provider/mount/solaris_spec.rb +48 -48
- data/spec/unit/provider/osx_profile_spec.rb +6 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
- data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
- data/spec/unit/provider/package/rubygems_spec.rb +50 -44
- data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
- data/spec/unit/provider/package/yum_spec.rb +61 -60
- data/spec/unit/provider/package_spec.rb +2 -2
- data/spec/unit/provider/powershell_script_spec.rb +4 -4
- data/spec/unit/provider/remote_directory_spec.rb +1 -1
- data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
- data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file_spec.rb +4 -4
- data/spec/unit/provider/script_spec.rb +4 -4
- data/spec/unit/provider/service/debian_service_spec.rb +4 -4
- data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
- data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
- data/spec/unit/provider/service/windows_spec.rb +10 -10
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/template/content_spec.rb +8 -8
- data/spec/unit/provider/template_spec.rb +8 -8
- data/spec/unit/provider/user/dscl_spec.rb +51 -51
- data/spec/unit/provider/user/linux_spec.rb +76 -0
- data/spec/unit/provider/user/pw_spec.rb +3 -6
- data/spec/unit/provider/user/solaris_spec.rb +5 -5
- data/spec/unit/provider/user/windows_spec.rb +3 -3
- data/spec/unit/provider/user_spec.rb +2 -2
- data/spec/unit/provider/yum_repository_spec.rb +35 -0
- data/spec/unit/provider_resolver_spec.rb +306 -264
- data/spec/unit/recipe_spec.rb +8 -7
- data/spec/unit/resource/apt_repository_spec.rb +4 -4
- data/spec/unit/resource/apt_update_spec.rb +4 -4
- data/spec/unit/resource/conditional_spec.rb +46 -0
- data/spec/unit/resource/dsc_resource_spec.rb +8 -8
- data/spec/unit/resource/dsc_script_spec.rb +4 -4
- data/spec/unit/resource/freebsd_package_spec.rb +6 -6
- data/spec/unit/resource/launchd_spec.rb +3 -2
- data/spec/unit/resource/osx_profile_spec.rb +3 -2
- data/spec/unit/resource/remote_file_spec.rb +6 -6
- data/spec/unit/resource/service_spec.rb +14 -14
- data/spec/unit/resource/user_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +49 -0
- data/spec/unit/resource_collection_spec.rb +4 -4
- data/spec/unit/resource_definition_spec.rb +11 -11
- data/spec/unit/resource_reporter_spec.rb +4 -4
- data/spec/unit/resource_resolver_spec.rb +6 -6
- data/spec/unit/resource_spec.rb +36 -16
- data/spec/unit/run_context/child_run_context_spec.rb +4 -4
- data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
- data/spec/unit/run_context_spec.rb +8 -8
- data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/search/query_spec.rb +15 -14
- data/spec/unit/user_v1_spec.rb +8 -8
- data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
- data/spec/unit/util/dsc/resource_store.rb +8 -6
- data/spec/unit/util/editor_spec.rb +6 -6
- data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
- data/tasks/bin/bundle-platform +1 -0
- data/tasks/bin/bundler_patch.rb +27 -0
- data/tasks/cbgb.rb +2 -2
- data/tasks/maintainers.rb +2 -2
- metadata +37 -8
- data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -49,7 +49,7 @@ class Chef
|
|
49
49
|
|
50
50
|
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(request_params)
|
51
51
|
signed = sign_obj.sign(key).merge({ :host => host })
|
52
|
-
signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1];memo }
|
52
|
+
signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1]; memo }
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -34,6 +34,7 @@ class Chef
|
|
34
34
|
attr_reader :url
|
35
35
|
attr_reader :http_client
|
36
36
|
attr_reader :ssl_policy
|
37
|
+
attr_reader :keepalives
|
37
38
|
|
38
39
|
# Instantiate a BasicClient.
|
39
40
|
# === Arguments:
|
@@ -43,7 +44,11 @@ class Chef
|
|
43
44
|
def initialize(url, opts = {})
|
44
45
|
@url = url
|
45
46
|
@ssl_policy = opts[:ssl_policy] || DefaultSSLPolicy
|
46
|
-
@
|
47
|
+
@keepalives = opts[:keepalives] || false
|
48
|
+
end
|
49
|
+
|
50
|
+
def http_client
|
51
|
+
@http_client ||= build_http_client
|
47
52
|
end
|
48
53
|
|
49
54
|
def host
|
@@ -114,7 +119,11 @@ class Chef
|
|
114
119
|
|
115
120
|
http_client.read_timeout = config[:rest_timeout]
|
116
121
|
http_client.open_timeout = config[:rest_timeout]
|
117
|
-
|
122
|
+
if keepalives
|
123
|
+
http_client.start
|
124
|
+
else
|
125
|
+
http_client
|
126
|
+
end
|
118
127
|
end
|
119
128
|
|
120
129
|
def config
|
@@ -197,9 +197,9 @@ class Chef
|
|
197
197
|
private
|
198
198
|
|
199
199
|
def headers_extracted_from_options
|
200
|
-
options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map
|
200
|
+
options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map do |name, value|
|
201
201
|
[name.to_s.split("_").map { |segment| segment.capitalize }.join("-"), value]
|
202
|
-
|
202
|
+
end
|
203
203
|
end
|
204
204
|
|
205
205
|
end
|
data/lib/chef/key.rb
CHANGED
@@ -201,72 +201,71 @@ class Chef
|
|
201
201
|
chef_rest.delete("#{api_base}/#{@actor}/keys/#{@name}")
|
202
202
|
end
|
203
203
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
204
|
+
class << self
|
205
|
+
def from_hash(key_hash)
|
206
|
+
if key_hash.has_key?("user")
|
207
|
+
key = Chef::Key.new(key_hash["user"], "user")
|
208
|
+
elsif key_hash.has_key?("client")
|
209
|
+
key = Chef::Key.new(key_hash["client"], "client")
|
210
|
+
else
|
211
|
+
raise Chef::Exceptions::MissingKeyAttribute, "The hash passed to from_hash does not contain the key 'user' or 'client'. Please pass a hash that defines one of those keys."
|
212
|
+
end
|
213
|
+
key.name key_hash["name"] if key_hash.key?("name")
|
214
|
+
key.public_key key_hash["public_key"] if key_hash.key?("public_key")
|
215
|
+
key.private_key key_hash["private_key"] if key_hash.key?("private_key")
|
216
|
+
key.create_key key_hash["create_key"] if key_hash.key?("create_key")
|
217
|
+
key.expiration_date key_hash["expiration_date"] if key_hash.key?("expiration_date")
|
218
|
+
key
|
212
219
|
end
|
213
|
-
key.name key_hash["name"] if key_hash.key?("name")
|
214
|
-
key.public_key key_hash["public_key"] if key_hash.key?("public_key")
|
215
|
-
key.private_key key_hash["private_key"] if key_hash.key?("private_key")
|
216
|
-
key.create_key key_hash["create_key"] if key_hash.key?("create_key")
|
217
|
-
key.expiration_date key_hash["expiration_date"] if key_hash.key?("expiration_date")
|
218
|
-
key
|
219
|
-
end
|
220
|
-
|
221
|
-
def self.from_json(json)
|
222
|
-
Chef::Key.from_hash(Chef::JSONCompat.from_json(json))
|
223
|
-
end
|
224
220
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
end
|
221
|
+
def from_json(json)
|
222
|
+
Chef::Key.from_hash(Chef::JSONCompat.from_json(json))
|
223
|
+
end
|
229
224
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
225
|
+
def json_create(json)
|
226
|
+
Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.")
|
227
|
+
Chef::Key.from_json(json)
|
228
|
+
end
|
234
229
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
230
|
+
def list_by_user(actor, inflate = false)
|
231
|
+
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys")
|
232
|
+
self.list(keys, actor, :load_by_user, inflate)
|
233
|
+
end
|
239
234
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
235
|
+
def list_by_client(actor, inflate = false)
|
236
|
+
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys")
|
237
|
+
self.list(keys, actor, :load_by_client, inflate)
|
238
|
+
end
|
244
239
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
240
|
+
def load_by_user(actor, key_name)
|
241
|
+
response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys/#{key_name}")
|
242
|
+
Chef::Key.from_hash(response.merge({ "user" => actor }))
|
243
|
+
end
|
249
244
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.e),
|
255
|
-
])
|
256
|
-
OpenSSL::Digest::SHA1.hexdigest(data_string.to_der).scan(/../).join(":")
|
257
|
-
end
|
245
|
+
def load_by_client(actor, key_name)
|
246
|
+
response = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys/#{key_name}")
|
247
|
+
Chef::Key.from_hash(response.merge({ "client" => actor }))
|
248
|
+
end
|
258
249
|
|
259
|
-
|
250
|
+
def generate_fingerprint(public_key)
|
251
|
+
openssl_key_object = OpenSSL::PKey::RSA.new(public_key)
|
252
|
+
data_string = OpenSSL::ASN1::Sequence([
|
253
|
+
OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.n),
|
254
|
+
OpenSSL::ASN1::Integer.new(openssl_key_object.public_key.e),
|
255
|
+
])
|
256
|
+
OpenSSL::Digest::SHA1.hexdigest(data_string.to_der).scan(/../).join(":")
|
257
|
+
end
|
260
258
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
259
|
+
def list(keys, actor, load_method_symbol, inflate)
|
260
|
+
if inflate
|
261
|
+
keys.inject({}) do |key_map, result|
|
262
|
+
name = result["name"]
|
263
|
+
key_map[name] = Chef::Key.send(load_method_symbol, actor, name)
|
264
|
+
key_map
|
265
|
+
end
|
266
|
+
else
|
267
|
+
keys
|
267
268
|
end
|
268
|
-
else
|
269
|
-
keys
|
270
269
|
end
|
271
270
|
end
|
272
271
|
end
|
data/lib/chef/knife.rb
CHANGED
@@ -233,61 +233,66 @@ class Chef
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
-
private
|
237
|
-
|
238
236
|
OFFICIAL_PLUGINS = %w{ec2 rackspace windows openstack terremark bluebox}
|
239
237
|
|
240
|
-
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
# :nodoc:
|
245
|
-
# Error out and print usage. probably because the arguments given by the
|
246
|
-
# user could not be resolved to a subcommand.
|
247
|
-
def self.subcommand_not_found!(args)
|
248
|
-
ui.fatal("Cannot find subcommand for: '#{args.join(' ')}'")
|
238
|
+
class << self
|
239
|
+
private
|
249
240
|
|
250
|
-
#
|
251
|
-
|
252
|
-
|
253
|
-
ui.info("If this is a recently installed plugin, please run 'knife rehash' to update the subcommands cache.")
|
241
|
+
# @api private
|
242
|
+
def path_from_caller(caller_line)
|
243
|
+
caller_line.split(/:\d+/).first
|
254
244
|
end
|
255
245
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
ui.
|
262
|
-
|
263
|
-
|
264
|
-
|
246
|
+
# :nodoc:
|
247
|
+
# Error out and print usage. probably because the arguments given by the
|
248
|
+
# user could not be resolved to a subcommand.
|
249
|
+
# @api private
|
250
|
+
def subcommand_not_found!(args)
|
251
|
+
ui.fatal("Cannot find subcommand for: '#{args.join(' ')}'")
|
252
|
+
|
253
|
+
# Mention rehash when the subcommands cache(plugin_manifest.json) is used
|
254
|
+
if subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::HashedCommandLoader) ||
|
255
|
+
subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::CustomManifestLoader)
|
256
|
+
ui.info("If this is a recently installed plugin, please run 'knife rehash' to update the subcommands cache.")
|
257
|
+
end
|
265
258
|
|
266
|
-
|
267
|
-
|
259
|
+
if category_commands = guess_category(args)
|
260
|
+
list_commands(category_commands)
|
261
|
+
elsif missing_plugin = ( OFFICIAL_PLUGINS.find { |plugin| plugin == args[0] } )
|
262
|
+
ui.info("The #{missing_plugin} commands were moved to plugins in Chef 0.10")
|
263
|
+
ui.info("You can install the plugin with `(sudo) gem install knife-#{missing_plugin}`")
|
264
|
+
ui.info("Use `chef gem install knife-#{missing_plugin}` instead if using ChefDK")
|
265
|
+
else
|
266
|
+
list_commands
|
267
|
+
end
|
268
|
+
|
269
|
+
exit 10
|
270
|
+
end
|
268
271
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
272
|
+
# @api private
|
273
|
+
def list_commands(preferred_category = nil)
|
274
|
+
category_desc = preferred_category ? preferred_category + " " : ""
|
275
|
+
msg "Available #{category_desc}subcommands: (for details, knife SUB-COMMAND --help)\n\n"
|
276
|
+
subcommand_loader.list_commands(preferred_category).sort.each do |category, commands|
|
277
|
+
next if category =~ /deprecated/i
|
278
|
+
msg "** #{category.upcase} COMMANDS **"
|
279
|
+
commands.sort.each do |command|
|
280
|
+
subcommand_loader.load_command(command)
|
281
|
+
msg subcommands[command].banner if subcommands[command]
|
282
|
+
end
|
283
|
+
msg
|
278
284
|
end
|
279
|
-
msg
|
280
285
|
end
|
281
|
-
end
|
282
286
|
|
283
|
-
|
284
|
-
|
287
|
+
# @api private
|
288
|
+
def reset_config_path!
|
289
|
+
@@chef_config_dir = nil
|
290
|
+
end
|
291
|
+
|
285
292
|
end
|
286
293
|
|
287
294
|
reset_config_path!
|
288
295
|
|
289
|
-
public
|
290
|
-
|
291
296
|
# Create a new instance of the current class configured for the given
|
292
297
|
# arguments and options
|
293
298
|
def initialize(argv = [])
|
@@ -324,31 +329,35 @@ class Chef
|
|
324
329
|
exit(1)
|
325
330
|
end
|
326
331
|
|
327
|
-
#
|
328
|
-
|
329
|
-
|
332
|
+
# keys from mixlib-cli options
|
333
|
+
def cli_keys
|
334
|
+
self.class.options.keys
|
335
|
+
end
|
336
|
+
|
337
|
+
# extracts the settings from the Chef::Config[:knife] sub-hash that correspond
|
338
|
+
# to knife cli options -- in preparation for merging config values with cli values
|
339
|
+
#
|
340
|
+
# NOTE: due to weirdness in mixlib-config #has_key? is only true if the value has
|
341
|
+
# been set by the user -- the Chef::Config defaults return #has_key?() of false and
|
342
|
+
# this code DEPENDS on that functionality since applying the default values in
|
343
|
+
# Chef::Config[:knife] would break the defaults in the cli that we would otherwise
|
344
|
+
# overwrite.
|
330
345
|
def config_file_settings
|
331
|
-
|
332
|
-
|
333
|
-
config_file_settings[key] = Chef::Config[:knife][key] if Chef::Config[:knife].has_key?(key)
|
346
|
+
cli_keys.each_with_object({}) do |key, memo|
|
347
|
+
memo[key] = Chef::Config[:knife][key] if Chef::Config[:knife].has_key?(key)
|
334
348
|
end
|
335
|
-
config_file_settings
|
336
349
|
end
|
337
350
|
|
338
|
-
#
|
339
|
-
# defaults from
|
340
|
-
#
|
341
|
-
#
|
351
|
+
# config is merged in this order (inverse of precedence)
|
352
|
+
# default_config - mixlib-cli defaults (accessor from the mixin)
|
353
|
+
# config_file_settings - Chef::Config[:knife] sub-hash
|
354
|
+
# config - mixlib-cli settings (accessor from the mixin)
|
342
355
|
def merge_configs
|
343
|
-
#
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
# Need to use the mutate-in-place #replace method instead of assigning to
|
349
|
-
# the instance variable because other code may have a reference to the
|
350
|
-
# original config hash object.
|
351
|
-
config.replace(combined_config)
|
356
|
+
# other code may have a handle to the config object, so use Hash#replace to deliberately
|
357
|
+
# update-in-place.
|
358
|
+
config.replace(
|
359
|
+
default_config.merge(config_file_settings).merge(config)
|
360
|
+
)
|
352
361
|
end
|
353
362
|
|
354
363
|
# Catch-all method that does any massaging needed for various config
|
@@ -43,7 +43,7 @@ class Chef
|
|
43
43
|
exit 1
|
44
44
|
end
|
45
45
|
|
46
|
-
delete_object(Chef::ApiClientV1, @client_name, "client")
|
46
|
+
delete_object(Chef::ApiClientV1, @client_name, "client") do
|
47
47
|
object = Chef::ApiClientV1.load(@client_name)
|
48
48
|
if object.validator
|
49
49
|
unless config[:delete_validators]
|
@@ -52,7 +52,7 @@ class Chef
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
object.destroy
|
55
|
-
|
55
|
+
end
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
@@ -42,7 +42,7 @@ class Chef
|
|
42
42
|
|
43
43
|
all_cookbooks = Chef::CookbookVersion.list
|
44
44
|
cookbooks_names = all_cookbooks.keys.grep(regex)
|
45
|
-
cookbooks_to_delete = cookbooks_names.inject({}) { |hash, name| hash[name] = all_cookbooks[name];hash }
|
45
|
+
cookbooks_to_delete = cookbooks_names.inject({}) { |hash, name| hash[name] = all_cookbooks[name]; hash }
|
46
46
|
ui.msg "All versions of the following cookbooks will be deleted:"
|
47
47
|
ui.msg ""
|
48
48
|
ui.msg ui.list(cookbooks_to_delete.keys.sort, :columns_down)
|
@@ -81,9 +81,9 @@ class Chef
|
|
81
81
|
files = []
|
82
82
|
|
83
83
|
if check_load_path
|
84
|
-
files = $LOAD_PATH.map
|
84
|
+
files = $LOAD_PATH.map do |load_path|
|
85
85
|
Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"]
|
86
|
-
|
86
|
+
end.flatten.select { |file| File.file? file.untaint }
|
87
87
|
end
|
88
88
|
|
89
89
|
gem_files = latest_gem_specs.map do |spec|
|
@@ -110,7 +110,7 @@ class Chef
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def check_spec_for_glob(spec, glob)
|
113
|
-
dirs = if spec.require_paths.size > 1
|
113
|
+
dirs = if spec.require_paths.size > 1
|
114
114
|
"{#{spec.require_paths.join(',')}}"
|
115
115
|
else
|
116
116
|
spec.require_paths.first
|
data/lib/chef/knife/search.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
require "chef/knife"
|
20
20
|
require "chef/knife/core/node_presenter"
|
21
|
+
require "addressable/uri"
|
21
22
|
|
22
23
|
class Chef
|
23
24
|
class Knife
|
@@ -85,8 +86,7 @@ class Chef
|
|
85
86
|
end
|
86
87
|
|
87
88
|
q = Chef::Search::Query.new
|
88
|
-
escaped_query = URI.
|
89
|
-
Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
89
|
+
escaped_query = Addressable::URI.encode_component(@query, Addressable::URI::CharacterClasses::QUERY)
|
90
90
|
|
91
91
|
result_items = []
|
92
92
|
result_count = 0
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -164,9 +164,7 @@ class Chef
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def configure_session
|
167
|
-
list = config[:manual] ?
|
168
|
-
@name_args[0].split(" ") :
|
169
|
-
search_nodes
|
167
|
+
list = config[:manual] ? @name_args[0].split(" ") : search_nodes
|
170
168
|
if list.length == 0
|
171
169
|
if @action_nodes.length == 0
|
172
170
|
ui.fatal("No nodes returned from search")
|
@@ -548,24 +546,24 @@ class Chef
|
|
548
546
|
configure_session
|
549
547
|
|
550
548
|
exit_status =
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
549
|
+
case @name_args[1]
|
550
|
+
when "interactive"
|
551
|
+
interactive
|
552
|
+
when "screen"
|
553
|
+
screen
|
554
|
+
when "tmux"
|
555
|
+
tmux
|
556
|
+
when "macterm"
|
557
|
+
macterm
|
558
|
+
when "cssh"
|
559
|
+
cssh
|
560
|
+
when "csshx"
|
561
|
+
Chef::Log.warn("knife ssh csshx will be deprecated in a future release")
|
562
|
+
Chef::Log.warn("please use knife ssh cssh instead")
|
563
|
+
cssh
|
564
|
+
else
|
565
|
+
ssh_command(@name_args[1..-1].join(" "))
|
566
|
+
end
|
569
567
|
|
570
568
|
session.close
|
571
569
|
if exit_status != 0
|