chef 15.8.23 → 15.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +1 -1
  4. data/Rakefile +9 -0
  5. data/lib/chef/application.rb +1 -1
  6. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  7. data/lib/chef/chef_fs/command_line.rb +5 -5
  8. data/lib/chef/cookbook/metadata.rb +5 -4
  9. data/lib/chef/cookbook/synchronizer.rb +1 -0
  10. data/lib/chef/cookbook_loader.rb +1 -1
  11. data/lib/chef/data_collector/config_validation.rb +7 -7
  12. data/lib/chef/deprecated.rb +5 -5
  13. data/lib/chef/dsl/platform_introspection.rb +2 -2
  14. data/lib/chef/dsl/reboot_pending.rb +3 -3
  15. data/lib/chef/http/json_output.rb +1 -1
  16. data/lib/chef/knife.rb +1 -1
  17. data/lib/chef/knife/bootstrap/templates/README.md +2 -2
  18. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  19. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
  20. data/lib/chef/knife/core/ui.rb +1 -1
  21. data/lib/chef/knife/core/windows_bootstrap_context.rb +8 -8
  22. data/lib/chef/knife/data_bag_edit.rb +2 -2
  23. data/lib/chef/knife/edit.rb +1 -1
  24. data/lib/chef/knife/environment_compare.rb +1 -1
  25. data/lib/chef/knife/list.rb +1 -1
  26. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  27. data/lib/chef/provider/group/usermod.rb +2 -5
  28. data/lib/chef/provider/mount/mount.rb +1 -1
  29. data/lib/chef/provider/package/homebrew.rb +1 -2
  30. data/lib/chef/provider/package/rubygems.rb +1 -1
  31. data/lib/chef/provider/package/yum/python_helper.rb +2 -2
  32. data/lib/chef/provider/package/yum/rpm_utils.rb +4 -4
  33. data/lib/chef/provider/package/zypper.rb +2 -1
  34. data/lib/chef/provider/remote_file.rb +2 -2
  35. data/lib/chef/provider/route.rb +4 -4
  36. data/lib/chef/provider/windows_env.rb +3 -3
  37. data/lib/chef/resource.rb +7 -2
  38. data/lib/chef/resource/build_essential.rb +46 -22
  39. data/lib/chef/resource/cron.rb +1 -1
  40. data/lib/chef/resource/cron_d.rb +1 -1
  41. data/lib/chef/resource/execute.rb +1 -1
  42. data/lib/chef/resource/freebsd_package.rb +0 -3
  43. data/lib/chef/resource/homebrew_package.rb +1 -2
  44. data/lib/chef/resource/hostname.rb +2 -2
  45. data/lib/chef/resource/kernel_module.rb +3 -2
  46. data/lib/chef/resource/openbsd_package.rb +0 -3
  47. data/lib/chef/resource/remote_file.rb +1 -1
  48. data/lib/chef/resource/rhsm_errata.rb +9 -2
  49. data/lib/chef/resource/rhsm_errata_level.rb +11 -5
  50. data/lib/chef/resource/rhsm_register.rb +27 -12
  51. data/lib/chef/resource/swap_file.rb +2 -2
  52. data/lib/chef/resource/timezone.rb +2 -2
  53. data/lib/chef/resource/windows_certificate.rb +0 -2
  54. data/lib/chef/resource/windows_share.rb +1 -1
  55. data/lib/chef/shell/ext.rb +1 -1
  56. data/lib/chef/util/diff.rb +3 -3
  57. data/lib/chef/util/selinux.rb +2 -2
  58. data/lib/chef/version.rb +1 -1
  59. data/lib/chef/win32/error.rb +1 -1
  60. data/lib/chef/win32/registry.rb +1 -1
  61. data/lib/chef/win32/system.rb +0 -0
  62. data/spec/data/cookbooks/starter/recipes/default.rb +1 -1
  63. data/spec/data/windows_certificates/base64_test.cer +18 -20
  64. data/spec/data/windows_certificates/othertest.cer +0 -0
  65. data/spec/data/windows_certificates/test.cer +0 -0
  66. data/spec/data/windows_certificates/test.p7b +0 -0
  67. data/spec/data/windows_certificates/test.pem +18 -19
  68. data/spec/data/windows_certificates/test.pfx +0 -0
  69. data/spec/functional/resource/ifconfig_spec.rb +2 -2
  70. data/spec/functional/resource/windows_certificate_spec.rb +9 -9
  71. data/spec/functional/resource/windows_service_spec.rb +1 -2
  72. data/spec/functional/run_lock_spec.rb +7 -1
  73. data/spec/functional/win32/service_manager_spec.rb +1 -1
  74. data/spec/functional/win32/version_info_spec.rb +4 -4
  75. data/spec/integration/client/client_spec.rb +2 -2
  76. data/spec/integration/client/exit_code_spec.rb +1 -0
  77. data/spec/integration/client/ipv6_spec.rb +1 -0
  78. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -0
  79. data/spec/integration/knife/chef_repo_path_spec.rb +1 -0
  80. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -0
  81. data/spec/integration/knife/chefignore_spec.rb +1 -0
  82. data/spec/integration/knife/client_bulk_delete_spec.rb +1 -0
  83. data/spec/integration/knife/client_create_spec.rb +1 -0
  84. data/spec/integration/knife/client_delete_spec.rb +1 -0
  85. data/spec/integration/knife/client_key_create_spec.rb +1 -0
  86. data/spec/integration/knife/client_key_delete_spec.rb +1 -0
  87. data/spec/integration/knife/client_key_list_spec.rb +1 -0
  88. data/spec/integration/knife/client_key_show_spec.rb +1 -0
  89. data/spec/integration/knife/client_list_spec.rb +1 -0
  90. data/spec/integration/knife/client_show_spec.rb +1 -0
  91. data/spec/integration/knife/common_options_spec.rb +1 -0
  92. data/spec/integration/knife/config_get_profile_spec.rb +1 -0
  93. data/spec/integration/knife/config_get_spec.rb +1 -0
  94. data/spec/integration/knife/config_list_profiles_spec.rb +1 -0
  95. data/spec/integration/knife/config_use_profile_spec.rb +1 -0
  96. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -0
  97. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +1 -0
  98. data/spec/integration/knife/cookbook_download_spec.rb +1 -0
  99. data/spec/integration/knife/cookbook_list_spec.rb +1 -0
  100. data/spec/integration/knife/cookbook_show_spec.rb +1 -0
  101. data/spec/integration/knife/cookbook_upload_spec.rb +1 -0
  102. data/spec/integration/knife/data_bag_create_spec.rb +1 -0
  103. data/spec/integration/knife/data_bag_delete_spec.rb +1 -0
  104. data/spec/integration/knife/data_bag_edit_spec.rb +1 -0
  105. data/spec/integration/knife/data_bag_from_file_spec.rb +1 -0
  106. data/spec/integration/knife/data_bag_list_spec.rb +1 -0
  107. data/spec/integration/knife/data_bag_show_spec.rb +1 -0
  108. data/spec/integration/knife/delete_spec.rb +1 -0
  109. data/spec/integration/knife/deps_spec.rb +3 -2
  110. data/spec/integration/knife/diff_spec.rb +1 -0
  111. data/spec/integration/knife/download_spec.rb +1 -0
  112. data/spec/integration/knife/environment_compare_spec.rb +1 -0
  113. data/spec/integration/knife/environment_create_spec.rb +1 -0
  114. data/spec/integration/knife/environment_delete_spec.rb +1 -0
  115. data/spec/integration/knife/environment_from_file_spec.rb +1 -0
  116. data/spec/integration/knife/environment_list_spec.rb +1 -0
  117. data/spec/integration/knife/environment_show_spec.rb +1 -0
  118. data/spec/integration/knife/list_spec.rb +1 -0
  119. data/spec/integration/knife/node_bulk_delete_spec.rb +1 -0
  120. data/spec/integration/knife/node_create_spec.rb +1 -0
  121. data/spec/integration/knife/node_delete_spec.rb +1 -0
  122. data/spec/integration/knife/node_environment_set_spec.rb +1 -0
  123. data/spec/integration/knife/node_from_file_spec.rb +1 -0
  124. data/spec/integration/knife/node_list_spec.rb +1 -0
  125. data/spec/integration/knife/node_run_list_add_spec.rb +1 -0
  126. data/spec/integration/knife/node_run_list_remove_spec.rb +1 -0
  127. data/spec/integration/knife/node_run_list_set_spec.rb +1 -0
  128. data/spec/integration/knife/node_show_spec.rb +1 -0
  129. data/spec/integration/knife/raw_spec.rb +1 -0
  130. data/spec/integration/knife/redirection_spec.rb +1 -0
  131. data/spec/integration/knife/role_bulk_delete_spec.rb +1 -0
  132. data/spec/integration/knife/role_create_spec.rb +1 -0
  133. data/spec/integration/knife/role_delete_spec.rb +1 -0
  134. data/spec/integration/knife/role_from_file_spec.rb +1 -0
  135. data/spec/integration/knife/role_list_spec.rb +1 -0
  136. data/spec/integration/knife/role_show_spec.rb +1 -0
  137. data/spec/integration/knife/search_node_spec.rb +1 -0
  138. data/spec/integration/knife/show_spec.rb +1 -0
  139. data/spec/integration/knife/upload_spec.rb +1 -0
  140. data/spec/integration/recipes/accumulator_spec.rb +1 -0
  141. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -0
  142. data/spec/integration/recipes/lwrp_spec.rb +1 -0
  143. data/spec/integration/recipes/notifies_spec.rb +1 -0
  144. data/spec/integration/recipes/notifying_block_spec.rb +1 -0
  145. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
  146. data/spec/integration/recipes/resource_action_spec.rb +1 -0
  147. data/spec/integration/recipes/unified_mode_spec.rb +1 -0
  148. data/spec/integration/solo/solo_spec.rb +1 -0
  149. data/spec/spec_helper.rb +7 -10
  150. data/spec/support/chef_helpers.rb +1 -1
  151. data/spec/support/key_helpers.rb +0 -2
  152. data/spec/support/platform_helpers.rb +7 -3
  153. data/spec/support/platforms/win32/spec_service.rb +27 -25
  154. data/spec/support/shared/context/config.rb +0 -3
  155. data/spec/support/shared/integration/integration_helper.rb +0 -1
  156. data/spec/support/shared/unit/execute_resource.rb +0 -2
  157. data/spec/support/shared/unit/provider/file.rb +0 -1
  158. data/spec/support/shared/unit/script_resource.rb +2 -4
  159. data/spec/support/shared/unit/windows_script_resource.rb +0 -2
  160. data/spec/unit/cookbook/gem_installer_spec.rb +1 -1
  161. data/spec/unit/cookbook/metadata_spec.rb +1 -10
  162. data/spec/unit/data_collector_spec.rb +1 -1
  163. data/spec/unit/deprecated_spec.rb +3 -3
  164. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +1 -1
  165. data/spec/unit/encrypted_data_bag_item_spec.rb +2 -2
  166. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +3 -3
  167. data/spec/unit/knife_spec.rb +6 -7
  168. data/spec/unit/mixin/shell_out_spec.rb +27 -29
  169. data/spec/unit/provider/file_spec.rb +1 -0
  170. data/spec/unit/resource/build_essential_spec.rb +48 -2
  171. data/spec/unit/resource/data/InstallHistory_with_CLT.plist +92 -0
  172. data/spec/unit/resource/data/InstallHistory_without_CLT.plist +38 -0
  173. data/spec/unit/resource/execute_spec.rb +1 -1
  174. data/spec/unit/resource/rhsm_register_spec.rb +24 -0
  175. data/spec/unit/resource/windows_share_spec.rb +3 -1
  176. data/tasks/rspec.rb +1 -0
  177. metadata +8 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4bfd0936e85a14def6d08f1d293f5ae247bb89a845342f6c7818856627bd77b
