chef 15.13.8-universal-mingw32 → 15.14.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/lib/chef/api_client/registration.rb +2 -2
  4. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  5. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  6. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  7. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  8. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  9. data/lib/chef/environment.rb +2 -2
  10. data/lib/chef/http.rb +2 -1
  11. data/lib/chef/knife/bootstrap.rb +2 -2
  12. data/lib/chef/knife/cookbook_download.rb +1 -1
  13. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  14. data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
  15. data/lib/chef/knife/exec.rb +2 -2
  16. data/lib/chef/knife/ssh.rb +16 -1
  17. data/lib/chef/provider/service/arch.rb +2 -2
  18. data/lib/chef/provider/service/debian.rb +1 -1
  19. data/lib/chef/provider/service/gentoo.rb +2 -2
  20. data/lib/chef/provider/service/macosx.rb +2 -2
  21. data/lib/chef/provider/service/openbsd.rb +1 -1
  22. data/lib/chef/provider/service/redhat.rb +2 -2
  23. data/lib/chef/provider/service/upstart.rb +1 -1
  24. data/lib/chef/resource/hostname.rb +18 -18
  25. data/lib/chef/resource/sudo.rb +1 -1
  26. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  27. data/lib/chef/resource/windows_font.rb +2 -1
  28. data/lib/chef/role.rb +2 -2
  29. data/lib/chef/shell.rb +1 -1
  30. data/lib/chef/util/diff.rb +1 -1
  31. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  32. data/lib/chef/version.rb +1 -1
  33. data/lib/chef/win32/file.rb +2 -2
  34. data/spec/functional/resource/aixinit_service_spec.rb +7 -7
  35. data/spec/functional/resource/bff_spec.rb +2 -2
  36. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  37. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  38. data/spec/functional/resource/insserv_spec.rb +4 -4
  39. data/spec/functional/resource/link_spec.rb +17 -17
  40. data/spec/functional/resource/rpm_spec.rb +2 -2
  41. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  42. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  43. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  44. data/spec/functional/resource/windows_font_spec.rb +49 -0
  45. data/spec/functional/win32/service_manager_spec.rb +1 -1
  46. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  47. data/spec/spec_helper.rb +5 -4
  48. data/spec/support/platform_helpers.rb +12 -42
  49. data/spec/support/platforms/win32/spec_service.rb +1 -1
  50. data/spec/support/shared/functional/directory_resource.rb +1 -1
  51. data/spec/support/shared/functional/execute_resource.rb +1 -1
  52. data/spec/support/shared/functional/file_resource.rb +2 -2
  53. data/spec/support/shared/functional/win32_service.rb +1 -1
  54. data/spec/support/shared/functional/windows_script.rb +3 -3
  55. data/spec/unit/environment_spec.rb +7 -7
  56. data/spec/unit/knife/bootstrap_spec.rb +14 -14
  57. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  58. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  59. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  60. data/spec/unit/knife/ssh_spec.rb +2 -2
  61. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  62. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  63. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  64. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  65. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  66. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  67. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  68. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  69. data/spec/unit/role_spec.rb +11 -11
  70. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc9053028d3cccbdba43dc5be7b25a0fd5a060e98508ca8d30a081dea3c3a427
4
- data.tar.gz: c7286fd82ecedab382a685fd24bfc97f80682b8351300254d1aee414c8910db6
3
+ metadata.gz: c9e4ce01879cb7fd217e2f540bdb84a5572cc688fbbe0bd995d3d51569944232
4
+ data.tar.gz: 01e4540863e22a7bcbc9b97c024626671194066e1581bdd9bc253e633ca61a38
5
5
  SHA512:
6
- metadata.gz: 5260139892c3516289eab07b899dfd949d420811d832fd49c856b4615f59c3fe4e3928e7d26fa26bdb9fb4667556b2145ddd25b43ac2508031389457dcc1f1e9
7
- data.tar.gz: 5f934310d3867313ef3fb9d3f35b29a2960fab407e856c574cfc10062a2a1bbc55f991c3a555e661b79dd81e98e0ce0771aa6b7bd14f3e1638266dcae4d5774f
6
+ metadata.gz: 72ad9af64fab6220e2833a63f208ae3a2608d7066b37ca485050e0b53de19d289e2d9e246d20c143378f48366a9060c7bae0061db87189eb4a28fb5c9b19cb5f
7
+ data.tar.gz: b46f80da09f83ad897eef10f4610f86c9110a656f59b8fbe5c09d512085ddd6f88a01e0d2d8a49d0644a15c6eb49f13c09568b5d669d985befc6b6481e5fa777
data/Gemfile CHANGED
@@ -71,8 +71,7 @@ group(:development, :test) do
71
71
  end
72
72
 
73
73
  group(:chefstyle) do
74
- # for testing new chefstyle rules
75
- 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
76
75
  end
77
76
 
78
77
  instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -73,7 +73,7 @@ class Chef
73
73
  manifest = cookbook.cookbook_manifest
