chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -4
- data/README.md +12 -13
- data/VERSION +1 -1
- data/acceptance/Gemfile +4 -4
- data/acceptance/Gemfile.lock +70 -69
- data/chef-universal-mingw32.gemspec +2 -3
- data/chef.gemspec +6 -6
- data/lib/chef/api_client.rb +8 -10
- data/lib/chef/api_client_v1.rb +9 -11
- data/lib/chef/application/apply.rb +8 -10
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service.rb +29 -30
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/audit/audit_event_proxy.rb +2 -2
- data/lib/chef/audit/control_group_data.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
- data/lib/chef/chef_fs/command_line.rb +15 -16
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
- data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
- data/lib/chef/chef_fs/parallelizer.rb +9 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
- data/lib/chef/cookbook/metadata.rb +26 -26
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +3 -3
- data/lib/chef/data_collector.rb +3 -4
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/audit.rb +2 -2
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +29 -31
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/resources.rb +6 -8
- data/lib/chef/encrypted_data_bag_item.rb +2 -2
- data/lib/chef/environment.rb +9 -11
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_access_control/unix.rb +14 -14
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
- data/lib/chef/formatters/error_mapper.rb +6 -6
- data/lib/chef/http/api_versions.rb +50 -0
- data/lib/chef/http/validate_content_length.rb +2 -2
- data/lib/chef/json_compat.rb +6 -10
- data/lib/chef/key.rb +5 -5
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/ui.rb +19 -25
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/deps.rb +32 -34
- data/lib/chef/knife/help.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +37 -27
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/user_delete.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/command.rb +2 -2
- data/lib/chef/mixin/create_path.rb +3 -5
- data/lib/chef/mixin/from_file.rb +2 -2
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/notifying_block.rb +7 -9
- data/lib/chef/mixin/params_validate.rb +3 -3
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +23 -3
- data/lib/chef/mixin/unformatter.rb +2 -2
- data/lib/chef/mixin/uris.rb +4 -6
- data/lib/chef/mixin/versioned_api.rb +69 -0
- data/lib/chef/mixin/which.rb +25 -8
- data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
- data/lib/chef/mixin/xml_escape.rb +3 -5
- data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
- data/lib/chef/node.rb +8 -8
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/node/common_api.rb +5 -7
- data/lib/chef/org.rb +10 -12
- data/lib/chef/platform/provider_mapping.rb +7 -7
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +31 -0
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/breakpoint.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +3 -3
- data/lib/chef/provider/cron.rb +38 -38
- data/lib/chef/provider/deploy.rb +81 -81
- data/lib/chef/provider/deploy/revision.rb +3 -5
- data/lib/chef/provider/directory.rb +32 -32
- data/lib/chef/provider/dsc_resource.rb +22 -6
- data/lib/chef/provider/env.rb +28 -28
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/erl_call.rb +13 -13
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +49 -51
- data/lib/chef/provider/git.rb +55 -55
- data/lib/chef/provider/http_request.rb +36 -36
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +50 -50
- data/lib/chef/provider/log.rb +2 -2
- data/lib/chef/provider/mdadm.rb +25 -25
- data/lib/chef/provider/mount/aix.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/ohai.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +23 -23
- data/lib/chef/provider/package.rb +74 -56
- data/lib/chef/provider/package/aix.rb +55 -52
- data/lib/chef/provider/package/apt.rb +15 -13
- data/lib/chef/provider/package/cab.rb +49 -20
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dnf.rb +20 -18
- data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +8 -9
- data/lib/chef/provider/package/easy_install.rb +22 -22
- data/lib/chef/provider/package/freebsd/base.rb +10 -10
- data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
- data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
- data/lib/chef/provider/package/freebsd/port.rb +7 -7
- data/lib/chef/provider/package/homebrew.rb +11 -10
- data/lib/chef/provider/package/ips.rb +18 -23
- data/lib/chef/provider/package/macports.rb +23 -23
- data/lib/chef/provider/package/msu.rb +11 -11
- data/lib/chef/provider/package/openbsd.rb +25 -22
- data/lib/chef/provider/package/pacman.rb +16 -16
- data/lib/chef/provider/package/paludis.rb +26 -27
- data/lib/chef/provider/package/portage.rb +22 -22
- data/lib/chef/provider/package/powershell.rb +17 -17
- data/lib/chef/provider/package/rpm.rb +25 -25
- data/lib/chef/provider/package/rubygems.rb +60 -60
- data/lib/chef/provider/package/smartos.rb +16 -16
- data/lib/chef/provider/package/solaris.rb +44 -44
- data/lib/chef/provider/package/windows.rb +3 -3
- data/lib/chef/provider/package/windows/exe.rb +6 -6
- data/lib/chef/provider/package/windows/msi.rb +6 -6
- data/lib/chef/provider/package/yum.rb +318 -268
- data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
- data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
- data/lib/chef/provider/package/zypper.rb +11 -11
- data/lib/chef/provider/powershell_script.rb +15 -7
- data/lib/chef/provider/reboot.rb +10 -10
- data/lib/chef/provider/registry_key.rb +39 -39
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file.rb +3 -3
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +42 -6
- data/lib/chef/provider/service.rb +49 -49
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +39 -39
- data/lib/chef/provider/systemd_unit.rb +2 -0
- data/lib/chef/provider/template.rb +3 -3
- data/lib/chef/provider/user.rb +42 -42
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
- data/lib/chef/resource.rb +27 -16
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +6 -3
- data/lib/chef/resource/dsc_resource.rb +9 -1
- data/lib/chef/resource/execute.rb +70 -6
- data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +13 -1
- data/lib/chef/resource/package.rb +2 -2
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/yum_package.rb +12 -3
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
- data/lib/chef/resource_collection/resource_set.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/run_list/run_list_item.rb +1 -1
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/server_api_versions.rb +40 -0
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/user.rb +9 -11
- data/lib/chef/user_v1.rb +9 -11
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +18 -30
- data/lib/chef/util/windows/net_use.rb +7 -11
- data/lib/chef/util/windows/net_user.rb +11 -17
- data/lib/chef/util/windows/volume.rb +9 -15
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/win32/api.rb +4 -6
- data/lib/chef/win32/api/file.rb +25 -31
- data/lib/chef/win32/api/installer.rb +2 -2
- data/lib/chef/win32/file.rb +4 -6
- data/lib/chef/win32/registry.rb +9 -9
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/acl.rb +2 -2
- data/lib/chef/win32/unicode.rb +2 -2
- data/lib/chef/win32/version.rb +1 -1
- data/spec/data/prefer_metadata_json/metadata.json +51 -0
- data/spec/data/prefer_metadata_json/metadata.rb +6 -0
- data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/resource/batch_spec.rb +5 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -4
- data/spec/functional/resource/execute_spec.rb +17 -0
- data/spec/functional/resource/user/dscl_spec.rb +2 -4
- data/spec/integration/client/client_spec.rb +33 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
- data/spec/spec_helper.rb +4 -0
- data/spec/support/chef_helpers.rb +5 -7
- data/spec/support/platform_helpers.rb +6 -0
- data/spec/support/platforms/prof/gc.rb +4 -6
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +150 -0
- data/spec/support/shared/functional/windows_script.rb +74 -4
- data/spec/support/shared/unit/execute_resource.rb +37 -0
- data/spec/support/shared/unit/provider/file.rb +10 -0
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/http/api_versions_spec.rb +69 -0
- data/spec/unit/knife/ssh_spec.rb +34 -36
- data/spec/unit/mixin/versioned_api_spec.rb +107 -0
- data/spec/unit/mixin/which.rb +160 -0
- data/spec/unit/platform_spec.rb +28 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +10 -0
- data/spec/unit/provider/dsc_resource_spec.rb +175 -0
- data/spec/unit/provider/execute_spec.rb +0 -1
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +22 -22
- data/spec/unit/provider/package/apt_spec.rb +27 -27
- data/spec/unit/provider/package/cab_spec.rb +59 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
- data/spec/unit/provider/package/dpkg_spec.rb +16 -16
- data/spec/unit/provider/package/easy_install_spec.rb +18 -18
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
- data/spec/unit/provider/package/homebrew_spec.rb +9 -9
- data/spec/unit/provider/package/ips_spec.rb +37 -31
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +10 -10
- data/spec/unit/provider/package/pacman_spec.rb +6 -6
- data/spec/unit/provider/package/paludis_spec.rb +7 -7
- data/spec/unit/provider/package/portage_spec.rb +6 -7
- data/spec/unit/provider/package/rpm_spec.rb +23 -23
- data/spec/unit/provider/package/rubygems_spec.rb +38 -38
- data/spec/unit/provider/package/solaris_spec.rb +15 -15
- data/spec/unit/provider/package/windows_spec.rb +2 -1
- data/spec/unit/provider/package/yum_spec.rb +51 -43
- data/spec/unit/provider/package/zypper_spec.rb +34 -34
- data/spec/unit/provider/package_spec.rb +8 -0
- data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +7 -1
- data/spec/unit/provider/script_spec.rb +49 -6
- data/spec/unit/resource/dsc_resource_spec.rb +6 -0
- data/spec/unit/resource/execute_spec.rb +214 -0
- data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
- data/spec/unit/resource/freebsd_package_spec.rb +2 -2
- data/spec/unit/resource/package_spec.rb +5 -0
- data/spec/unit/resource/yum_package_spec.rb +42 -1
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +18 -0
- data/spec/unit/server_api_versions_spec.rb +44 -0
- data/spec/unit/util/selinux_spec.rb +3 -14
- data/spec/unit/win32/error_spec.rb +67 -0
- data/spec/unit/win32/security_spec.rb +66 -0
- data/tasks/changelog.rb +1 -1
- data/tasks/dependencies.rb +20 -4
- metadata +39 -18
- data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
data/lib/chef/knife/core/ui.rb
CHANGED
@@ -65,22 +65,18 @@ class Chef
|
|
65
65
|
# Prints a message to stdout. Aliased as +info+ for compatibility with
|
66
66
|
# the logger API.
|
67
67
|
def msg(message)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
exit 0
|
73
|
-
end
|
68
|
+
stdout.puts message
|
69
|
+
rescue Errno::EPIPE => e
|
70
|
+
raise e if @config[:verbosity] >= 2
|
71
|
+
exit 0
|
74
72
|
end
|
75
73
|
|
76
74
|
# Prints a msg to stderr. Used for info, warn, error, and fatal.
|
77
75
|
def log(message)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
exit 0
|
83
|
-
end
|
76
|
+
stderr.puts message
|
77
|
+
rescue Errno::EPIPE => e
|
78
|
+
raise e if @config[:verbosity] >= 2
|
79
|
+
exit 0
|
84
80
|
end
|
85
81
|
|
86
82
|
alias :info :log
|
@@ -155,12 +151,10 @@ class Chef
|
|
155
151
|
end
|
156
152
|
|
157
153
|
def pretty_print(data)
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
exit 0
|
163
|
-
end
|
154
|
+
stdout.puts data
|
155
|
+
rescue Errno::EPIPE => e
|
156
|
+
raise e if @config[:verbosity] >= 2
|
157
|
+
exit 0
|
164
158
|
end
|
165
159
|
|
166
160
|
# Hash -> Hash
|
@@ -215,9 +209,9 @@ class Chef
|
|
215
209
|
output_parsed_again = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(output))
|
216
210
|
if object_parsed_again != output_parsed_again
|
217
211
|
output.save
|
218
|
-
|
212
|
+
msg("Saved #{output}")
|
219
213
|
else
|
220
|
-
|
214
|
+
msg("Object unchanged, not saving")
|
221
215
|
end
|
222
216
|
output(format_for_display(object)) if config[:print_after]
|
223
217
|
end
|
@@ -247,19 +241,19 @@ class Chef
|
|
247
241
|
when "Y", "y"
|
248
242
|
true
|
249
243
|
when "N", "n"
|
250
|
-
|
244
|
+
msg("You said no, so I'm done here.")
|
251
245
|
false
|
252
246
|
when ""
|
253
247
|
unless default_choice.nil?
|
254
248
|
default_choice
|
255
249
|
else
|
256
|
-
|
257
|
-
|
250
|
+
msg("I have no idea what to do with '#{answer}'")
|
251
|
+
msg("Just say Y or N, please.")
|
258
252
|
confirm_without_exit(question, append_instructions, default_choice)
|
259
253
|
end
|
260
254
|
else
|
261
|
-
|
262
|
-
|
255
|
+
msg("I have no idea what to do with '#{answer}'")
|
256
|
+
msg("Just say Y or N, please.")
|
263
257
|
confirm_without_exit(question, append_instructions, default_choice)
|
264
258
|
end
|
265
259
|
end
|
data/lib/chef/knife/deps.rb
CHANGED
@@ -72,49 +72,47 @@ class Chef
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def get_dependencies(entry)
|
75
|
-
|
76
|
-
|
77
|
-
return entry.chef_object.metadata.dependencies.keys.map { |cookbook| "/cookbooks/#{cookbook}" }
|
75
|
+
if entry.parent && entry.parent.path == "/cookbooks"
|
76
|
+
return entry.chef_object.metadata.dependencies.keys.map { |cookbook| "/cookbooks/#{cookbook}" }
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
78
|
+
elsif entry.parent && entry.parent.path == "/nodes"
|
79
|
+
node = Chef::JSONCompat.parse(entry.read)
|
80
|
+
result = []
|
81
|
+
if node["chef_environment"] && node["chef_environment"] != "_default"
|
82
|
+
result << "/environments/#{node['chef_environment']}.json"
|
83
|
+
end
|
84
|
+
if node["run_list"]
|
85
|
+
result += dependencies_from_runlist(node["run_list"])
|
86
|
+
end
|
87
|
+
result
|
89
88
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
89
|
+
elsif entry.parent && entry.parent.path == "/roles"
|
90
|
+
role = Chef::JSONCompat.parse(entry.read)
|
91
|
+
result = []
|
92
|
+
if role["run_list"]
|
93
|
+
dependencies_from_runlist(role["run_list"]).each do |dependency|
|
94
|
+
result << dependency if !result.include?(dependency)
|
97
95
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
end
|
97
|
+
if role["env_run_lists"]
|
98
|
+
role["env_run_lists"].each_pair do |env, run_list|
|
99
|
+
dependencies_from_runlist(run_list).each do |dependency|
|
100
|
+
result << dependency if !result.include?(dependency)
|
103
101
|
end
|
104
102
|
end
|
105
|
-
|
103
|
+
end
|
104
|
+
result
|
106
105
|
|
107
|
-
|
108
|
-
|
106
|
+
elsif !entry.exists?
|
107
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(entry)
|
109
108
|
|
110
|
-
|
111
|
-
[]
|
112
|
-
end
|
113
|
-
rescue Chef::ChefFS::FileSystem::NotFoundError => e
|
114
|
-
ui.error "#{format_path(e.entry)}: No such file or directory"
|
115
|
-
self.exit_code = 2
|
109
|
+
else
|
116
110
|
[]
|
117
111
|
end
|
112
|
+
rescue Chef::ChefFS::FileSystem::NotFoundError => e
|
113
|
+
ui.error "#{format_path(e.entry)}: No such file or directory"
|
114
|
+
self.exit_code = 2
|
115
|
+
[]
|
118
116
|
end
|
119
117
|
|
120
118
|
def dependencies_from_runlist(run_list)
|
data/lib/chef/knife/help.rb
CHANGED
@@ -90,7 +90,7 @@ MOAR_HELP
|
|
90
90
|
def find_manpage_path(topic)
|
91
91
|
if ::File.exists?(::File.expand_path("../distro/common/man/man1/#{topic}.1", CHEF_ROOT))
|
92
92
|
# If we've provided the man page in the gem, give that
|
93
|
-
|
93
|
+
::File.expand_path("../distro/common/man/man1/#{topic}.1", CHEF_ROOT)
|
94
94
|
else
|
95
95
|
# Otherwise, we'll just be using MANPATH
|
96
96
|
topic
|
data/lib/chef/knife/list.rb
CHANGED
data/lib/chef/knife/search.rb
CHANGED
@@ -183,7 +183,7 @@ class Chef
|
|
183
183
|
return_id, attr_path = f.split("=")
|
184
184
|
final_filter[return_id.to_sym] = attr_path.split(".")
|
185
185
|
end
|
186
|
-
|
186
|
+
final_filter
|
187
187
|
end
|
188
188
|
|
189
189
|
def create_result_filter_from_attributes(filter_array)
|
@@ -193,7 +193,7 @@ class Chef
|
|
193
193
|
end
|
194
194
|
# adding magic filter so we can actually pull the name as before
|
195
195
|
final_filter["__display_name"] = [ "name" ]
|
196
|
-
|
196
|
+
final_filter
|
197
197
|
end
|
198
198
|
|
199
199
|
end
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -26,7 +26,6 @@ class Chef
|
|
26
26
|
deps do
|
27
27
|
require "net/ssh"
|
28
28
|
require "net/ssh/multi"
|
29
|
-
require "chef/monkey_patches/net-ssh-multi"
|
30
29
|
require "readline"
|
31
30
|
require "chef/exceptions"
|
32
31
|
require "chef/search/query"
|
@@ -166,10 +165,10 @@ class Chef
|
|
166
165
|
def configure_session
|
167
166
|
list = config[:manual] ? @name_args[0].split(" ") : search_nodes
|
168
167
|
if list.length == 0
|
169
|
-
if @
|
168
|
+
if @search_count == 0
|
170
169
|
ui.fatal("No nodes returned from search")
|
171
170
|
else
|
172
|
-
ui.fatal("#{@
|
171
|
+
ui.fatal("#{@search_count} #{@search_count > 1 ? "nodes" : "node"} found, " +
|
173
172
|
"but does not have the required attribute to establish the connection. " +
|
174
173
|
"Try setting another attribute to open the connection using --attribute.")
|
175
174
|
end
|
@@ -184,41 +183,56 @@ class Chef
|
|
184
183
|
# 2) configuration file
|
185
184
|
# 3) cloud attribute
|
186
185
|
# 4) fqdn
|
187
|
-
if config
|
188
|
-
Chef::Log.debug("Using node attribute '#{config[:attribute]}' as the ssh target")
|
189
|
-
|
186
|
+
if node["config"]
|
187
|
+
Chef::Log.debug("Using node attribute '#{config[:attribute]}' as the ssh target: #{node["config"]}")
|
188
|
+
node["config"]
|
190
189
|
elsif Chef::Config[:knife][:ssh_attribute]
|
191
|
-
Chef::Log.debug("Using node attribute #{Chef::Config[:knife][:ssh_attribute]}")
|
192
|
-
|
193
|
-
elsif node[
|
194
|
-
node[
|
195
|
-
!node[
|
196
|
-
Chef::Log.debug("Using node attribute 'cloud[:public_hostname]' automatically as the ssh target")
|
197
|
-
|
190
|
+
Chef::Log.debug("Using node attribute #{Chef::Config[:knife][:ssh_attribute]}: #{node["knife_config"]}")
|
191
|
+
node["knife_config"]
|
192
|
+
elsif node["cloud"] &&
|
193
|
+
node["cloud"]["public_hostname"] &&
|
194
|
+
!node["cloud"]["public_hostname"].empty?
|
195
|
+
Chef::Log.debug("Using node attribute 'cloud[:public_hostname]' automatically as the ssh target: #{node["cloud"]["public_hostname"]}")
|
196
|
+
node["cloud"]["public_hostname"]
|
198
197
|
else
|
199
198
|
# falling back to default of fqdn
|
200
|
-
Chef::Log.debug("Using node attribute 'fqdn' as the ssh target")
|
201
|
-
|
199
|
+
Chef::Log.debug("Using node attribute 'fqdn' as the ssh target: #{node["fqdn"]}")
|
200
|
+
node["fqdn"]
|
202
201
|
end
|
203
|
-
attribute
|
204
202
|
end
|
205
203
|
|
206
204
|
def search_nodes
|
207
205
|
list = Array.new
|
208
206
|
query = Chef::Search::Query.new
|
209
|
-
|
210
|
-
|
207
|
+
required_attributes = { fqdn: ["fqdn"], cloud: ["cloud"] }
|
208
|
+
|
209
|
+
separator = ui.presenter.attribute_field_separator
|
210
|
+
|
211
|
+
# if we've set an attribute to use on the command line
|
212
|
+
if config[:attribute]
|
213
|
+
required_attributes[:config] = config[:attribute].split(separator)
|
214
|
+
end
|
215
|
+
|
216
|
+
# if we've configured an attribute in our config
|
217
|
+
if Chef::Config[:knife][:ssh_attribute]
|
218
|
+
required_attributes[:knife_config] = Chef::Config[:knife][:ssh_attribute].split(separator)
|
219
|
+
end
|
220
|
+
|
221
|
+
@search_count = 0
|
222
|
+
query.search(:node, @name_args[0], filter_result: required_attributes) do |item|
|
223
|
+
@search_count += 1
|
211
224
|
# we should skip the loop to next iteration if the item
|
212
225
|
# returned by the search is nil
|
213
226
|
next if item.nil?
|
214
227
|
# next if we couldn't find the specified attribute in the
|
215
228
|
# returned node object
|
216
|
-
host =
|
229
|
+
host = get_ssh_attribute(item)
|
217
230
|
next if host.nil?
|
218
231
|
ssh_port = item[:cloud].nil? ? nil : item[:cloud][:public_ssh_port]
|
219
232
|
srv = [host, ssh_port]
|
220
233
|
list.push(srv)
|
221
234
|
end
|
235
|
+
|
222
236
|
list
|
223
237
|
end
|
224
238
|
|
@@ -232,7 +246,7 @@ class Chef
|
|
232
246
|
# @param user [String] Optional username for this session.
|
233
247
|
# @return [Hash<Symbol, Object>]
|
234
248
|
def session_options(host, port, user = nil)
|
235
|
-
ssh_config = Net::SSH.configuration_for(host)
|
249
|
+
ssh_config = Net::SSH.configuration_for(host, true)
|
236
250
|
{}.tap do |opts|
|
237
251
|
# Chef::Config[:knife][:ssh_user] is parsed in #configure_user and written to config[:ssh_user]
|
238
252
|
opts[:user] = user || config[:ssh_user] || ssh_config[:user]
|
@@ -309,9 +323,9 @@ class Chef
|
|
309
323
|
subsession ||= session
|
310
324
|
command = fixup_sudo(command)
|
311
325
|
command.force_encoding("binary") if command.respond_to?(:force_encoding)
|
312
|
-
subsession.open_channel do |
|
313
|
-
|
314
|
-
|
326
|
+
subsession.open_channel do |chan|
|
327
|
+
chan.request_pty
|
328
|
+
chan.exec command do |ch, success|
|
315
329
|
raise ArgumentError, "Cannot execute #{command}" unless success
|
316
330
|
ch.on_data do |ichannel, data|
|
317
331
|
print_data(ichannel[:host], data)
|
@@ -532,10 +546,6 @@ class Chef
|
|
532
546
|
config[:ssh_identity_file] = get_stripped_unfrozen_value(config[:ssh_identity_file] || config[:identity_file] || Chef::Config[:knife][:ssh_identity_file])
|
533
547
|
end
|
534
548
|
|
535
|
-
def extract_nested_value(data_structure, path_spec)
|
536
|
-
ui.presenter.extract_nested_value(data_structure, path_spec)
|
537
|
-
end
|
538
|
-
|
539
549
|
def run
|
540
550
|
@longest = 0
|
541
551
|
|
data/lib/chef/knife/ssl_check.rb
CHANGED
data/lib/chef/mash.rb
CHANGED
data/lib/chef/mixin/command.rb
CHANGED
@@ -103,7 +103,7 @@ class Chef
|
|
103
103
|
command_output << "STDERR: #{stderr}"
|
104
104
|
handle_command_failures(status, command_output, args)
|
105
105
|
|
106
|
-
|
106
|
+
[status, stdout, stderr]
|
107
107
|
end
|
108
108
|
|
109
109
|
def output_of_command(command, args)
|
@@ -141,7 +141,7 @@ class Chef
|
|
141
141
|
Chef::Log.debug("Ran #{command} returned #{status.exitstatus}")
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
[status, stdout_string, stderr_string]
|
145
145
|
end
|
146
146
|
|
147
147
|
def handle_command_failures(status, command_output, opts = {})
|
@@ -53,7 +53,6 @@ class Chef
|
|
53
53
|
private
|
54
54
|
|
55
55
|
def create_dir(path)
|
56
|
-
begin
|
57
56
|
# When doing multithreaded downloads into the file cache, the following
|
58
57
|
# interleaving raises an error here:
|
59
58
|
#
|
@@ -62,10 +61,9 @@ class Chef
|
|
62
61
|
# File.directory?(create_path) <- false
|
63
62
|
# Dir.mkdir(create_path)
|
64
63
|
# Dir.mkdir(create_path) <- raises Errno::EEXIST
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
64
|
+
Chef::Log.debug("Creating directory #{path}")
|
65
|
+
Dir.mkdir(path)
|
66
|
+
rescue Errno::EEXIST
|
69
67
|
end
|
70
68
|
|
71
69
|
end
|
data/lib/chef/mixin/from_file.rb
CHANGED
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
# Raises an IOError if the file cannot be found, or is not readable.
|
28
28
|
def from_file(filename)
|
29
29
|
if File.exists?(filename) && File.readable?(filename)
|
30
|
-
|
30
|
+
instance_eval(IO.read(filename), filename, 1)
|
31
31
|
else
|
32
32
|
raise IOError, "Cannot open or read #{filename}!"
|
33
33
|
end
|
@@ -39,7 +39,7 @@ class Chef
|
|
39
39
|
# Raises an IOError if the file cannot be found, or is not readable.
|
40
40
|
def class_from_file(filename)
|
41
41
|
if File.exists?(filename) && File.readable?(filename)
|
42
|
-
|
42
|
+
class_eval(IO.read(filename), filename, 1)
|
43
43
|
else
|
44
44
|
raise IOError, "Cannot open or read #{filename}!"
|
45
45
|
end
|
@@ -37,9 +37,9 @@ class Chef
|
|
37
37
|
return if new_resource.package_name.is_a?(Array)
|
38
38
|
# if we're passed something that looks like a filesystem path, with no source, use it
|
39
39
|
# - require at least one '/' in the path to avoid gem_package "foo" breaking if a file named 'foo' exists in the cwd
|
40
|
-
if new_resource.source.nil? && new_resource.package_name.match(/#{::File::SEPARATOR}/) && ::File.
|
40
|
+
if new_resource.source.nil? && new_resource.package_name.match(/#{::File::SEPARATOR}/) && ::File.exist?(new_resource.package_name)
|
41
41
|
Chef::Log.debug("No package source specified, but #{new_resource.package_name} exists on the filesystem, copying to package source")
|
42
|
-
new_resource.source(
|
42
|
+
new_resource.source(new_resource.package_name)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -20,15 +20,13 @@ class Chef
|
|
20
20
|
module NotifyingBlock
|
21
21
|
|
22
22
|
def notifying_block(&block)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if
|
29
|
-
|
30
|
-
new_resource.updated_by_last_action(true)
|
31
|
-
end
|
23
|
+
subcontext = subcontext_block(&block)
|
24
|
+
Chef::Runner.new(subcontext).converge
|
25
|
+
ensure
|
26
|
+
# recipes don't have a new_resource
|
27
|
+
if respond_to?(:new_resource)
|
28
|
+
if subcontext && subcontext.resource_collection.any?(&:updated?)
|
29
|
+
new_resource.updated_by_last_action(true)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|