chef 15.11.3 → 15.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -9
  3. data/README.md +3 -3
  4. data/chef-universal-mingw32.gemspec +2 -2
  5. data/chef.gemspec +12 -3
  6. data/lib/chef/api_client/registration.rb +2 -2
  7. data/lib/chef/application/apply.rb +1 -1
  8. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  9. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  10. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  11. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  12. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  13. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  14. data/lib/chef/chef_fs/path_utils.rb +3 -3
  15. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  16. data/lib/chef/data_bag.rb +2 -2
  17. data/lib/chef/data_collector/error_handlers.rb +1 -1
  18. data/lib/chef/deprecated.rb +12 -0
  19. data/lib/chef/dsl/declare_resource.rb +1 -1
  20. data/lib/chef/dsl/platform_introspection.rb +2 -0
  21. data/lib/chef/environment.rb +2 -2
  22. data/lib/chef/exceptions.rb +3 -0
  23. data/lib/chef/http.rb +2 -1
  24. data/lib/chef/knife/bootstrap.rb +8 -10
  25. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  26. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  27. data/lib/chef/knife/cookbook_download.rb +1 -1
  28. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  29. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  30. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  31. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  32. data/lib/chef/knife/exec.rb +2 -2
  33. data/lib/chef/knife/ssh.rb +20 -1
  34. data/lib/chef/log.rb +1 -1
  35. data/lib/chef/mixin/openssl_helper.rb +26 -3
  36. data/lib/chef/mixin/template.rb +1 -0
  37. data/lib/chef/node_map.rb +5 -2
  38. data/lib/chef/provider/mount/solaris.rb +0 -1
  39. data/lib/chef/provider/package/cab.rb +1 -1
  40. data/lib/chef/provider/package/chocolatey.rb +1 -1
  41. data/lib/chef/provider/package/msu.rb +1 -0
  42. data/lib/chef/provider/package/powershell.rb +5 -1
  43. data/lib/chef/provider/package/snap.rb +96 -27
  44. data/lib/chef/provider/package/zypper.rb +0 -1
  45. data/lib/chef/provider/service/arch.rb +2 -2
  46. data/lib/chef/provider/service/debian.rb +1 -1
  47. data/lib/chef/provider/service/gentoo.rb +2 -2
  48. data/lib/chef/provider/service/macosx.rb +2 -2
  49. data/lib/chef/provider/service/openbsd.rb +1 -1
  50. data/lib/chef/provider/service/redhat.rb +2 -2
  51. data/lib/chef/provider/service/upstart.rb +1 -1
  52. data/lib/chef/provider/yum_repository.rb +1 -1
  53. data/lib/chef/provider/zypper_repository.rb +31 -11
  54. data/lib/chef/resource.rb +2 -0
  55. data/lib/chef/resource/archive_file.rb +28 -8
  56. data/lib/chef/resource/cron_access.rb +13 -5
  57. data/lib/chef/resource/cron_d.rb +2 -1
  58. data/lib/chef/resource/homebrew_cask.rb +3 -3
  59. data/lib/chef/resource/hostname.rb +19 -18
  60. data/lib/chef/resource/locale.rb +1 -1
  61. data/lib/chef/resource/lwrp_base.rb +7 -0
  62. data/lib/chef/resource/msu_package.rb +5 -0
  63. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  64. data/lib/chef/resource/sudo.rb +2 -2
  65. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  66. data/lib/chef/resource/windows_font.rb +2 -1
  67. data/lib/chef/role.rb +2 -2
  68. data/lib/chef/shell.rb +1 -1
  69. data/lib/chef/shell/shell_session.rb +2 -0
  70. data/lib/chef/util/diff.rb +1 -1
  71. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  72. data/lib/chef/version.rb +2 -2
  73. data/lib/chef/win32/file.rb +2 -2
  74. data/spec/functional/knife/ssh_spec.rb +4 -4
  75. data/spec/functional/resource/aix_service_spec.rb +0 -1
  76. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  77. data/spec/functional/resource/apt_package_spec.rb +0 -1
  78. data/spec/functional/resource/bff_spec.rb +2 -2
  79. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  80. data/spec/functional/resource/cron_spec.rb +0 -1
  81. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  82. data/spec/functional/resource/insserv_spec.rb +4 -5
  83. data/spec/functional/resource/link_spec.rb +17 -17
  84. data/spec/functional/resource/msu_package_spec.rb +5 -2
  85. data/spec/functional/resource/rpm_spec.rb +2 -2
  86. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  87. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  88. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  89. data/spec/functional/resource/windows_font_spec.rb +49 -0
  90. data/spec/functional/resource/windows_task_spec.rb +8 -8
  91. data/spec/functional/run_lock_spec.rb +2 -1
  92. data/spec/functional/shell_spec.rb +5 -5
  93. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  94. data/spec/functional/version_spec.rb +1 -1
  95. data/spec/functional/win32/service_manager_spec.rb +1 -1
  96. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  97. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  98. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  99. data/spec/integration/recipes/notifies_spec.rb +1 -1
  100. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  101. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  102. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  103. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  104. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  105. data/spec/scripts/ssl-serve.rb +1 -1
  106. data/spec/spec_helper.rb +26 -8
  107. data/spec/support/chef_helpers.rb +1 -1
  108. data/spec/support/platform_helpers.rb +12 -42
  109. data/spec/support/platforms/win32/spec_service.rb +1 -1
  110. data/spec/support/shared/functional/directory_resource.rb +1 -1
  111. data/spec/support/shared/functional/execute_resource.rb +1 -1
  112. data/spec/support/shared/functional/file_resource.rb +2 -2
  113. data/spec/support/shared/functional/win32_service.rb +1 -1
  114. data/spec/support/shared/functional/windows_script.rb +3 -3
  115. data/spec/support/shared/integration/knife_support.rb +2 -5
  116. data/spec/unit/application_spec.rb +7 -0
  117. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  118. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  119. data/spec/unit/data_bag_spec.rb +1 -1
  120. data/spec/unit/data_collector_spec.rb +1 -1
  121. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  122. data/spec/unit/environment_spec.rb +7 -7
  123. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  124. data/spec/unit/file_access_control_spec.rb +1 -1
  125. data/spec/unit/json_compat_spec.rb +1 -1
  126. data/spec/unit/knife/bootstrap_spec.rb +16 -16
  127. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  128. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  129. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  130. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  131. data/spec/unit/knife/ssh_spec.rb +2 -2
  132. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  133. data/spec/unit/lwrp_spec.rb +4 -4
  134. data/spec/unit/mixin/securable_spec.rb +0 -1
  135. data/spec/unit/mixin/user_context_spec.rb +1 -9
  136. data/spec/unit/property_spec.rb +6 -6
  137. data/spec/unit/provider/apt_repository_spec.rb +2 -2
  138. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  139. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  140. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  141. data/spec/unit/provider/package/snap_spec.rb +1 -1
  142. data/spec/unit/provider/package/windows_spec.rb +30 -53
  143. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  144. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  145. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  146. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  147. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  148. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  149. data/spec/unit/provider/service/windows_spec.rb +2 -6
  150. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  151. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  152. data/spec/unit/provider_spec.rb +1 -0
  153. data/spec/unit/resource/archive_file_spec.rb +11 -2
  154. data/spec/unit/resource/msu_package_spec.rb +4 -0
  155. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  156. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  157. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  158. data/spec/unit/resource/windows_package_spec.rb +1 -0
  159. data/spec/unit/resource/windows_task_spec.rb +1 -1
  160. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  161. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  162. data/spec/unit/resource_reporter_spec.rb +1 -1
  163. data/spec/unit/resource_spec.rb +1 -1
  164. data/spec/unit/role_spec.rb +11 -11
  165. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  166. data/spec/unit/run_lock_spec.rb +1 -1
  167. data/spec/unit/scan_access_control_spec.rb +1 -1
  168. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  169. data/spec/unit/win32/security_spec.rb +4 -3
  170. data/tasks/rspec.rb +5 -13
  171. metadata +30 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 284b837896f77e4369e5cf591eb17b9a71761df8524a920f36afd7112093eab4
