chef 15.8.23-universal-mingw32 → 15.9.17-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) 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/distro/powershell/chef/chef.psm1 +459 -459
  6. data/distro/templates/powershell/chef/chef.psm1.erb +459 -0
  7. data/lib/chef/application.rb +1 -1
  8. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  9. data/lib/chef/chef_fs/command_line.rb +5 -5
  10. data/lib/chef/cookbook/metadata.rb +5 -4
  11. data/lib/chef/cookbook/synchronizer.rb +1 -0
  12. data/lib/chef/cookbook_loader.rb +1 -1
  13. data/lib/chef/data_collector/config_validation.rb +7 -7
  14. data/lib/chef/deprecated.rb +5 -5
  15. data/lib/chef/dsl/platform_introspection.rb +2 -2
  16. data/lib/chef/dsl/reboot_pending.rb +3 -3
  17. data/lib/chef/http/json_output.rb +1 -1
  18. data/lib/chef/knife.rb +1 -1
  19. data/lib/chef/knife/bootstrap/templates/README.md +2 -2
  20. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  21. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
  22. data/lib/chef/knife/core/ui.rb +1 -1
  23. data/lib/chef/knife/core/windows_bootstrap_context.rb +8 -8
  24. data/lib/chef/knife/data_bag_edit.rb +2 -2
  25. data/lib/chef/knife/edit.rb +1 -1
  26. data/lib/chef/knife/environment_compare.rb +1 -1
  27. data/lib/chef/knife/list.rb +1 -1
  28. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  29. data/lib/chef/provider/group/usermod.rb +2 -5
  30. data/lib/chef/provider/mount/mount.rb +1 -1
  31. data/lib/chef/provider/package/homebrew.rb +1 -2
  32. data/lib/chef/provider/package/rubygems.rb +1 -1
  33. data/lib/chef/provider/package/yum/python_helper.rb +2 -2
  34. data/lib/chef/provider/package/yum/rpm_utils.rb +4 -4
  35. data/lib/chef/provider/package/zypper.rb +2 -1
  36. data/lib/chef/provider/remote_file.rb +2 -2
  37. data/lib/chef/provider/route.rb +4 -4
  38. data/lib/chef/provider/windows_env.rb +3 -3
  39. data/lib/chef/resource.rb +7 -2
  40. data/lib/chef/resource/build_essential.rb +46 -22
  41. data/lib/chef/resource/cron.rb +1 -1
  42. data/lib/chef/resource/cron_d.rb +1 -1
  43. data/lib/chef/resource/execute.rb +1 -1
  44. data/lib/chef/resource/freebsd_package.rb +0 -3
  45. data/lib/chef/resource/homebrew_package.rb +1 -2
  46. data/lib/chef/resource/hostname.rb +2 -2
  47. data/lib/chef/resource/kernel_module.rb +3 -2
  48. data/lib/chef/resource/openbsd_package.rb +0 -3
  49. data/lib/chef/resource/remote_file.rb +1 -1
  50. data/lib/chef/resource/rhsm_errata.rb +9 -2
  51. data/lib/chef/resource/rhsm_errata_level.rb +11 -5
  52. data/lib/chef/resource/rhsm_register.rb +27 -12
  53. data/lib/chef/resource/swap_file.rb +2 -2
  54. data/lib/chef/resource/timezone.rb +2 -2
  55. data/lib/chef/resource/windows_certificate.rb +0 -2
  56. data/lib/chef/resource/windows_share.rb +1 -1
  57. data/lib/chef/shell/ext.rb +1 -1
  58. data/lib/chef/util/diff.rb +3 -3
  59. data/lib/chef/util/selinux.rb +2 -2
  60. data/lib/chef/version.rb +1 -1
  61. data/lib/chef/win32/error.rb +1 -1
  62. data/lib/chef/win32/registry.rb +1 -1
  63. data/spec/data/cookbooks/starter/recipes/default.rb +1 -1
  64. data/spec/data/windows_certificates/base64_test.cer +18 -20
  65. data/spec/data/windows_certificates/othertest.cer +0 -0
  66. data/spec/data/windows_certificates/test.cer +0 -0
  67. data/spec/data/windows_certificates/test.p7b +0 -0
  68. data/spec/data/windows_certificates/test.pem +18 -19
  69. data/spec/data/windows_certificates/test.pfx +0 -0
  70. data/spec/functional/resource/ifconfig_spec.rb +2 -2
  71. data/spec/functional/resource/windows_certificate_spec.rb +9 -9
  72. data/spec/functional/resource/windows_service_spec.rb +1 -2
  73. data/spec/functional/run_lock_spec.rb +7 -1
  74. data/spec/functional/win32/service_manager_spec.rb +1 -1
  75. data/spec/functional/win32/version_info_spec.rb +4 -4
  76. data/spec/integration/client/client_spec.rb +2 -2
  77. data/spec/integration/client/exit_code_spec.rb +1 -0
  78. data/spec/integration/client/ipv6_spec.rb +1 -0
  79. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -0
  80. data/spec/integration/knife/chef_repo_path_spec.rb +1 -0
  81. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -0
  82. data/spec/integration/knife/chefignore_spec.rb +1 -0
  83. data/spec/integration/knife/client_bulk_delete_spec.rb +1 -0
  84. data/spec/integration/knife/client_create_spec.rb +1 -0
  85. data/spec/integration/knife/client_delete_spec.rb +1 -0
  86. data/spec/integration/knife/client_key_create_spec.rb +1 -0
  87. data/spec/integration/knife/client_key_delete_spec.rb +1 -0
  88. data/spec/integration/knife/client_key_list_spec.rb +1 -0
  89. data/spec/integration/knife/client_key_show_spec.rb +1 -0
  90. data/spec/integration/knife/client_list_spec.rb +1 -0
  91. data/spec/integration/knife/client_show_spec.rb +1 -0
  92. data/spec/integration/knife/common_options_spec.rb +1 -0
  93. data/spec/integration/knife/config_get_profile_spec.rb +1 -0
  94. data/spec/integration/knife/config_get_spec.rb +1 -0
  95. data/spec/integration/knife/config_list_profiles_spec.rb +1 -0
  96. data/spec/integration/knife/config_use_profile_spec.rb +1 -0
  97. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -0
  98. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +1 -0
  99. data/spec/integration/knife/cookbook_download_spec.rb +1 -0
  100. data/spec/integration/knife/cookbook_list_spec.rb +1 -0
  101. data/spec/integration/knife/cookbook_show_spec.rb +1 -0
  102. data/spec/integration/knife/cookbook_upload_spec.rb +1 -0
  103. data/spec/integration/knife/data_bag_create_spec.rb +1 -0
  104. data/spec/integration/knife/data_bag_delete_spec.rb +1 -0
  105. data/spec/integration/knife/data_bag_edit_spec.rb +1 -0
  106. data/spec/integration/knife/data_bag_from_file_spec.rb +1 -0
  107. data/spec/integration/knife/data_bag_list_spec.rb +1 -0
  108. data/spec/integration/knife/data_bag_show_spec.rb +1 -0
  109. data/spec/integration/knife/delete_spec.rb +1 -0
  110. data/spec/integration/knife/deps_spec.rb +3 -2
  111. data/spec/integration/knife/diff_spec.rb +1 -0
  112. data/spec/integration/knife/download_spec.rb +1 -0
  113. data/spec/integration/knife/environment_compare_spec.rb +1 -0
  114. data/spec/integration/knife/environment_create_spec.rb +1 -0
  115. data/spec/integration/knife/environment_delete_spec.rb +1 -0
  116. data/spec/integration/knife/environment_from_file_spec.rb +1 -0
  117. data/spec/integration/knife/environment_list_spec.rb +1 -0
  118. data/spec/integration/knife/environment_show_spec.rb +1 -0
  119. data/spec/integration/knife/list_spec.rb +1 -0
  120. data/spec/integration/knife/node_bulk_delete_spec.rb +1 -0
  121. data/spec/integration/knife/node_create_spec.rb +1 -0
  122. data/spec/integration/knife/node_delete_spec.rb +1 -0
  123. data/spec/integration/knife/node_environment_set_spec.rb +1 -0
  124. data/spec/integration/knife/node_from_file_spec.rb +1 -0
  125. data/spec/integration/knife/node_list_spec.rb +1 -0
  126. data/spec/integration/knife/node_run_list_add_spec.rb +1 -0
  127. data/spec/integration/knife/node_run_list_remove_spec.rb +1 -0
  128. data/spec/integration/knife/node_run_list_set_spec.rb +1 -0
  129. data/spec/integration/knife/node_show_spec.rb +1 -0
  130. data/spec/integration/knife/raw_spec.rb +1 -0
  131. data/spec/integration/knife/redirection_spec.rb +1 -0
  132. data/spec/integration/knife/role_bulk_delete_spec.rb +1 -0
  133. data/spec/integration/knife/role_create_spec.rb +1 -0
  134. data/spec/integration/knife/role_delete_spec.rb +1 -0
  135. data/spec/integration/knife/role_from_file_spec.rb +1 -0
  136. data/spec/integration/knife/role_list_spec.rb +1 -0
  137. data/spec/integration/knife/role_show_spec.rb +1 -0
  138. data/spec/integration/knife/search_node_spec.rb +1 -0
  139. data/spec/integration/knife/show_spec.rb +1 -0
  140. data/spec/integration/knife/upload_spec.rb +1 -0
  141. data/spec/integration/recipes/accumulator_spec.rb +1 -0
  142. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -0
  143. data/spec/integration/recipes/lwrp_spec.rb +1 -0
  144. data/spec/integration/recipes/notifies_spec.rb +1 -0
  145. data/spec/integration/recipes/notifying_block_spec.rb +1 -0
  146. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
  147. data/spec/integration/recipes/resource_action_spec.rb +1 -0
  148. data/spec/integration/recipes/unified_mode_spec.rb +1 -0
  149. data/spec/integration/solo/solo_spec.rb +1 -0
  150. data/spec/spec_helper.rb +7 -10
  151. data/spec/support/chef_helpers.rb +1 -1
  152. data/spec/support/key_helpers.rb +0 -2
  153. data/spec/support/platform_helpers.rb +7 -3
  154. data/spec/support/platforms/win32/spec_service.rb +27 -25
  155. data/spec/support/shared/context/config.rb +0 -3
  156. data/spec/support/shared/integration/integration_helper.rb +0 -1
  157. data/spec/support/shared/unit/execute_resource.rb +0 -2
  158. data/spec/support/shared/unit/provider/file.rb +0 -1
  159. data/spec/support/shared/unit/script_resource.rb +2 -4
  160. data/spec/support/shared/unit/windows_script_resource.rb +0 -2
  161. data/spec/unit/cookbook/gem_installer_spec.rb +1 -1
  162. data/spec/unit/cookbook/metadata_spec.rb +1 -10
  163. data/spec/unit/data_collector_spec.rb +1 -1
  164. data/spec/unit/deprecated_spec.rb +3 -3
  165. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +1 -1
  166. data/spec/unit/encrypted_data_bag_item_spec.rb +2 -2
  167. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +3 -3
  168. data/spec/unit/knife_spec.rb +6 -7
  169. data/spec/unit/mixin/shell_out_spec.rb +27 -29
  170. data/spec/unit/provider/file_spec.rb +1 -0
  171. data/spec/unit/resource/build_essential_spec.rb +48 -2
  172. data/spec/unit/resource/data/InstallHistory_with_CLT.plist +92 -0
  173. data/spec/unit/resource/data/InstallHistory_without_CLT.plist +38 -0
  174. data/spec/unit/resource/execute_spec.rb +1 -1
  175. data/spec/unit/resource/rhsm_register_spec.rb +24 -0
  176. data/spec/unit/resource/windows_share_spec.rb +3 -1
  177. data/tasks/rspec.rb +1 -0
  178. metadata +9 -6
