chef 15.11.8-universal-mingw32 → 15.16.2-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +12 -13
  3. data/README.md +3 -3
  4. data/Rakefile +11 -17
  5. data/chef-universal-mingw32.gemspec +4 -4
  6. data/chef.gemspec +25 -7
  7. data/distro/powershell/chef/chef.psm1 +3 -3
  8. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  9. data/lib/chef/api_client/registration.rb +2 -2
  10. data/lib/chef/application/apply.rb +1 -1
  11. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  12. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  13. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  15. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  17. data/lib/chef/chef_fs/path_utils.rb +3 -3
  18. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  19. data/lib/chef/data_bag.rb +2 -2
  20. data/lib/chef/data_collector/error_handlers.rb +1 -1
  21. data/lib/chef/deprecated.rb +12 -0
  22. data/lib/chef/dsl/declare_resource.rb +1 -1
  23. data/lib/chef/dsl/platform_introspection.rb +2 -0
  24. data/lib/chef/environment.rb +2 -2
  25. data/lib/chef/exceptions.rb +3 -0
  26. data/lib/chef/http.rb +2 -1
  27. data/lib/chef/knife/bootstrap.rb +6 -9
  28. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  29. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  30. data/lib/chef/knife/cookbook_download.rb +1 -1
  31. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  32. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  33. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  34. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  35. data/lib/chef/knife/exec.rb +2 -2
  36. data/lib/chef/knife/ssh.rb +20 -1
  37. data/lib/chef/log.rb +1 -1
  38. data/lib/chef/mixin/openssl_helper.rb +26 -3
  39. data/lib/chef/mixin/template.rb +1 -0
  40. data/lib/chef/node_map.rb +5 -2
  41. data/lib/chef/provider/mount/solaris.rb +0 -1
  42. data/lib/chef/provider/package/cab.rb +1 -1
  43. data/lib/chef/provider/package/chocolatey.rb +1 -1
  44. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -0
  45. data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
  46. data/lib/chef/provider/package/msu.rb +1 -0
  47. data/lib/chef/provider/package/powershell.rb +5 -1
  48. data/lib/chef/provider/package/snap.rb +96 -27
  49. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  50. data/lib/chef/provider/package/zypper.rb +0 -1
  51. data/lib/chef/provider/service/arch.rb +2 -2
  52. data/lib/chef/provider/service/debian.rb +1 -1
  53. data/lib/chef/provider/service/gentoo.rb +2 -2
  54. data/lib/chef/provider/service/macosx.rb +2 -2
  55. data/lib/chef/provider/service/openbsd.rb +1 -1
  56. data/lib/chef/provider/service/redhat.rb +2 -2
  57. data/lib/chef/provider/service/upstart.rb +1 -1
  58. data/lib/chef/provider/yum_repository.rb +1 -1
  59. data/lib/chef/provider/zypper_repository.rb +31 -11
  60. data/lib/chef/resource.rb +2 -0
  61. data/lib/chef/resource/archive_file.rb +28 -8
  62. data/lib/chef/resource/cron_access.rb +13 -5
  63. data/lib/chef/resource/cron_d.rb +2 -1
  64. data/lib/chef/resource/homebrew_cask.rb +3 -3
  65. data/lib/chef/resource/hostname.rb +19 -18
  66. data/lib/chef/resource/locale.rb +1 -1
  67. data/lib/chef/resource/lwrp_base.rb +7 -0
  68. data/lib/chef/resource/msu_package.rb +5 -0
  69. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  70. data/lib/chef/resource/sudo.rb +2 -2
  71. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  72. data/lib/chef/resource/windows_font.rb +2 -1
  73. data/lib/chef/role.rb +2 -2
  74. data/lib/chef/shell.rb +32 -1
  75. data/lib/chef/shell/shell_session.rb +2 -0
  76. data/lib/chef/util/diff.rb +1 -1
  77. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  78. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  79. data/lib/chef/version.rb +2 -2
  80. data/lib/chef/version_string.rb +1 -1
  81. data/lib/chef/win32/file.rb +2 -2
  82. data/spec/functional/knife/ssh_spec.rb +4 -4
  83. data/spec/functional/resource/aix_service_spec.rb +0 -1
  84. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  85. data/spec/functional/resource/apt_package_spec.rb +0 -1
  86. data/spec/functional/resource/bff_spec.rb +2 -2
  87. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  88. data/spec/functional/resource/cron_spec.rb +0 -1
  89. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  90. data/spec/functional/resource/insserv_spec.rb +4 -5
  91. data/spec/functional/resource/link_spec.rb +17 -17
  92. data/spec/functional/resource/msu_package_spec.rb +5 -2
  93. data/spec/functional/resource/rpm_spec.rb +2 -2
  94. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  95. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  96. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  97. data/spec/functional/resource/windows_font_spec.rb +49 -0
  98. data/spec/functional/resource/windows_task_spec.rb +8 -8
  99. data/spec/functional/run_lock_spec.rb +2 -1
  100. data/spec/functional/shell_spec.rb +5 -5
  101. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  102. data/spec/functional/version_spec.rb +1 -1
  103. data/spec/functional/win32/service_manager_spec.rb +1 -1
  104. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  105. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  106. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  107. data/spec/integration/recipes/notifies_spec.rb +1 -1
  108. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  109. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  110. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  111. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  112. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  113. data/spec/scripts/ssl-serve.rb +1 -1
  114. data/spec/spec_helper.rb +10 -8
  115. data/spec/support/platform_helpers.rb +12 -42
  116. data/spec/support/platforms/win32/spec_service.rb +1 -1
  117. data/spec/support/shared/functional/directory_resource.rb +1 -1
  118. data/spec/support/shared/functional/execute_resource.rb +1 -1
  119. data/spec/support/shared/functional/file_resource.rb +2 -2
  120. data/spec/support/shared/functional/win32_service.rb +1 -1
  121. data/spec/support/shared/functional/windows_script.rb +3 -3
  122. data/spec/support/shared/integration/knife_support.rb +2 -5
  123. data/spec/unit/application_spec.rb +7 -0
  124. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  125. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  126. data/spec/unit/data_bag_spec.rb +1 -1
  127. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  128. data/spec/unit/environment_spec.rb +7 -7
  129. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  130. data/spec/unit/knife/bootstrap_spec.rb +16 -16
  131. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  132. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  133. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  134. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  135. data/spec/unit/knife/ssh_spec.rb +2 -2
  136. data/spec/unit/knife/supermarket_share_spec.rb +5 -3
  137. data/spec/unit/lwrp_spec.rb +4 -4
  138. data/spec/unit/mixin/securable_spec.rb +0 -1
  139. data/spec/unit/mixin/user_context_spec.rb +1 -9
  140. data/spec/unit/property_spec.rb +6 -6
  141. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  142. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  143. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  144. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  145. data/spec/unit/provider/package/snap_spec.rb +1 -1
  146. data/spec/unit/provider/package/windows_spec.rb +30 -53
  147. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  148. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  149. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  150. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  151. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  152. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  153. data/spec/unit/provider/service/windows_spec.rb +2 -6
  154. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  155. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  156. data/spec/unit/provider_spec.rb +1 -0
  157. data/spec/unit/resource/archive_file_spec.rb +11 -2
  158. data/spec/unit/resource/msu_package_spec.rb +4 -0
  159. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  160. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  161. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  162. data/spec/unit/resource/windows_package_spec.rb +1 -0
  163. data/spec/unit/resource/windows_task_spec.rb +1 -1
  164. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  165. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  166. data/spec/unit/resource_spec.rb +1 -1
  167. data/spec/unit/role_spec.rb +11 -11
  168. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  169. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  170. data/spec/unit/win32/security_spec.rb +4 -3
  171. metadata +64 -39