4
- data.tar.gz: 8d750cfd693024f1a1a0fd4b0cec42086be4562593dbfb426baece630fe6f2e2
3
+ metadata.gz: dcc08d354ca7fa1200a0eb3cac4c86bec517ceb346a0f2bc023b1f9abaf87920
4
+ data.tar.gz: bf949036d55a3ec0ea2892f952d0ad5eab0044e6d6848af805ac39798e17b6d3
5
5
  SHA512:
6
- metadata.gz: eb3a42ffe7ac30522a82e35cb852bdf2593ca4d174bc751db126cd40cd8a4eafab1e71c2525242b0889ada8539e135d087ad7d835f3f42cff1863e41c22ca77d
7
- data.tar.gz: e6c0733787eef6eff73bb4a0017f431c5cb7683ef9ff72ea5c673418b8ea4cc737f5559bf13f651f2737b11db4fef011a95220572b0ff9bd2e78ff3fb5d482e9
6
+ metadata.gz: 9547afde6d37ca3b3eaa6b3c87c7e6130996d001a8d9895385bcdd26a17bc88e9680cc95ca4dbfdb3ac2dfbc1ede68c022fc5b97c7694acfdb8334a0d1e6e9cb
7
+ data.tar.gz: 223528572bf22ca87d57dd90755fdc5a61dc7f70e1655124928e055d9b36403a3388518ae068fde648ce543834c3d620a60c10b4789aa74e9e8735b86c35a5f2
data/Gemfile CHANGED
@@ -9,12 +9,12 @@ gem "chef", path: "."
9
9
 