@@ -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
 
@@ -74,7 +74,7 @@ class Chef
74
74
 
75
75
  # Let the user edit the temporary file
76
76
  unless system("#{config[:editor]} #{file.path}")
77
- raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup.html for details."
77
+ raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup/ for details."
78
78
  end
79
79
 
80
80
  result_text = IO.read(file.path)
@@ -81,7 +81,7 @@ class Chef
81
81
 
82
82
  def constraint_list(environments)
83
83
  constraints = {}
84
- environments.each do |env, url| # rubocop:disable Performance/HashEachMethods
84
+ environments.each do |env, url| # rubocop:disable Style/HashEachMethods
85
85
  # Because you cannot modify the default environment I filter it out here.
86
86
  unless env == "_default"
87
87
  envdata = Chef::Environment.load(env)
@@ -90,7 +90,7 @@ class Chef
90
90
 
91
91
  # Flatten out directory results if necessary
92
92
  if config[:flat]
93
- dir_results.each do |result, children| # rubocop:disable Performance/HashEachMethods
93
+ dir_results.each do |result, children| # rubocop:disable Style/HashEachMethods
94
94
  results += children
95
95
  end
96
96
  dir_results = []
@@ -55,7 +55,7 @@ class Chef
55
55
  The server that received the request supports a min version of #{min_version} and a max version of #{max_version}.
56
56
  User keys are now managed via the key rotation commmands.
57
57
  Please refer to the documentation on how to manage your keys via the key rotation commands:
58
- https://docs.chef.io/server_security.html#key-rotation
58
+ https://docs.chef.io/ctl_chef_server/#key-rotation
59
59
  EOH
60
60
  end
61
61
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: AJ Christensen (<aj@chef.io>)
3
- # Copyright:: Copyright 2008-2019, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2020, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -76,10 +76,7 @@ class Chef
76
76
  end
77
77
 
78
78
  def append_flags
79
- case node[:platform]
80
- when "openbsd", "netbsd", "aix", "smartos", "omnios"
81
- "-G"
82
- end
79
+ "-G" if platform?("openbsd", "netbsd", "aix", "smartos", "omnios")
83
80
  end
84
81
 
85
82
  end
@@ -157,7 +157,7 @@ class Chef
157
157
 
158
158
  # Return appropriate default mount options according to the given os.
159
159
  def default_mount_options
160
- node[:os] == "linux" ? "defaults" : "rw"
160
+ linux? ? "defaults" : "rw"
161
161
  end
162
162
 
163
163
  def enable_fs