data/lib/chef/resource.rb CHANGED
@@ -613,6 +613,7 @@ class Chef
613
613
  # Do NOT use this. It may be removed. It is for internal purposes only.
614
614
  # @api private
615
615
  attr_reader :resource_initializing
616
+
616
617
  def resource_initializing=(value)
617
618
  if value
618
619
  @resource_initializing = true
@@ -863,6 +864,7 @@ class Chef
863
864
  # have.
864
865
  #
865
866
  attr_writer :allowed_actions
867
+
866
868
  def allowed_actions(value = NOT_PASSED)
867
869
  if value != NOT_PASSED
868
870
  self.allowed_actions = value
@@ -19,6 +19,7 @@
19
19
  #
20
20
 
21
21
  require_relative "../resource"
22
+ require "fileutils" unless defined?(FileUtils)
22
23
 
23
24
  class Chef
24
25
  class Resource
@@ -38,6 +39,18 @@ class Chef
38
39
  destination '/srv/files'
39
40
  end
40
41
  ```
42
+
43
+ **Set specific permissions on the extracted files**:
44
+
45
+ ```ruby
46
+ archive_file 'Precompiled.zip' do
47
+ owner 'tsmith'
48
+ group 'staff'
49
+ mode '700'
50
+ path '/tmp/Precompiled.zip'
51
+ destination '/srv/files'
52
+ end
53
+ ```
41
54
  DOC
42
55
 
43
56
  property :path, String,
@@ -52,7 +65,7 @@ class Chef
52
65
  description: "The group of the extracted files."
53
66
 
54
67
  property :mode, [String, Integer],
55
- description: "The mode of the extracted files.",
68
+ description: "The mode of the extracted files. Integer values are deprecated as octal values (ex. 0755) would not be interpreted correctly.",
56
69
  default: "755"
57
70
 
58
71
  property :destination, String,
@@ -71,11 +84,11 @@ class Chef
71
84
  alias_method :extract_options, :options
72
85
  alias_method :extract_to, :destination
73
86
 
74
- require "fileutils" unless defined?(FileUtils)
75
-
76
87
  action :extract do
77
88
  description "Extract and archive file."
78
89
 
90
+ require_libarchive
91
+
79
92
  unless ::File.exist?(new_resource.path)
80
93
  raise Errno::ENOENT, "No archive found at #{new_resource.path}! Cannot continue."
81
94
  end
@@ -84,7 +97,8 @@ class Chef
84
97
  Chef::Log.trace("File or directory does not exist at destination path: #{new_resource.destination}")
85
98
 
86
99
  converge_by("create directory #{new_resource.destination}") do
87
- FileUtils.mkdir_p(new_resource.destination, mode: new_resource.mode.to_i)
100
+ # @todo when we remove the ability for mode to be an int we can remove the .to_s below
101
+ FileUtils.mkdir_p(new_resource.destination, mode: new_resource.mode.to_s.to_i(8))
88
102
  end
89
103
 
90
104
  extract(new_resource.path, new_resource.destination, Array(new_resource.options))
@@ -112,6 +126,16 @@ class Chef
112
126
  end
113
127
 
114
128
  action_class do
129
+ def require_libarchive
130
+ require "ffi-libarchive"
131
+ end
132
+
133
+ def define_resource_requirements
134
+ if new_resource.mode.is_a?(Integer)
135
+ Chef.deprecated(:archive_file_integer_file_mode, "The mode property should be passed to archive_file resources as a String and not an Integer to ensure the value is properly interpreted.")
136
+ end
137
+ end
138
+
115
139
  # This can't be a constant since we might not have required 'ffi-libarchive' yet.
116
140
  def extract_option_map
117
141
  {
@@ -135,8 +159,6 @@ class Chef
135
159
  #
136
160
  # @return [Boolean]
137
161
  def archive_differs_from_disk?(src, dest)
138
- require "ffi-libarchive"
139
-
140
162
  modified = false
141
163
  Dir.chdir(dest) do
142
164
  archive = Archive::Reader.open_filename(src)
@@ -163,8 +185,6 @@ class Chef
163
185
  #
164
186
  # @return [void]
165
187
  def extract(src, dest, options = [])
166
- require "ffi-libarchive"
167
-
168
188
  converge_by("extract #{src} to #{dest}") do
169
189
  flags = [options].flatten.map { |option| extract_option_map[option] }.compact.reduce(:|)
170
190
 
@@ -27,7 +27,7 @@ class Chef
27
27
  provides(:cron_manage) # legacy name @todo in Chef 15 we should { true } this so it wins over the cookbook
28
28
 
29
29
  introduced "14.4"
30
- description "Use the cron_access resource to manage the /etc/cron.allow and /etc/cron.deny files."
30
+ description "Use the **cron_access** resource to manage cron's cron.allow and cron.deny files. Note: This resource previously shipped in the `cron` cookbook as `cron_manage`, which it can still be used as for backwards compatibility with existing Chef Infra Client releases."
31
31
  examples <<~DOC
32
32
  Add the mike user to cron.allow
33
33
  ```ruby