4
- data.tar.gz: 9716dcf24df69c197fe6064788e2ed5f81d47395d1beeabfc8b750425c53f3a8
3
+ metadata.gz: 1250f5368650d0abc11260a7aaa7099d09a77c2b132202bca6999f3cfe4e1036
4
+ data.tar.gz: 658b91416f006f790140de07fa26fdd8148246ff555006e706a34bdb2419c6a2
5
5
  SHA512:
6
- metadata.gz: 6aaffecb25528b55237179dc9bcc06849700cfed58765826a136d59b1d5f72280f7c6879b0bcf79ba9d408ec54336db7dc4a1ccf6ac934abcd495ab2c843c3f9
7
- data.tar.gz: 3c495b0ab4f181c2ebec8c5a84bff67dbec5afc615211011233fed31cb8b0b7e48838ac2ec9e3d937018bf7e337652bc54036c9210353d2da42dfe48057143ff
6
+ metadata.gz: f35c60ef7d4fd61f9765832b0ac672c5232ce5761f36e4d1929c1b251f2a088c397fa85ccf36ae69622204422ce8be36d8075a3ee8094bb115589060aeeeda18
7
+ data.tar.gz: 2351c5b376949a20c9d144141051d1b52e426d150a6500e50e7239ce4087eb0c8ac0c7a67bd0b043c741e27dbaf237c3cf4105ebdcb77f2047613293364619e2
data/Gemfile CHANGED
@@ -46,7 +46,8 @@ end
46
46
 