74
74
 
75
75
  basedir = File.join(config[:download_directory], "#{@cookbook_name}-#{cookbook.version}")
76
- if File.exists?(basedir)
76
+ if File.exist?(basedir)
77
77
  if config[:force]
78
78
  Chef::Log.trace("Deleting #{basedir}")
79
79
  FileUtils.rm_rf(basedir)
@@ -62,7 +62,7 @@ class Chef
62
62
  def generate_metadata(cookbook)
63
63
  Array(config[:cookbook_path]).reverse_each do |path|
64
64
  file = File.expand_path(File.join(path, cookbook, "metadata.rb"))
65
- if File.exists?(file)
65
+ if File.exist?(file)
66
66
  generate_metadata_from_file(cookbook, file)
67
67
  else
68
68
  validate_metadata_json(path, cookbook)
@@ -53,7 +53,7 @@ class Chef
53
53
  paths = manifest[KEY]["plugins_paths"][command]
54
54
  if paths && paths.is_a?(Array)
55
55
  # It is only an error if all the paths don't exist
56
- if paths.all? { |sc| !File.exists?(sc) }
56
+ if paths.all? { |sc| !File.exist?(sc) }
57
57
  errors[command] = paths
58
58
  end
59
59
  end
@@ -77,7 +77,7 @@ class Chef
77
77
  false
78
78
  else
79
79
  paths.each do |sc|
80
- if File.exists?(sc)
80
+ if File.exist?(sc)
81
81
  Kernel.load sc
82
82
  else
83
83
  return false
@@ -76,7 +76,7 @@ class Chef::Knife::Exec < Chef::Knife
76
76
  def find_script(x)
77
77
  # Try to find a script. First try expanding the path given.
78
78
  script = File.expand_path(x)
79
- return script if File.exists?(script)
79
+ return script if File.exist?(script)
80
80
 
81
81
  # Failing that, try searching the script path. If we can't find
82
82
  # anything, fail gracefully.
@@ -86,7 +86,7 @@ class Chef::Knife::Exec < Chef::Knife
86
86
  path = File.expand_path(path)
87
87
  test = File.join(path, x)
88
88
  Chef::Log.trace("Testing: #{test}")
89
- if File.exists?(test)
89
+ if File.exist?(test)
90
90
  script = test
91
91
  Chef::Log.trace("Found: #{test}")
92
92
  return script
@@ -362,11 +362,21 @@ class Chef
362
362
  subsession ||= session
363
363
  command = fixup_sudo(command)
364
364
  command.force_encoding("binary") if command.respond_to?(:force_encoding)
365
+ begin
366
+ open_session(subsession, command)
367
+ rescue => e
368
+ open_session(subsession, command, true)
369
+ end
370
+ end
371
+
372
+ def open_session(subsession, command, pty = false)
373
+ stderr = ""
374
+ exit_status = 0
365
375
  subsession.open_channel do |chan|
366
376
  if config[:on_error] && exit_status != 0
367
377
  chan.close
368
378
  else
369
- chan.request_pty
379
+ chan.request_pty if pty
370
380
  chan.exec command do |ch, success|
371
381
  raise ArgumentError, "Cannot execute #{command}" unless success
372
382
 
@@ -377,6 +387,11 @@ class Chef
377
387
  ichannel.send_data("#{get_password}\n")
378
388
  end
379
389
  end
390
+
391
+ ch.on_extended_data do |_, _type, data|
392
+ stderr += data
393
+ end
394
+
380
395
  ch.on_request "exit-status" do |ichannel, data|
381
396
  exit_status = [exit_status, data.read_long].max
382
397
  end
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
32
32
  end
33
33
 
34
34
  def load_current_resource
35
- raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
36
- raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf") =~ /DAEMONS=\((.*)\)/m
35
+ raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exist?("/etc/rc.conf")
36
+ raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless /DAEMONS=\((.*)\)/m.match?(::File.read("/etc/rc.conf"))
37
37
 
38
38
  super
39
39
 
@@ -45,7 +45,7 @@ class Chef
45
45
  shared_resource_requirements
46
46
  requirements.assert(:all_actions) do |a|
47
47
  update_rcd = "/usr/sbin/update-rc.d"
48
- a.assertion { ::File.exists? update_rcd }
48
+ a.assertion { ::File.exist? update_rcd }
49
49
  a.failure_message Chef::Exceptions::Service, "#{update_rcd} does not exist!"
50
50
  # no whyrun recovery - this is a base system component of debian
51
51
  # distros and must be present