10
10
  gem "ohai", git: "https://github.com/chef/ohai.git", branch: "15-stable"
11
11
 
12
- gem "chef-utils", path: File.expand_path("../chef-utils", __FILE__) if File.exist?(File.expand_path("../chef-utils", __FILE__))
13
- gem "chef-config", path: File.expand_path("../chef-config", __FILE__) if File.exist?(File.expand_path("../chef-config", __FILE__))
12
+ gem "chef-utils", path: File.expand_path("chef-utils", __dir__) if File.exist?(File.expand_path("chef-utils", __dir__))
13
+ gem "chef-config", path: File.expand_path("chef-config", __dir__) if File.exist?(File.expand_path("chef-config", __dir__))
14
14
 
15
- if File.exist?(File.expand_path("../chef-bin", __FILE__))
15
+ if File.exist?(File.expand_path("chef-bin", __dir__))
16
16
  # bundling in a git checkout
17
- gem "chef-bin", path: File.expand_path("../chef-bin", __FILE__)
17
+ gem "chef-bin", path: File.expand_path("chef-bin", __dir__)
18
18
  else
19
19
  # bundling in omnibus
20
20
  gem "chef-bin" # rubocop:disable Bundler/DuplicatedGem
@@ -22,8 +22,7 @@ end
22
22
 
23
23
  gem "cheffish", "~> 14"
24
24
 
25
- # avoid bringing in the new http 4 gem that comes with other ffi baggage which breaks builds
26
- gem "chef-telemetry", "=1.0.3"
25
+ gem "chef-telemetry", ">=1.0.8" # 1.0.8 removes the http dep
27
26
 
28
27
  group(:omnibus_package) do
29
28
  gem "appbundler"
@@ -39,7 +38,7 @@ group(:omnibus_package, :pry) do
39
38
  gem "pry"
40
39
  gem "pry-byebug"
41
40
  gem "pry-remote"
42
- gem "pry-stack_explorer"
41
+ gem "pry-stack_explorer", "~> 0.4.0" # pin to allow Ruby 2.5
43
42
  end
44
43
 
45
44
  group(:docgen) do
@@ -72,8 +71,7 @@ group(:development, :test) do
72
71
  end
73
72
 
74
73
  group(:chefstyle) do
75
- # for testing new chefstyle rules
76
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
74
+ gem "chefstyle", "1.2.1" # pinned so we don't have to fixup 2 branches for new rules
77
75
  end