47
47
  # Everything except AIX
48
48
  group(:ruby_prof) do
49
- gem "ruby-prof"
49
+ # ruby-prof 1.3.0 does not compile on our centos6 builders/kitchen testers
50
+ gem "ruby-prof", "< 1.3.0"
50
51
  end
51
52
 
52
53
  # Everything except AIX and Windows
@@ -58,7 +59,7 @@ group(:development, :test) do
58
59
  # we pin rake as a copy of rake is installed from the ruby source
59
60
  # if you bump the ruby version you should confirm we don't end up with
60
61
  # two rake gems installed again
61
- gem "rake", "<= 12.3.2"
62
+ gem "rake", "<= 12.3.3"
62
63
 
63
64
  gem "rspec-core", "~> 3.5"
64
65
  gem "rspec-mocks", "~> 3.5"
data/README.md CHANGED
@@ -22,7 +22,7 @@ For Chef Infra usage, please refer to our [Learn Chef Rally](https://learn.chef.
22
22
 
23
23
  Other useful resources for Chef Infra users:
24
24
 
25
- - Documentation: <https://docs.chef.io>
25
+ - Documentation: <https://docs.chef.io/>
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/)
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ begin
22
22
  require_relative "tasks/dependencies"
23
23
  require_relative "tasks/announce"