@@ -34,7 +34,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
34
34
  @current_resource.enabled(
35
35
  Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? do |file|
36
36
  @found_script = true
37
- exists = ::File.exists? file
37
+ exists = ::File.exist? file
38
38
  readable = ::File.readable? file
39
39
  logger.trace "#{@new_resource} exists: #{exists}, readable: #{readable}"
40
40
  exists && readable
@@ -47,7 +47,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
47
47
 
48
48
  def define_resource_requirements
49
49
  requirements.assert(:all_actions) do |a|
50
- a.assertion { ::File.exists?("/sbin/rc-update") }
50
+ a.assertion { ::File.exist?("/sbin/rc-update") }
51
51
  a.failure_message Chef::Exceptions::Service, "/sbin/rc-update does not exist"
52
52
  # no whyrun recovery -t his is a core component whose presence is
53
53
  # unlikely to be affected by what we do in the course of a chef run
@@ -84,7 +84,7 @@ class Chef
84
84
  end
85
85
 
86
86
  requirements.assert(:all_actions) do |a|
87
- a.assertion { ::File.exists?(@plist.to_s) }
87
+ a.assertion { ::File.exist?(@plist.to_s) }
88
88
  a.failure_message Chef::Exceptions::Service,
89
89
  "Could not find plist for #{@new_resource}"
90
90
  end
@@ -215,7 +215,7 @@ class Chef
215
215
  return nil if @plist.nil?
216
216
 
217
217
  # Plist must exist by this point
218
- raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.exists?(@plist)
218
+ raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.exist?(@plist)
219
219
 
220
220
  # Most services have the same internal label as the name of the
221
221
  # plist file. However, there is no rule saying that *has* to be
@@ -132,7 +132,7 @@ class Chef
132
132
  end
133
133
 
134
134
  def update_rcl(value)
135
- FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.exists? RC_CONF_LOCAL_PATH
135
+ FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.exist? RC_CONF_LOCAL_PATH
136
136
  ::File.write(RC_CONF_LOCAL_PATH, value)
137
137
  @rc_conf_local = value
138
138
  end
@@ -56,7 +56,7 @@ class Chef
56
56
 
57
57
  requirements.assert(:all_actions) do |a|
58
58
  chkconfig_file = "/sbin/chkconfig"
59
- a.assertion { ::File.exists? chkconfig_file }
59
+ a.assertion { ::File.exist? chkconfig_file }
60
60
  a.failure_message Chef::Exceptions::Service, "#{chkconfig_file} does not exist!"
61
61
  end
62
62
 
@@ -80,7 +80,7 @@ class Chef
80
80
 
81
81
  super
82
82
 
83
- if ::File.exists?("/sbin/chkconfig")
83
+ if ::File.exist?("/sbin/chkconfig")
84
84
  chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1])
85
85
  unless run_levels.nil? || run_levels.empty?
86
86
  all_levels_match = true
@@ -135,7 +135,7 @@ class Chef
135
135
  end
136
136
  end
137
137
  # Get enabled/disabled state by reading job configuration file
138
- if ::File.exists?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
138
+ if ::File.exist?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
139
139
  logger.trace("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
140
140
  ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
141
141
  while line = file.gets
@@ -67,8 +67,7 @@ class Chef
67
67
  def updated_ec2_config_xml
68
68
  begin
69
69
  require "rexml/document" unless defined?(REXML::Document)
70
- config_file = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'
71
- config = REXML::Document.new(::File.read(config_file))
70
+ config = REXML::Document.new(::File.read(WINDOWS_EC2_CONFIG))
72
71
  # find an element named State with a sibling element whose value is Ec2SetComputerName
73
72
  REXML::XPath.each(config, "//Plugin/State[../Name/text() = 'Ec2SetComputerName']") do |element|
74
73
  element.text = "Disabled"
@@ -220,35 +219,36 @@ class Chef
220
219
  end
221
220
 
222
221
  else # windows
222
+ WINDOWS_EC2_CONFIG = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'.freeze
223
+
223
224
  raise "Windows hostnames cannot contain a period." if new_resource.hostname.match?(/\./)
224
225
 
225
226
  # suppress EC2 config service from setting our hostname
226
- if ::File.exist?('C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml')
227
+ if ::File.exist?(WINDOWS_EC2_CONFIG)
227
228
  xml_contents = updated_ec2_config_xml
228
229
  if xml_contents.empty?
229
230
  Chef::Log.warn('Unable to properly parse and update C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml contents. Skipping file update.')
230
231
  else
231
- declare_resource(:file, 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml') do
232
+ file WINDOWS_EC2_CONFIG do
232
233
  content xml_contents
233
234
  end
234
235
  end
235
236
  end
236
237
 
237
- # update via netdom
238
- declare_resource(:powershell_script, "set hostname") do
239
- code <<-EOH
240
- $sysInfo = Get-WmiObject -Class Win32_ComputerSystem
241
- $sysInfo.Rename("#{new_resource.hostname}")
242
- EOH
243
- notifies :request_reboot, "reboot[setting hostname]"
244
- not_if { Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname }
245
- 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
246
245
 
247
- # reboot because $windows
248
- declare_resource(:reboot, "setting hostname") do
249
- reason "#{Chef::Dist::PRODUCT} updated system hostname"
250
- action :nothing
251
- 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
252
252
  end
253
253
  end
254
254
  end
@@ -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.
@@ -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)