@@ -54,12 +54,19 @@ class Chef
54
54
  description: "An optional property to set the user name if it differs from the resource block's name.",
55
55
  name_property: true
56
56
 
57
+ CRON_PATHS = {
58
+ "aix" => "/var/adm/cron",
59
+ "solaris" => "/etc/cron.d",
60
+ "default" => "/etc",
61
+ }.freeze
62
+
57
63
  action :allow do
58
64
  description "Add the user to the cron.allow file."
65
+ allow_path = ::File.join(value_for_platform_family(CRON_PATHS), "cron.allow")
59
66
 
60
67
  with_run_context :root do
61
- edit_resource(:template, "/etc/cron.allow") do |new_resource|
62
- source ::File.expand_path("../support/cron_access.erb", __FILE__)
68
+ edit_resource(:template, allow_path) do |new_resource|
69
+ source ::File.expand_path("support/cron_access.erb", __dir__)
63
70
  local true
64
71
  mode "0600"
65
72
  variables["users"] ||= []
@@ -72,10 +79,11 @@ class Chef
72
79
 
73
80
  action :deny do
74
81
  description "Add the user to the cron.deny file."
82
+ deny_path = ::File.join(value_for_platform_family(CRON_PATHS), "cron.deny")
75
83
 
76
84
  with_run_context :root do