24
24
  require_relative "tasks/docs"
25
+ require_relative "lib/chef/dist"
25
26
  rescue LoadError => e
26
27
  puts "Skipping missing rake dep: #{e}"
27
28
  end
@@ -35,6 +36,14 @@ task :super_install do
35
36
  Dir.chdir(path)
36
37
  sh("rake install")
37
38
  end
39
+
40
+ # Templating the powershell extensions so we can inject distro constants
41
+ template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
42
+ psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
43
+ FileUtils.mkdir_p psm1_path
44
+ template = ERB.new(IO.read(template_file))
45
+ chef_psm1 = template.result
46
+ File.open(::File.join(psm1_path, "chef.psm1"), "w") { |f| f.write(chef_psm1) }
38
47
  end
39
48
 
40
49
  task install: :super_install
@@ -19,7 +19,6 @@
19
19
  require "pp" unless defined?(PP)
20
20
  require "socket" unless defined?(Socket)
21
21
  require_relative "config"
22
- require_relative "config_fetcher"
23
22
  require_relative "exceptions"
24
23
  require_relative "local_mode"
25
24
  require_relative "log"
@@ -119,6 +118,7 @@ class Chef
119
118
 
120
119
  # @api private (test injection)
121
120
  def chef_configfetcher
121
+ require_relative "config_fetcher"
122
122
  Chef::ConfigFetcher
123
123
  end
124
124
 
@@ -775,7 +775,7 @@ class Chef
775
775
  end
776
776
 
777
777
  elsif path.length == 2 && path[0] != "cookbooks"
778
- path[1] = path[1].gsub(/\.(rb|json)/, "")
778
+ path[1] = path[1].gsub(/\.(rb|json)$/, "")
779
779
  end