78
76
 
79
77
  instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
data/README.md CHANGED
@@ -18,7 +18,7 @@ Chef Infra is a configuration management tool designed to bring automation to yo
18
18
 
19
19
  ### Want to try Chef Infra?
20
20
 
21
- For Chef Infra usage, please refer to our [Learn Chef Rally](https://learn.chef.io/) website, which includes module-based training for Chef Infra, as well as Automate, Habitat, and InSpec.
21
+ For Chef Infra usage, please refer to [Learn Chef](https://learn.chef.io/), our self-paced, entirely free learning platform. Learn Chef also includes module-based training for Chef Infra, as well as Chef Automate, Chef Habitat, and Chef InSpec.
22
22
 
23
23
  Other useful resources for Chef Infra users:
24
24
 
@@ -26,7 +26,7 @@ Other useful resources for Chef Infra users:
26
26
  - Source: <https://github.com/chef/chef/tree/master>
27
27
  - Tickets/Issues: <https://github.com/chef/chef/issues>
28
28
  - Slack: [Chef Community Slack](https://community-slack.chef.io/)
29
- - Mailing list: <https://discourse.chef.io>
29
+ - Mailing list/Forum: <https://discourse.chef.io>
30
30
 
31
31
  ## Reporting Issues
32
32
 
@@ -46,7 +46,7 @@ We'd love to have your help developing Chef Infra. See our [Contributing Documen
46
46
 
47
47
  ## License and Copyright
48
48
 
49
- Copyright 2008-2019, Chef Software, Inc.
49
+ Copyright 2008-2020, Chef Software, Inc.
50
50
 
51
51
  ```
52
52
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,4 +1,4 @@
1
- gemspec = eval(IO.read(File.expand_path("../chef.gemspec", __FILE__)))
1
+ gemspec = eval(IO.read(File.expand_path("chef.gemspec", __dir__)))
2
2
 
3
3
  gemspec.platform = Gem::Platform.new(%w{universal mingw32})
4
4
 
@@ -14,7 +14,7 @@ gemspec.add_dependency "win32-process", "~> 0.8.2"
14
14
  gemspec.add_dependency "win32-service", ">= 2.1.5", "< 3.0"
15
15
  gemspec.add_dependency "wmi-lite", "~> 1.0"
16
16
  gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
17
- gemspec.add_dependency "iso8601", "~> 0.12.1"
17
+ gemspec.add_dependency "iso8601", ">= 0.12.1", "< 0.14" # validate 0.14 when it comes out
18
18
  gemspec.add_dependency "win32-certstore", "~> 0.3"
19
19
  gemspec.extensions << "ext/win32-eventlog/Rakefile"
20
20
  gemspec.files += Dir.glob("{distro,ext}/**/*")
@@ -30,16 +30,16 @@ Gem::Specification.new do |s|
30
30
 
31
31
  s.add_dependency "ffi", "~> 1.9", ">= 1.9.25"
32
32
  s.add_dependency "ffi-yajl", "~> 2.2"
33
- s.add_dependency "net-ssh", ">= 4.2", "< 6"
33
+ s.add_dependency "net-ssh", ">= 4.2", "< 7"
34
34
  s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
35
- s.add_dependency "net-sftp", "~> 2.1", ">= 2.1.2"
35
+ s.add_dependency "net-sftp", ">= 2.1.2", "< 4.0"
36
36
  s.add_dependency "ed25519", "~> 1.2" # ed25519 ssh key support
37
37
  s.add_dependency "bcrypt_pbkdf", "~> 1.0" # ed25519 ssh key support
38
38
  s.add_dependency "highline", ">= 1.6.9", "< 2"
39
39
  s.add_dependency "tty-screen", "~> 0.6" # knife list
40
40
  s.add_dependency "erubis", "~> 2.7"
41
41
  s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4"
42
- s.add_dependency "ffi-libarchive"
42
+ s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3"
43
43
  s.add_dependency "chef-zero", ">= 14.0.11"
44
44
 
45
45
  s.add_dependency "plist", "~> 3.2"
@@ -62,4 +62,13 @@ Gem::Specification.new do |s|
62
62
  Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } +
63
63
  Dir.glob("*.gemspec") +
64
64
  Dir.glob("tasks/rspec.rb")
65
+
66
+ s.metadata = {
67
+ "bug_tracker_uri" => "https://github.com/chef/chef/issues",
68
+ "changelog_uri" => "https://github.com/chef/chef/blob/master/CHANGELOG.md",
69
+ "documentation_uri" => "https://docs.chef.io/",
70
+ "homepage_uri" => "https://www.chef.io",
71
+ "mailing_list_uri" => "https://discourse.chef.io/",
72
+ "source_code_uri" => "https://github.com/chef/chef/",
73
+ }
65
74
  end
@@ -72,14 +72,14 @@ class Chef
72
72
 
73
73
  def assert_destination_writable!
74
74
  abs_path = File.expand_path(destination)
75
- unless File.exists?(File.dirname(abs_path))
75
+ unless File.exist?(File.dirname(abs_path))
76
76
  begin
77
77
  FileUtils.mkdir_p(File.dirname(abs_path))
78
78
  rescue Errno::EACCES
79
79
  raise Chef::Exceptions::CannotWritePrivateKey, "I can't create the configuration directory at #{File.dirname(abs_path)} - check permissions?"
80
80
  end
81
81
  end
82
- if (File.exists?(abs_path) && !File.writable?(abs_path)) || !File.writable?(File.dirname(abs_path))
82
+ if (File.exist?(abs_path) && !File.writable?(abs_path)) || !File.writable?(File.dirname(abs_path))
83
83
  raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?"
84
84
  end
85
85
  end
@@ -216,7 +216,7 @@ class Chef::Application::Apply < Chef::Application
216
216
  end
217
217
 
218
218
  # Get this party started
219
- def run(enforce_license = false)
219
+ def run(enforce_license: false)
220
220
  reconfigure
221
221
  check_license_acceptance if enforce_license
222
222
  run_application
@@ -92,6 +92,7 @@ class Chef
92
92
  end
93
93
 
94
94
  attr_writer :write_pretty_json
95
+
95
96
  def write_pretty_json
96
97
  @write_pretty_json.nil? ? root.write_pretty_json : @write_pretty_json
97
98
  end
@@ -76,7 +76,7 @@ class Chef
76
76
 
77
77
  # Write out .uploaded-cookbook-version.json
78
78
  # cookbook_file_path = File.join(file_path, cookbook_name) <- this should be the same as self.file_path
79
- unless File.exists?(file_path)
79
+ unless File.exist?(file_path)
80
80
  FileUtils.mkdir_p(file_path)
81
81
  end
82
82
  uploaded_cookbook_version_path = File.join(file_path, Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE)
@@ -132,7 +132,7 @@ class Chef
132
132
  end
133
133
 
134
134
  def can_upload?
135
- File.exists?(uploaded_cookbook_version_path) || children.size > 0
135
+ File.exist?(uploaded_cookbook_version_path) || children.size > 0
136
136
  end
137
137
 
138
138
  protected
@@ -137,7 +137,7 @@ class Chef
137
137
  end
138
138
 
139
139
  def exists?
140
- File.exists?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
140
+ File.exist?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
141
141
  end
142
142
 
143
143
  def read
@@ -161,7 +161,7 @@ class Chef
161
161
  # members.json and org.json may be found.
162
162
  #
163
163
  def root_dir
164
- existing_paths = root_paths.select { |path| File.exists?(path) }
164
+ existing_paths = root_paths.select { |path| File.exist?(path) }
165
165
  if existing_paths.size > 0
166
166
  MultiplexedDir.new(existing_paths.map do |path|
167
167
  dir = FileSystemEntry.new(name, parent, path)
@@ -184,7 +184,7 @@ class Chef
184
184
  return root_dir.child(name)
185
185
  end
186
186
 
187
- paths = (child_paths[name] || []).select { |path| File.exists?(path) }
187
+ paths = (child_paths[name] || []).select { |path| File.exist?(path) }
188
188
  if paths.size == 0
189
189
  return NonexistentFSObject.new(name, self)
190
190
  end
@@ -151,7 +151,7 @@ class Chef
151
151
  end
152
152
 
153
153
  def exists?
154
- File.exists?(file_path)
154
+ File.exist?(file_path)
155
155
  end
156
156
 
157
157
  protected
@@ -122,7 +122,7 @@ class Chef
122
122
  end
123
123
 
124
124
  def exists?
125
- File.exists?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
125
+ File.exist?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
126
126
  end
127
127
 
128
128
  def read
@@ -71,9 +71,9 @@ class Chef
71
71
  # part that actually exists. The paths operated on here are not Chef-FS paths.
72
72
  # These are OS paths that may contain symlinks but may not also fully exist.
73
73
  #
74
- # If /x is a symlink to /blarghle, and has no subdirectories, then:
75
- # PathUtils.realest_path('/x/y/z') == '/blarghle/y/z'
76
- # PathUtils.realest_path('/x/*/z') == '/blarghle/*/z'
74
+ # If /x is a symlink to /foo_bar, and has no subdirectories, then:
75
+ # PathUtils.realest_path('/x/y/z') == '/foo_bar/y/z'
76
+ # PathUtils.realest_path('/x/*/z') == '/foo_bar/*/z'
77
77
  # PathUtils.realest_path('/*/y/z') == '/*/y/z'
78
78
  #
79
79
  # TODO: Move this to wherever util/path_helper is these days.
@@ -27,7 +27,7 @@ class Chef
27
27
  # and throws the rest away then re-builds the list of files on the
28
28
  # disk. This is due to the manifest not having the on-disk file
29
29
  # locations, since in the chef-client case, that information is
30
- # non-sensical.
30
+ # nonsensical.
31
31
  class FileSystemFileVendor < FileVendor
32
32
 
33
33
  attr_reader :cookbook_name
@@ -94,7 +94,7 @@ class Chef
94
94
  names = []
95
95
  paths.each do |path|
96
96
  unless File.directory?(path)
97
- raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' is invalid"
97
+ raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' not found. Please create this directory."
98
98
  end
99
99
 
100
100
  names += Dir.glob(File.join(
@@ -122,7 +122,7 @@ class Chef
122
122
  data_bag = {}
123
123
  paths.each do |path|
124
124
  unless File.directory?(path)
125
- raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' is invalid"
125
+ raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' not found. Please create this directory."
126
126
  end
127
127
 
128
128
  Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path, name.to_s), "*.json")).inject({}) do |bag, f|
@@ -18,7 +18,7 @@
18
18
  class Chef
19
19
  class DataCollector
20
20
 
21
- # This module isolates the handling of collecting error descriptions to insert into the data_colletor
21
+ # This module isolates the handling of collecting error descriptions to insert into the data_collector
22
22
  # report output. For very early errors it is responsible for collecting the node_name for the report
23
23
  # to use. For all failure conditions that have an ErrorMapper it collects the output.
24
24
  #
@@ -233,6 +233,18 @@ class Chef
233
233
  target 28
234
234
  end
235
235
 
236
+ class KnifeBootstrapApis < Base
237
+ target 29
238
+ end
239
+
240
+ class ArchiveFileIntegerFileMode < Base
241
+ target 30
242
+ end
243
+
244
+ class ResourceNameWithoutProvides < Base
245
+ target 31
246
+ end
247
+
236
248
  class Generic < Base
237
249
  def url
238
250
  "https://docs.chef.io/chef_deprecations_client/"
@@ -151,7 +151,7 @@ class Chef
151
151
  # source "y.txt.erb"
152
152
  # variables {}
153
153
  # end
154
- # resource.variables.merge!({ home: "/home/klowns" })
154
+ # resource.variables.merge!({ home: "/home/clowns" })
155
155
  #
156
156
  def edit_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
157
157
  edit_resource!(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)
@@ -248,6 +248,8 @@ class Chef
248
248
  end
249
249
 
250
250
  # a simple helper to determine if we're on a windows release pre-2012 / 8
251
+ #
252
+ # @deprecated Windows releases before Windows 2012 and 8 are no longer supported
251
253
  # @return [Boolean] Is the system older than Windows 8 / 2012
252
254
  def older_than_win_2012_or_8?(node = run_context.nil? ? nil : run_context.node)
253
255
  node["platform_version"].to_f < 6.2
@@ -255,11 +255,11 @@ class Chef
255
255
  js_file = File.join(Chef::Config[:environment_path], "#{name}.json")
256
256
  rb_file = File.join(Chef::Config[:environment_path], "#{name}.rb")
257
257
 
258
- if File.exists?(js_file)
258
+ if File.exist?(js_file)
259
259
  # from_json returns object.class => json_class in the JSON.
260
260
  hash = Chef::JSONCompat.parse(IO.read(js_file))
261
261
  from_hash(hash)
262
- elsif File.exists?(rb_file)
262
+ elsif File.exist?(rb_file)
263
263
  environment = Chef::Environment.new
264
264
  environment.name(name)
265
265
  environment.from_file(rb_file)
@@ -198,6 +198,7 @@ class Chef
198
198
  class MetadataNotFound < StandardError
199
199
  attr_reader :install_path
200
200
  attr_reader :cookbook_name
201
+
201
202
  def initialize(install_path, cookbook_name)
202
203
  @install_path = install_path
203
204
  @cookbook_name = cookbook_name
@@ -448,6 +449,7 @@ class Chef
448
449
  # to correctly populate the backtrace with the wrapped backtraces.
449
450
  class RunFailedWrappingError < RuntimeError
450
451
  attr_reader :wrapped_errors
452
+
451
453
  def initialize(*errors)
452
454
  errors = errors.select { |e| !e.nil? }
453
455
  output = "Found #{errors.size} errors, they are stored in the backtrace"
@@ -488,6 +490,7 @@ class Chef
488
490
 
489
491
  class MultipleDscResourcesFound < RuntimeError
490
492
  attr_reader :resources_found
493
+
491
494
  def initialize(resources_found)
492
495
  @resources_found = resources_found
493
496
  matches_info = @resources_found.each do |r|
@@ -22,7 +22,8 @@
22
22
  #
23
23
 
24
24
  require "tempfile" unless defined?(Tempfile)
25
- require "net/https"
25
+ require "openssl" unless defined?(OpenSSL)
26
+ require "net/http" unless defined?(Net::HTTP)
26
27
  require "uri" unless defined?(URI)
27
28
  require_relative "http/basic_client"
28
29
  require_relative "monkey_patches/net_http"
@@ -497,7 +497,7 @@ class Chef
497
497
  template = bootstrap_template
498
498
 
499
499
  # Use the template directly if it's a path to an actual file
500
- if File.exists?(template)
500
+ if File.exist?(template)
501
501
  Chef::Log.trace("Using the specified bootstrap template: #{File.dirname(template)}")
502
502
  return template
503
503
  end
@@ -512,7 +512,7 @@ class Chef
512
512
 
513
513
  template_file = Array(bootstrap_files).find do |bootstrap_template|
514
514
  Chef::Log.trace("Looking for bootstrap template in #{File.dirname(bootstrap_template)}")
515
- File.exists?(bootstrap_template)
515
+ File.exist?(bootstrap_template)
516
516
  end
517
517
 
518
518
  unless template_file
@@ -555,7 +555,7 @@ class Chef
555
555
  end
556
556
 
557
557
  def run
558
- check_license
558
+ check_license if ChefConfig::Dist::ENFORCE_LICENSE
559
559
 
560
560
  plugin_setup!
561
561
  validate_name_args!
@@ -597,11 +597,8 @@ class Chef
597
597
 
598
598
  bootstrap_context.client_pem = client_builder.client_path
599
599
  else
600
- ui.info <<~EOM
601
- Performing legacy client registration with the validation key at #{Chef::Config[:validation_key]}...
602
- Delete your validation key in order to use your user credentials for client registration instead.
603
- EOM
604
-
600
+ ui.warn "Performing legacy client registration with the validation key at #{Chef::Config[:validation_key]}..."
601
+ ui.warn "Remove the key file or remove the 'validation_key' configuration option from your config.rb (knife.rb) to use more secure user credentials for client registration."
605
602
  end
606
603
  end
607
604
 
@@ -619,7 +616,7 @@ class Chef
619
616
  end
620
617
 
621
618
  def connect!
622
- ui.info("Connecting to #{ui.color(server_name, :bold)}")
619
+ ui.info("Connecting to #{ui.color(server_name, :bold)} using #{connection_protocol}")
623
620
  opts ||= connection_opts.dup
624
621
  do_connect(opts)
625
622
  rescue Train::Error => e
@@ -1108,7 +1105,8 @@ class Chef
1108
1105
  # These keys are available in Chef::Config, and are prefixed with the protocol name.
1109
1106
  # For example, :user CLI option will map to :winrm_user and :ssh_user Chef::Config keys,
1110
1107
  # based on the connection protocol in use.
1111
- def knife_key_for_protocol(protocol, option)
1108
+ def knife_key_for_protocol(new_option, option = nil)
1109
+ option = new_option if option.nil? # hacky compat with both old Chef-15 style and new Chef-16 style API signature
1112
1110
  "#{connection_protocol}_#{option}".to_sym
1113
1111
  end
1114
1112
 
@@ -185,50 +185,50 @@ if test "x$tmp_dir" != "x"; then
185
185
  rm -r "$tmp_dir"
186
186
  fi
187
187
 
188
- mkdir -p <%= ChefConfig::Config.etc_chef_dir(false) %>
188
+ mkdir -p /etc/chef
189
189
 
190
190
  <% if client_pem -%>
191
- (umask 077 && (cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/client.pem <<'EOP'
191
+ (umask 077 && (cat > /etc/chef/client.pem <<'EOP'
192
192
  <%= ::File.read(::File.expand_path(client_pem)) %>
193
193
  EOP
194
194
  )) || exit 1
195
195
  <% end -%>
196
196
 
197
197
  <% if validation_key -%>
198
- (umask 077 && (cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/validation.pem <<'EOP'
198
+ (umask 077 && (cat > /etc/chef/validation.pem <<'EOP'
199
199
  <%= validation_key %>
200
200
  EOP
201
201
  )) || exit 1
202
202
  <% end -%>
203
203
 
204
204
  <% if encrypted_data_bag_secret -%>
205
- (umask 077 && (cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/encrypted_data_bag_secret <<'EOP'
205
+ (umask 077 && (cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
206
206
  <%= encrypted_data_bag_secret %>
207
207
  EOP
208
208
  )) || exit 1
209
209
  <% end -%>
210
210
 
211
211
  <% unless trusted_certs.empty? -%>
212
- mkdir -p <%= ChefConfig::Config.etc_chef_dir(false) %>/trusted_certs
212
+ mkdir -p /etc/chef/trusted_certs
213
213
  <%= trusted_certs %>
214
214
  <% end -%>
215
215
 
216
216
  <%# Generate Ohai Hints -%>
217
217
  <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
218
- mkdir -p <%= ChefConfig::Config.etc_chef_dir(false) %>/ohai/hints
218
+ mkdir -p /etc/chef/ohai/hints
219
219
 
220
220
  <% @chef_config[:knife][:hints].each do |name, hash| -%>
221
- cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/ohai/hints/<%= name %>.json <<'EOP'
221
+ cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
222
222
  <%= Chef::JSONCompat.to_json(hash) %>
223
223
  EOP
224
224
  <% end -%>
225
225
  <% end -%>
226
226
 
227
- cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/client.rb <<'EOP'
227
+ cat > /etc/chef/client.rb <<'EOP'
228
228
  <%= config_content %>
229
229
  EOP
230
230
 
231
- cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/first-boot.json <<'EOP'
231
+ cat > /etc/chef/first-boot.json <<'EOP'
232
232
  <%= Chef::JSONCompat.to_json(first_boot) %>
233
233
  EOP
234
234