77
- edit_resource(:template, "/etc/cron.deny") do |new_resource|
78
- source ::File.expand_path("../support/cron_access.erb", __FILE__)
85
+ edit_resource(:template, deny_path) do |new_resource|
86
+ source ::File.expand_path("support/cron_access.erb", __dir__)
79
87
  local true
80
88
  mode "0600"
81
89
  variables["users"] ||= []
@@ -289,9 +289,10 @@ class Chef
289
289
 
290
290
  # @todo this is Chef 12 era cleanup. Someday we should remove it all
291
291
  template "/etc/cron.d/#{sanitized_name}" do
292
- source ::File.expand_path("../support/cron.d.erb", __FILE__)
292
+ source ::File.expand_path("support/cron.d.erb", __dir__)
293
293
  local true
294
294
  mode new_resource.mode
295
+ sensitive new_resource.sensitive
295
296
  variables(
296
297
  name: sanitized_name,
297
298
  predefined_value: new_resource.predefined_value,
@@ -59,7 +59,7 @@ class Chef
59
59
 
60
60
  unless casked?
61
61
  converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
62
- shell_out!("#{new_resource.homebrew_path} cask install #{new_resource.cask_name} #{new_resource.options}",
62
+ shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
63
63
  user: new_resource.owner,
64
64
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
65
65
  cwd: ::Dir.home(new_resource.owner))
@@ -74,7 +74,7 @@ class Chef
74
74
 
75
75
  if casked?
76
76
  converge_by("uninstall cask #{new_resource.cask_name}") do
77
- shell_out!("#{new_resource.homebrew_path} cask uninstall #{new_resource.cask_name}",
77
+ shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
78
78
  user: new_resource.owner,
79
79
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
80
80
  cwd: ::Dir.home(new_resource.owner))
@@ -92,7 +92,7 @@ class Chef
92
92
  # @return [Boolean]
93
93
  def casked?
94
94
  unscoped_name = new_resource.cask_name.split("/").last
95
- shell_out!("#{new_resource.homebrew_path} cask list 2>/dev/null",
95
+ shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
96
96
  user: new_resource.owner,
97
97
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
98
98
  cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
@@ -13,6 +13,7 @@
13
13
  #
14
14
 
15
15
  require_relative "../resource"
16
+ require_relative "../dist"
16
17
 
17
18
  class Chef
18
19
  class Resource
@@ -66,8 +67,7 @@ class Chef
66
67
  def updated_ec2_config_xml
67
68
  begin
68
69
  require "rexml/document" unless defined?(REXML::Document)
69
- config_file = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'
70
- config = REXML::Document.new(::File.read(config_file))
70
+ config = REXML::Document.new(::File.read(WINDOWS_EC2_CONFIG))
71
71
  # find an element named State with a sibling element whose value is Ec2SetComputerName
72
72
  REXML::XPath.each(config, "//Plugin/State[../Name/text() = 'Ec2SetComputerName']") do |element|
73
73
  element.text = "Disabled"
@@ -219,35 +219,36 @@ class Chef
219
219
  end
220
220
 
221
221
  else # windows
222
+ WINDOWS_EC2_CONFIG = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'.freeze
223
+
222
224
  raise "Windows hostnames cannot contain a period." if new_resource.hostname.match?(/\./)
223
225
 
224
226
  # suppress EC2 config service from setting our hostname
225
- if ::File.exist?('C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml')
227
+ if ::File.exist?(WINDOWS_EC2_CONFIG)
226
228
  xml_contents = updated_ec2_config_xml
227
229
  if xml_contents.empty?
228
230
  Chef::Log.warn('Unable to properly parse and update C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml contents. Skipping file update.')
229
231
  else
230
- declare_resource(:file, 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml') do
232
+ file WINDOWS_EC2_CONFIG do
231
233
  content xml_contents
232
234
  end
233
235
  end
234
236
  end
235
237
 
236
- # update via netdom
237
- declare_resource(:powershell_script, "set hostname") do
238
- code <<-EOH
239
- $sysInfo = Get-WmiObject -Class Win32_ComputerSystem
240
- $sysInfo.Rename("#{new_resource.hostname}")
241
- EOH
242
- notifies :request_reboot, "reboot[setting hostname]"
243
- not_if { Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname }
244
- end
238
+ unless Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname
239
+ converge_by "set hostname to #{new_resource.hostname}" do
240
+ powershell_out! <<~EOH
241
+ $sysInfo = Get-WmiObject -Class Win32_ComputerSystem
242
+ $sysInfo.Rename("#{new_resource.hostname}")
243
+ EOH
244
+ end
245
245
 
246
- # reboot because $windows
247
- declare_resource(:reboot, "setting hostname") do
248
- reason "chef setting hostname"
249
- action :nothing
250
- only_if { new_resource.windows_reboot }
246
+ # reboot because $windows
247
+ reboot "setting hostname" do
248
+ reason "#{Chef::Dist::PRODUCT} updated system hostname"
249
+ only_if { new_resource.windows_reboot }
250
+ action :request_reboot
251
+ end
251
252
  end
252
253
  end
253
254
  end
@@ -97,7 +97,7 @@ class Chef
97
97
  # @raise [Mixlib::ShellOut::ShellCommandFailed] not a supported language or locale
98
98
  #
99
99
  def generate_locales
100
- shell_out!("locale-gen #{unavailable_locales.join(" ")}")
100
+ shell_out!("locale-gen #{unavailable_locales.join(" ")}", timeout: 1800)
101
101
  end
102
102
 
103
103
  # Updates system locale by appropriately writing them in /etc/locale.conf
@@ -65,6 +65,12 @@ class Chef
65
65
 
66
66
  LWRPBase.loaded_lwrps[filename] = true
67
67
 
68
+ unless resource_class.resource_name.nil?
69
+ if Chef.resource_handler_map.get(node, resource_class.resource_name, canonical: true) == resource_class
70
+ Chef.deprecated(:resource_name_without_provides, "Resource #{resource_class.resource_name} needs `provides :#{resource_class.resource_name}` in addition to `resource_name :#{resource_class.resource_name}` declaration")
71
+ end
72
+ end
73
+
68
74
  # wire up the default resource name after the class is parsed only if we haven't declared one.
69
75
  # (this ordering is important for MapCollision deprecation warnings)
70
76
  resource_class.resource_name resource_name.to_sym if resource_class.resource_name.nil?
@@ -103,6 +109,7 @@ class Chef
103
109
  protected
104
110
 
105
111
  attr_writer :loaded_lwrps
112
+
106
113
  def loaded_lwrps
107
114
  @loaded_lwrps ||= {}
108
115
  end
@@ -44,6 +44,11 @@ class Chef
44
44
 
45
45
  property :checksum, String, desired_state: false,
46
46
  description: "SHA-256 digest used to verify the checksum of the downloaded MSU package."
47
+
48
+ property :timeout, [String, Integer],
49
+ default: 3600,
50
+ description: "The amount of time (in seconds) to wait before timing out.",
51
+ desired_state: false
47
52
  end
48
53
  end
49
54
  end
@@ -88,7 +88,7 @@ class Chef
88
88
 
89
89
  r = with_run_context :root do
90
90
  find_resource(:template, "update ssh known hosts file #{new_resource.file_location}") do
91
- source ::File.expand_path("../support/ssh_known_hosts.erb", __FILE__)
91
+ source ::File.expand_path("support/ssh_known_hosts.erb", __dir__)
92
92
  local true
93
93
  path new_resource.file_location
94
94
  owner new_resource.owner
@@ -172,7 +172,7 @@ class Chef
172
172
  end
173
173
  else
174
174
  declare_resource(:template, file_path) do
175
- source ::File.expand_path("../support/sudoer.erb", __FILE__)
175
+ source ::File.expand_path("support/sudoer.erb", __dir__)
176
176
  local true
177
177
  mode "0440"
178
178
  variables sudoer: (new_resource.groups + new_resource.users).join(","),
@@ -228,7 +228,7 @@ class Chef
228
228
  end
229
229
 
230
230
  def visudo_content(path)
231
- if ::File.exists?(path)
231
+ if ::File.exist?(path)
232
232
  "cat #{new_resource.config_prefix}/sudoers | #{new_resource.visudo_binary} -cf - && #{new_resource.visudo_binary} -cf %{path}"
233
233
  else
234
234
  "cat #{new_resource.config_prefix}/sudoers %{path} | #{new_resource.visudo_binary} -cf -"
@@ -163,8 +163,12 @@ class Chef
163
163
 
164
164
  # @return [Array] features the user has requested to install which need installation
165
165
  def features_to_install
166
- # the intersection of the features to install & disabled features are what needs installing
167
- @install ||= new_resource.feature_name & node["powershell_features_cache"]["disabled"]
166
+ # the intersection of the features to install & disabled/removed features are what needs installing
167
+ @features_to_install ||= begin
168
+ features = node["powershell_features_cache"]["disabled"]
169
+ features |= node["powershell_features_cache"]["removed"] if new_resource.source
170
+ new_resource.feature_name & features
171
+ end
168
172
  end
169
173
 
170
174
  # @return [Array] features the user has requested to remove which need removing
@@ -90,8 +90,9 @@ class Chef
90
90
  def font_exists?
91
91
  require "win32ole" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
92
92
  fonts_dir = WIN32OLE.new("WScript.Shell").SpecialFolders("Fonts")
93
+ fonts_dir_local = Chef::Util::PathHelper.join(ENV["home"], "AppData/Local/Microsoft/Windows/fonts")
93
94
  logger.trace("Seeing if the font at #{Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name)} exists")
94
- ::File.exist?(Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name))
95
+ ::File.exist?(Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name)) || ::File.exist?(Chef::Util::PathHelper.join(fonts_dir_local, new_resource.font_name))
95
96
  end
96
97
 
97
98
  # Parse out the schema provided to us to see if it's one we support via remote_file.
data/lib/chef/role.rb CHANGED
@@ -257,11 +257,11 @@ class Chef
257
257
 
258
258
  js_path, rb_path = js_files.first, rb_files.first
259
259
 
260
- if js_path && File.exists?(js_path)
260
+ if js_path && File.exist?(js_path)
261
261
  # from_json returns object.class => json_class in the JSON.
262
262
  hsh = Chef::JSONCompat.parse(IO.read(js_path))
263
263
  return from_hash(hsh)
264
- elsif rb_path && File.exists?(rb_path)
264
+ elsif rb_path && File.exist?(rb_path)
265
265
  role = Chef::Role.new
266
266
  role.name(name)
267
267
  role.from_file(rb_path)
data/lib/chef/shell.rb CHANGED
@@ -19,6 +19,7 @@ require "singleton" unless defined?(Singleton)
19
19
  require "pp" unless defined?(PP)
20
20
  require "etc" unless defined?(Etc)
21
21
  require "mixlib/cli" unless defined?(Mixlib::CLI)
22
+ require "chef-config/mixin/dot_d"
22
23
 
23
24
  require_relative "../chef"
24
25
  require_relative "version"
@@ -199,6 +200,7 @@ module Shell
199
200
 
200
201
  class Options
201
202
  include Mixlib::CLI
203
+ include ChefConfig::Mixin::DotD
202
204
 
203
205
  def self.footer(text = nil)
204
206
  @footer = text if text
@@ -314,15 +316,44 @@ module Shell
314
316
  # We have to nuke ARGV to make sure irb's option parser never sees it.
315
317
  # otherwise, IRB complains about command line switches it doesn't recognize.
316
318
  ARGV.clear
319
+
320
+ # This code should not exist.
321
+ # We should be using Application::Client and then calling load_config_file
322
+ # which does all this properly. However this will do for now.
317
323
  config[:config_file] = config_file_for_shell_mode(environment)
318
324
  config_msg = config[:config_file] || "none (standalone session)"
319
325
  puts "loading configuration: #{config_msg}"
320
- Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exists?(config[:config_file]) && File.readable?(config[:config_file])
326
+
327
+ # load the config (if we have one)
328
+ if !config[:config_file].nil?
329
+ if File.exist?(config[:config_file]) && File.readable?(config[:config_file])
330
+ Chef::Config.from_file(config[:config_file])
331
+ end
332
+
333
+ # even if we couldn't load that, we need to tell Chef::Config what
334
+ # the file was so it sets confdir and d_dir and such properly
335
+ Chef::Config[:config_file] = config[:config_file]
336
+
337
+ # now attempt to load any relevant dot-dirs
338
+ load_dot_d(Chef::Config[:client_d_dir]) if Chef::Config[:client_d_dir]
339
+ end
340
+
341
+ # finally merge command-line options in
321
342
  Chef::Config.merge!(config)
322
343
  end
323
344
 
324
345
  private
325
346
 
347
+ # shamelessly lifted from application.rb
348
+ def apply_config(config_content, config_file_path)
349
+ Chef::Config.from_string(config_content, config_file_path)
350
+ rescue Exception => error
351
+ logger.fatal("Configuration error #{error.class}: #{error.message}")
352
+ filtered_trace = error.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
353
+ filtered_trace.each { |line| logger.fatal(" " + line ) }
354
+ raise Chef::Exceptions::ConfigurationError.new("Aborting due to error in '#{config_file_path}': #{error}")
355
+ end
356
+
326
357
  def config_file_for_shell_mode(environment)
327
358
  dot_chef_dir = Chef::Util::PathHelper.home(".chef")
328
359
  if config[:config_file]
@@ -41,6 +41,7 @@ module Shell
41
41
 
42
42
  attr_accessor :node, :compile, :recipe, :json_configuration
43
43
  attr_reader :node_attributes, :client
44
+
44
45
  def initialize
45
46
  @node_built = false
46
47
  formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR)
@@ -75,6 +76,7 @@ module Shell
75
76
  end
76
77
 
77
78
  attr_writer :run_context
79
+
78
80
  def run_context
79
81
  @run_context ||= rebuild_context
80
82
  end