780
780
 
781
781
  path
@@ -190,9 +190,9 @@ class Chef
190
190
  are_same, old_value, new_value = Chef::ChefFS::FileSystem.compare(old_entry, new_entry)
191
191
  if are_same
192
192
  if old_value == :none
193
- return [ [ :both_nonexistent, old_entry, new_entry ] ]
193
+ [ [ :both_nonexistent, old_entry, new_entry ] ]
194
194
  else
195
- return [ [ :same, old_entry, new_entry ] ]
195
+ [ [ :same, old_entry, new_entry ] ]
196
196
  end
197
197
  else
198
198
  if old_value == :none
@@ -235,11 +235,11 @@ class Chef
235
235
  end
236
236
 
237
237
  if old_value == :none || (old_value.nil? && !old_entry.exists?)
238
- return [ [ :added, old_entry, new_entry, old_value, new_value ] ]
238
+ [ [ :added, old_entry, new_entry, old_value, new_value ] ]
239
239
  elsif new_value == :none
240
- return [ [ :deleted, old_entry, new_entry, old_value, new_value ] ]
240
+ [ [ :deleted, old_entry, new_entry, old_value, new_value ] ]
241
241
  else
242
- return [ [ :modified, old_entry, new_entry, old_value, new_value ] ]
242
+ [ [ :modified, old_entry, new_entry, old_value, new_value ] ]
243
243
  end
244
244
  end
245
245
  end
@@ -604,7 +604,7 @@ class Chef
604
604
  msg = <<~OBSOLETED
605
605
  The dependency specification syntax you are using is no longer valid. You may not
606
606
  specify more than one version constraint for a particular cookbook.
607
- Consult https://docs.chef.io/config_rb_metadata.html for the updated syntax.
607
+ Consult https://docs.chef.io/config_rb_metadata/ for the updated syntax.
608
608
 
609
609
  Called by: #{caller_name} '#{dep_name}', #{version_constraints.map(&:inspect).join(", ")}
610
610
  Called from:
@@ -621,9 +621,10 @@ class Chef
621
621
 
622
622
  msg = <<~INVALID
623
623
  The version constraint syntax you are using is not valid. If you recently
624
- upgraded to Chef 0.10.0, be aware that you no may longer use "<<" and ">>" for
625
- 'less than' and 'greater than'; use '<' and '>' instead.
626
- Consult https://docs.chef.io/config_rb_metadata.html for more information.
624
+ upgraded from Chef Infra releases before 0.10, be aware that you no may
625
+ longer use "<<" and ">>" for 'less than' and 'greater than'; use '<' and
626
+ '>' instead. Consult https://docs.chef.io/config_rb_metadata/ for more
627
+ information.
627
628
 
628
629
  Called by: #{caller_name} '#{dep_name}', '#{constraint_str}'
629
630
  Called from:
@@ -47,6 +47,7 @@ class Chef
47
47
  end
48
48
 
49
49
  def reset!
50
+ @skip_removal = nil
50
51
  @valid_cache_entries = {}
51
52
  end
52
53
 
@@ -88,7 +88,7 @@ class Chef
88
88
  # @return [Chef::CookbookVersion]
89
89
  def load_cookbook(cookbook_name)
90
90
  unless cookbook_version_loaders.key?(cookbook_name)
91
- raise Exceptions::CookbookNotFoundInRepo, "Cannot find a cookbook named #{cookbook_name}; did you forget to add metadata to a cookbook? (https://docs.chef.io/config_rb_metadata.html)"
91
+ raise Exceptions::CookbookNotFoundInRepo, "Cannot find a cookbook named #{cookbook_name}; did you forget to add metadata to a cookbook? (https://docs.chef.io/config_rb_metadata/)"
92
92
  end
93
93
 
94
94
  return cookbooks_by_name[cookbook_name] if cookbooks_by_name.key?(cookbook_name)
@@ -77,27 +77,27 @@ class Chef
77
77
  case
78
78
  when Chef::Config[:why_run]
79
79
  Chef::Log.trace("data collector is disabled for why run mode")
80
- return false
80
+ false
81
81
  when (want_mode != :both) && running_mode != want_mode
82
82
  Chef::Log.trace("data collector is configured to only run in #{Chef::Config[:data_collector][:mode]} modes, disabling it")
83
- return false
83
+ false
84
84
  when !(Chef::Config[:data_collector][:server_url] || Chef::Config[:data_collector][:output_locations])
85
85
  Chef::Log.trace("Neither data collector URL or output locations have been configured, disabling data collector")
86
- return false
86
+ false
87
87
  when running_mode == :client && Chef::Config[:data_collector][:token]
88
88
  Chef::Log.warn("Data collector token authentication is not recommended for client-server mode. " \
89
89
  "Please upgrade #{Chef::Dist::SERVER_PRODUCT} to 12.11 or later and remove the token from your config file " \
90
90
  "to use key based authentication instead")
91
- return true
91
+ true
92
92
  when Chef::Config[:data_collector][:output_locations] && Chef::Config[:data_collector][:output_locations][:files] && !Chef::Config[:data_collector][:output_locations][:files].empty?
93
93
  # we can run fine to a file without a token, even in solo mode.
94
- return true
94
+ true
95
95
  when running_mode == :solo && !Chef::Config[:data_collector][:token]
96
96
  # we are in solo mode and are not logging to a file, so must have a token
97
97
  Chef::Log.trace("Data collector token must be configured to use #{Chef::Dist::AUTOMATE} data collector with #{Chef::Dist::SOLO}")
98
- return false
98
+ false
99
99
  else
100
- return true
100
+ true
101
101
  end
102
102
  end
103
103
 
@@ -47,7 +47,7 @@ class Chef
47
47
  #
48
48
  # @return [String]
49
49
  def url
50
- "#{BASE_URL}#{self.class.doc_page}"
50
+ "#{BASE_URL}#{self.class.doc_page}/"
51
51
  end
52
52
 
53
53
  # Render the user-visible message for this deprecation.
@@ -104,7 +104,7 @@ class Chef
104
104
  #
105
105
  # @example
106
106
  # class MyDeprecation < Base
107
- # target 123, "my_deprecation.html"
107
+ # target 123, "my_deprecation"
108
108
  # end
109
109
  # @param id [Integer] Deprecation ID number. This must be unique among
110
110
  # all deprecations.
@@ -113,7 +113,7 @@ class Chef
113
113
  # @return [void]
114
114
  def target(id, page = nil)
115
115
  @deprecation_id = id
116
- @doc_page = page || "#{deprecation_key}.html"
116
+ @doc_page = page || "#{deprecation_key}"
117
117
  end
118
118
  end
119
119
  end
@@ -137,7 +137,7 @@ class Chef
137
137
  end
138
138
 
139
139
  class CustomResource < Base
140
- target 5, "custom_resource_cleanups.html"
140
+ target 5, "custom_resource_cleanups"
141
141
  end
142
142
 
143
143
  class EasyInstall < Base
@@ -235,7 +235,7 @@ class Chef
235
235
 
236
236
  class Generic < Base
237
237
  def url
238
- "https://docs.chef.io/chef_deprecations_client.html"
238
+ "https://docs.chef.io/chef_deprecations_client/"
239
239
  end
240
240
 
241
241
  def to_s
@@ -90,9 +90,9 @@ class Chef
90
90
 
91
91
  case key_matches.length
92
92
  when 0
93
- return nil
93
+ nil
94
94
  when 1
95
- return @values[platform][key_matches.first]
95
+ @values[platform][key_matches.first]
96
96
  else
97
97
  raise "Multiple matches detected for #{platform} with values #{@values}. The matches are: #{key_matches}"
98
98
  end
@@ -39,11 +39,11 @@ class Chef
39
39
  # http://technet.microsoft.com/en-us/library/cc960241.aspx
40
40
  registry_value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }) ||
41
41
 
42
- # RebootRequired key contains Update IDs with a value of 1 if they require a reboot.
43
- # The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update
42
+ # RebootRequired key contains Update IDs with a value of 1 if they require a reboot.
43
+ # The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update
44
44
  registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') ||
45
45
 
46
- # Vista + Server 2008 and newer may have reboots pending from CBS
46
+ # Vista + Server 2008 and newer may have reboots pending from CBS
47
47
  registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending')
48
48
  elsif platform?("ubuntu")
49
49
  # This should work for Debian as well if update-notifier-common happens to be installed. We need an API for that.
@@ -65,7 +65,7 @@ class Chef
65
65
  if http_response.body
66
66
  Chef::Log.trace("Response body contains:\n#{http_response.body.length < 256 ? http_response.body : http_response.body[0..256] + " [...truncated...]"}")
67
67
  end
68
- return [http_response, rest_request, http_response.body.to_s]
68
+ [http_response, rest_request, http_response.body.to_s]
69
69
  end
70
70
  end
71
71
 
@@ -191,7 +191,7 @@ class Chef
191
191
  config_loader.profile = profile
192
192
  config_loader.load
193
193
 
194
- ui.warn("No knife configuration file found. See https://docs.chef.io/config_rb_knife.html for details.") if config_loader.no_config_found?
194
+ ui.warn("No knife configuration file found. See https://docs.chef.io/config_rb/ for details.") if config_loader.no_config_found?
195
195
 
196
196
  config_loader
197
197
  rescue Exceptions::ConfigurationError => e
@@ -5,7 +5,7 @@ standardized on the [Omnibus](https://github.com/chef/omnibus) built installatio
5
5
  packages.
6
6
 
7
7
  The 'chef-full' template downloads a script which is used to determine the correct
8
- Omnibus package for this system from the [Omnitruck](https://docs.chef.io/api_omnitruck.html) API.
8
+ Omnibus package for this system from the [Omnitruck](https://docs.chef.io/api_omnitruck/) API.
9
9
 
10
10
  You can still utilize custom bootstrap templates on your system if your installation
11
- needs are unique. Additional information can be found on the [docs site](https://docs.chef.io/knife_bootstrap.html#custom-templates).
11
+ needs are unique. Additional information can be found on the [docs site](https://docs.chef.io/knife_bootstrap/#custom-templates).
@@ -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 /etc/chef
188
+ mkdir -p <%= ChefConfig::Config.etc_chef_dir(false) %>
189
189
 
190
190
  <% if client_pem -%>
191
- (umask 077 && (cat > /etc/chef/client.pem <<'EOP'
191
+ (umask 077 && (cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/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 > /etc/chef/validation.pem <<'EOP'
198
+ (umask 077 && (cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/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 > /etc/chef/encrypted_data_bag_secret <<'EOP'
205
+ (umask 077 && (cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/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 /etc/chef/trusted_certs
212
+ mkdir -p <%= ChefConfig::Config.etc_chef_dir(false) %>/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 /etc/chef/ohai/hints
218
+ mkdir -p <%= ChefConfig::Config.etc_chef_dir(false) %>/ohai/hints
219
219
 
220
220
  <% @chef_config[:knife][:hints].each do |name, hash| -%>
221
- cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
221
+ cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/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 > /etc/chef/client.rb <<'EOP'
227
+ cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/client.rb <<'EOP'
228
228
  <%= config_content %>
229
229
  EOP
230
230
 
231
- cat > /etc/chef/first-boot.json <<'EOP'
231
+ cat > <%= ChefConfig::Config.etc_chef_dir(false) %>/first-boot.json <<'EOP'
232
232
  <%= Chef::JSONCompat.to_json(first_boot) %>
233
233
  EOP
234
234
 
@@ -120,11 +120,11 @@ If !ERRORLEVEL!==0 (
120
120
  )
121
121
 
122
122
  :install
123
- @rem If user has provided the custom installation command for <%= Chef::Dist::CLIENT %> then execute it
123
+ @rem If user has provided the custom installation command, execute it
124
124
  <% if @chef_config[:knife][:bootstrap_install_command] %>
125
125
  <%= @chef_config[:knife][:bootstrap_install_command] %>
126
126
  <% else %>
127
- @rem Install Chef using <%= Chef::Dist::CLIENT %> MSI installer
127
+ @rem Install Chef using the MSI installer
128
128
 
129
129
  @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>"
130
130
  @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\<%= Chef::Dist::CLIENT %>-msi%RANDOM%.log"
@@ -208,7 +208,7 @@ class Chef
208
208
  tf.sync = true
209
209
  tf.puts output
210
210
  tf.close
211
- raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup.html for details." unless system("#{config[:editor]} #{tf.path}")
211
+ raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup/ for details." unless system("#{config[:editor]} #{tf.path}")
212
212
 
213
213
  output = IO.read(tf.path)
214
214
  end
@@ -59,9 +59,9 @@ class Chef
59
59
  client_rb = <<~CONFIG
60
60
  chef_server_url "#{@chef_config[:chef_server_url]}"
61
61
  validation_client_name "#{@chef_config[:validation_client_name]}"
62
- file_cache_path "c:/chef/cache"
63
- file_backup_path "c:/chef/backup"
64
- cache_options ({:path => "c:/chef/cache/checksums", :skip_expires => true})
62
+ file_cache_path "#{ChefConfig::Config.var_chef_dir(true)}/cache"
63
+ file_backup_path "#{ChefConfig::Config.var_chef_dir(true)}/backup"
64
+ cache_options ({:path => "#{ChefConfig::Config.etc_chef_dir(true)}/cache/checksums", :skip_expires => true})
65
65
  CONFIG
66
66
 
67
67
  unless @chef_config[:chef_license].nil?
@@ -124,11 +124,11 @@ class Chef
124
124
  end
125
125
 
126
126
  if @config[:secret]
127
- client_rb << %Q{encrypted_data_bag_secret "c:/chef/encrypted_data_bag_secret"\n}
127
+ client_rb << %Q{encrypted_data_bag_secret "#{ChefConfig::Config.etc_chef_dir(true)}/encrypted_data_bag_secret"\n}
128
128
  end
129
129
 
130
130
  unless trusted_certs_script.empty?
131
- client_rb << %Q{trusted_certs_dir "c:/chef/trusted_certs"\n}
131
+ client_rb << %Q{trusted_certs_dir "#{ChefConfig::Config.etc_chef_dir(true)}/trusted_certs"\n}
132
132
  end
133
133
 
134
134
  if Chef::Config[:fips]
@@ -158,8 +158,8 @@ class Chef
158
158
 
159
159
  def start_chef
160
160
  bootstrap_environment_option = bootstrap_environment.nil? ? "" : " -E #{bootstrap_environment}"
161
- start_chef = "SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\;%PATH%\"\n"
162
- start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json#{bootstrap_environment_option}\n"
161
+ start_chef = "SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;#{ChefConfig::Config.c_opscode_dir}\\#{ChefConfig::Dist::DIR_SUFFIX}\\bin;#{ChefConfig::Config.c_opscode_dir}\\#{ChefConfig::Dist::DIR_SUFFIX}\\embedded\\bin\;%PATH%\"\n"
162
+ start_chef << "chef-client -c #{ChefConfig::Config.etc_chef_dir(true)}/client.rb -j #{ChefConfig::Config.etc_chef_dir(true)}/first-boot.json#{bootstrap_environment_option}\n"
163
163
  end
164
164
 
165
165
  def win_wget
@@ -260,7 +260,7 @@ class Chef
260
260
  end
261
261
 
262
262
  def bootstrap_directory
263
- "C:\\chef"
263
+ ChefConfig::Config.etc_chef_dir(true)
264
264
  end
265
265
 
266
266
  def local_download_path
@@ -37,13 +37,13 @@ class Chef
37
37
  item = Chef::DataBagItem.load(bag, item_name)
38
38
  if encrypted?(item.raw_data)
39
39
  if encryption_secret_provided_ignore_encrypt_flag?
40
- return Chef::EncryptedDataBagItem.new(item, read_secret).to_hash, true
40
+ [Chef::EncryptedDataBagItem.new(item, read_secret).to_hash, true]
41
41
  else
42
42
  ui.fatal("You cannot edit an encrypted data bag without providing the secret.")
43
43
  exit(1)
44
44
  end
45
45
  else
46
- return item.raw_data, false
46
+ [item.raw_data, false]
47
47
  end
48
48
  end
49
49