chef 18.5.0 → 18.7.3

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 (241) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +11 -6
  3. data/chef-universal-mingw-ucrt.gemspec +1 -1
  4. data/chef.gemspec +19 -15
  5. data/lib/chef/application/client.rb +0 -12
  6. data/lib/chef/client.rb +1 -10
  7. data/lib/chef/compliance/default_attributes.rb +2 -2
  8. data/lib/chef/compliance/runner.rb +6 -11
  9. data/lib/chef/cookbook/metadata.rb +1 -1
  10. data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
  11. data/lib/chef/cookbook/synchronizer.rb +0 -5
  12. data/lib/chef/event_dispatch/dispatcher.rb +0 -1
  13. data/lib/chef/exceptions.rb +1 -1
  14. data/lib/chef/file_access_control/unix.rb +9 -9
  15. data/lib/chef/file_content_management/deploy.rb +1 -4
  16. data/lib/chef/mixin/file_class.rb +1 -3
  17. data/lib/chef/mixin/get_source_from_package.rb +1 -1
  18. data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
  19. data/lib/chef/mixin/openssl_helper.rb +1 -12
  20. data/lib/chef/provider/cookbook_file.rb +1 -1
  21. data/lib/chef/provider/cron.rb +1 -1
  22. data/lib/chef/provider/directory.rb +15 -15
  23. data/lib/chef/provider/file.rb +29 -42
  24. data/lib/chef/provider/git.rb +8 -8
  25. data/lib/chef/provider/group/aix.rb +1 -1
  26. data/lib/chef/provider/group/dscl.rb +1 -1
  27. data/lib/chef/provider/group/gpasswd.rb +2 -2
  28. data/lib/chef/provider/group/groupadd.rb +1 -1
  29. data/lib/chef/provider/group/groupmod.rb +2 -2
  30. data/lib/chef/provider/group/pw.rb +2 -2
  31. data/lib/chef/provider/group/solaris.rb +2 -2
  32. data/lib/chef/provider/group/usermod.rb +2 -2
  33. data/lib/chef/provider/group.rb +1 -1
  34. data/lib/chef/provider/http_request.rb +3 -2
  35. data/lib/chef/provider/ifconfig/aix.rb +1 -1
  36. data/lib/chef/provider/ifconfig/debian.rb +3 -3
  37. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  38. data/lib/chef/provider/ifconfig.rb +1 -1
  39. data/lib/chef/provider/link.rb +10 -10
  40. data/lib/chef/provider/mount/aix.rb +4 -4
  41. data/lib/chef/provider/mount/linux.rb +4 -4
  42. data/lib/chef/provider/mount/mount.rb +11 -11
  43. data/lib/chef/provider/package/apt.rb +11 -2
  44. data/lib/chef/provider/package/bff.rb +3 -3
  45. data/lib/chef/provider/package/chocolatey.rb +2 -2
  46. data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
  47. data/lib/chef/provider/package/dpkg.rb +3 -3
  48. data/lib/chef/provider/package/freebsd/base.rb +1 -1
  49. data/lib/chef/provider/package/habitat.rb +3 -5
  50. data/lib/chef/provider/package/homebrew.rb +6 -9
  51. data/lib/chef/provider/package/ips.rb +2 -2
  52. data/lib/chef/provider/package/openbsd.rb +2 -3
  53. data/lib/chef/provider/package/pacman.rb +4 -4
  54. data/lib/chef/provider/package/paludis.rb +2 -2
  55. data/lib/chef/provider/package/portage.rb +1 -1
  56. data/lib/chef/provider/package/rpm.rb +2 -2
  57. data/lib/chef/provider/package/rubygems.rb +4 -0
  58. data/lib/chef/provider/package/smartos.rb +2 -2
  59. data/lib/chef/provider/package/snap.rb +2 -2
  60. data/lib/chef/provider/package/solaris.rb +4 -4
  61. data/lib/chef/provider/package/zypper.rb +4 -4
  62. data/lib/chef/provider/package.rb +1 -1
  63. data/lib/chef/provider/registry_key.rb +6 -0
  64. data/lib/chef/provider/remote_directory.rb +5 -5
  65. data/lib/chef/provider/remote_file/http.rb +3 -2
  66. data/lib/chef/provider/remote_file.rb +1 -1
  67. data/lib/chef/provider/route.rb +9 -9
  68. data/lib/chef/provider/service/aix.rb +1 -1
  69. data/lib/chef/provider/service/aixinit.rb +4 -4
  70. data/lib/chef/provider/service/arch.rb +6 -6
  71. data/lib/chef/provider/service/debian.rb +5 -5
  72. data/lib/chef/provider/service/freebsd.rb +7 -7
  73. data/lib/chef/provider/service/gentoo.rb +5 -5
  74. data/lib/chef/provider/service/init.rb +2 -2
  75. data/lib/chef/provider/service/insserv.rb +2 -2
  76. data/lib/chef/provider/service/invokercd.rb +1 -1
  77. data/lib/chef/provider/service/openbsd.rb +7 -7
  78. data/lib/chef/provider/service/redhat.rb +3 -3
  79. data/lib/chef/provider/service/solaris.rb +2 -2
  80. data/lib/chef/provider/service/systemd.rb +2 -2
  81. data/lib/chef/provider/service/upstart.rb +2 -2
  82. data/lib/chef/provider/subversion.rb +8 -8
  83. data/lib/chef/provider/systemd_unit.rb +3 -3
  84. data/lib/chef/provider/template.rb +1 -1
  85. data/lib/chef/provider/user/aix.rb +3 -3
  86. data/lib/chef/provider/user/linux.rb +2 -7
  87. data/lib/chef/provider/user/pw.rb +3 -3
  88. data/lib/chef/provider/user/solaris.rb +7 -7
  89. data/lib/chef/provider/user/windows.rb +5 -0
  90. data/lib/chef/provider/user.rb +8 -7
  91. data/lib/chef/provider/yum_repository.rb +3 -1
  92. data/lib/chef/provider/zypper_repository.rb +1 -1
  93. data/lib/chef/providers.rb +0 -1
  94. data/lib/chef/resource/alternatives.rb +2 -2
  95. data/lib/chef/resource/apt_preference.rb +1 -1
  96. data/lib/chef/resource/apt_repository.rb +90 -15
  97. data/lib/chef/resource/apt_update.rb +3 -3
  98. data/lib/chef/resource/bff_package.rb +1 -1
  99. data/lib/chef/resource/chef_client_config.rb +3 -2
  100. data/lib/chef/resource/chef_sleep.rb +1 -1
  101. data/lib/chef/resource/cookbook_file.rb +1 -1
  102. data/lib/chef/resource/cron/cron.rb +1 -1
  103. data/lib/chef/resource/cron/cron_d.rb +1 -1
  104. data/lib/chef/resource/cron_access.rb +1 -1
  105. data/lib/chef/resource/directory.rb +1 -1
  106. data/lib/chef/resource/dpkg_package.rb +1 -1
  107. data/lib/chef/resource/file/verification/json.rb +1 -1
  108. data/lib/chef/resource/file/verification/systemd_unit.rb +1 -1
  109. data/lib/chef/resource/file/verification/yaml.rb +1 -1
  110. data/lib/chef/resource/file.rb +1 -1
  111. data/lib/chef/resource/freebsd_package.rb +2 -2
  112. data/lib/chef/resource/group.rb +1 -1
  113. data/lib/chef/resource/habitat/habitat_package.rb +1 -1
  114. data/lib/chef/resource/habitat/habitat_sup.rb +9 -9
  115. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +2 -2
  116. data/lib/chef/resource/habitat_install.rb +3 -3
  117. data/lib/chef/resource/homebrew_cask.rb +19 -30
  118. data/lib/chef/resource/homebrew_tap.rb +32 -17
  119. data/lib/chef/resource/homebrew_update.rb +4 -4
  120. data/lib/chef/resource/hostname.rb +10 -11
  121. data/lib/chef/resource/http_request.rb +1 -1
  122. data/lib/chef/resource/ifconfig.rb +1 -1
  123. data/lib/chef/resource/inspec_input.rb +1 -3
  124. data/lib/chef/resource/inspec_waiver.rb +1 -1
  125. data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
  126. data/lib/chef/resource/ips_package.rb +2 -2
  127. data/lib/chef/resource/kernel_module.rb +2 -2
  128. data/lib/chef/resource/link.rb +1 -1
  129. data/lib/chef/resource/locale.rb +2 -2
  130. data/lib/chef/resource/mount.rb +1 -1
  131. data/lib/chef/resource/notify_group.rb +1 -1
  132. data/lib/chef/resource/ohai.rb +1 -1
  133. data/lib/chef/resource/ohai_hint.rb +1 -1
  134. data/lib/chef/resource/openbsd_package.rb +2 -2
  135. data/lib/chef/resource/package.rb +1 -1
  136. data/lib/chef/resource/pacman_package.rb +1 -1
  137. data/lib/chef/resource/paludis_package.rb +1 -1
  138. data/lib/chef/resource/portage_package.rb +1 -1
  139. data/lib/chef/resource/reboot.rb +1 -1
  140. data/lib/chef/resource/registry_key.rb +18 -0
  141. data/lib/chef/resource/remote_directory.rb +1 -1
  142. data/lib/chef/resource/remote_file.rb +1 -1
  143. data/lib/chef/resource/rhsm_errata.rb +1 -1
  144. data/lib/chef/resource/rhsm_errata_level.rb +1 -1
  145. data/lib/chef/resource/rhsm_register.rb +1 -1
  146. data/lib/chef/resource/rhsm_repo.rb +4 -3
  147. data/lib/chef/resource/rhsm_subscription.rb +9 -8
  148. data/lib/chef/resource/route.rb +1 -1
  149. data/lib/chef/resource/rpm_package.rb +1 -1
  150. data/lib/chef/resource/scm/git.rb +1 -1
  151. data/lib/chef/resource/scm/subversion.rb +1 -1
  152. data/lib/chef/resource/selinux/common_helpers.rb +1 -1
  153. data/lib/chef/resource/selinux_boolean.rb +1 -1
  154. data/lib/chef/resource/selinux_fcontext.rb +3 -3
  155. data/lib/chef/resource/selinux_install.rb +1 -1
  156. data/lib/chef/resource/selinux_login.rb +1 -1
  157. data/lib/chef/resource/selinux_module.rb +5 -5
  158. data/lib/chef/resource/selinux_permissive.rb +2 -2
  159. data/lib/chef/resource/selinux_port.rb +2 -2
  160. data/lib/chef/resource/selinux_state.rb +2 -2
  161. data/lib/chef/resource/selinux_user.rb +1 -1
  162. data/lib/chef/resource/smartos_package.rb +2 -2
  163. data/lib/chef/resource/snap_package.rb +1 -1
  164. data/lib/chef/resource/solaris_package.rb +1 -1
  165. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  166. data/lib/chef/resource/sudo.rb +5 -5
  167. data/lib/chef/resource/support/client.erb +3 -2
  168. data/lib/chef/resource/swap_file.rb +6 -6
  169. data/lib/chef/resource/sysctl.rb +5 -5
  170. data/lib/chef/resource/systemd_unit.rb +1 -1
  171. data/lib/chef/resource/template.rb +1 -1
  172. data/lib/chef/resource/timezone.rb +5 -5
  173. data/lib/chef/resource/user/aix_user.rb +2 -2
  174. data/lib/chef/resource/user/linux_user.rb +2 -2
  175. data/lib/chef/resource/user/pw_user.rb +2 -2
  176. data/lib/chef/resource/user/solaris_user.rb +2 -2
  177. data/lib/chef/resource/user_ulimit.rb +1 -1
  178. data/lib/chef/resource/yum_repository.rb +1 -1
  179. data/lib/chef/resource/zypper_package.rb +2 -2
  180. data/lib/chef/resource/zypper_repository.rb +2 -2
  181. data/lib/chef/resource.rb +1 -0
  182. data/lib/chef/resource_inspector.rb +25 -7
  183. data/lib/chef/resource_reporter.rb +1 -0
  184. data/lib/chef/run_lock.rb +0 -3
  185. data/lib/chef/scan_access_control.rb +6 -6
  186. data/lib/chef/util/backup.rb +1 -1
  187. data/lib/chef/util/diff.rb +1 -14
  188. data/lib/chef/util/file_edit.rb +4 -4
  189. data/lib/chef/util/powershell/ps_credential.rb +10 -0
  190. data/lib/chef/version.rb +1 -1
  191. data/lib/chef/win32/registry.rb +5 -1
  192. data/lib/chef/win32/security.rb +9 -0
  193. data/lib/chef.rb +0 -2
  194. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +6 -6
  195. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  196. data/spec/functional/resource/registry_spec.rb +276 -609
  197. data/spec/integration/client/open_ssl_spec.rb +1 -1
  198. data/spec/spec_helper.rb +1 -0
  199. data/spec/support/chef_helpers.rb +2 -2
  200. data/spec/support/platform_helpers.rb +8 -0
  201. data/spec/support/shared/functional/file_resource.rb +3 -3
  202. data/spec/tiny_server.rb +5 -2
  203. data/spec/unit/mixin/homebrew_spec.rb +118 -0
  204. data/spec/unit/provider/apt_repository_spec.rb +14 -9
  205. data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
  206. data/spec/unit/provider/package/homebrew_spec.rb +4 -1
  207. data/spec/unit/provider/registry_key_spec.rb +18 -17
  208. data/spec/unit/provider/route_spec.rb +4 -6
  209. data/spec/unit/provider/user/windows_spec.rb +1 -0
  210. data/spec/unit/resource/rhsm_repo_spec.rb +0 -1
  211. data/spec/unit/resource/rhsm_subscription_spec.rb +0 -2
  212. data/spec/unit/resource_inspector_spec.rb +36 -0
  213. data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
  214. metadata +36 -44
  215. data/lib/chef/file_content_management/deploy/target_io.rb +0 -29
  216. data/lib/chef/provider/.gitkeep +0 -0
  217. data/lib/chef/provider/package/snap_tm.rb +0 -79
  218. data/lib/chef/resource/.gitkeep +0 -0
  219. data/lib/chef/target_io/dir.rb +0 -12
  220. data/lib/chef/target_io/etc.rb +0 -16
  221. data/lib/chef/target_io/file.rb +0 -12
  222. data/lib/chef/target_io/fileutils.rb +0 -12
  223. data/lib/chef/target_io/http.rb +0 -22
  224. data/lib/chef/target_io/io.rb +0 -12
  225. data/lib/chef/target_io/shadow.rb +0 -44
  226. data/lib/chef/target_io/train/dir.rb +0 -69
  227. data/lib/chef/target_io/train/etc.rb +0 -112
  228. data/lib/chef/target_io/train/file.rb +0 -219
  229. data/lib/chef/target_io/train/fileutils.rb +0 -220
  230. data/lib/chef/target_io/train/http.rb +0 -117
  231. data/lib/chef/target_io/train/io.rb +0 -13
  232. data/lib/chef/target_io/train/shadow.rb +0 -52
  233. data/lib/chef/target_io/train_compat.rb +0 -7
  234. data/lib/chef/target_io.rb +0 -9
  235. data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
  236. /data/spec/functional/assets/yumrepo-empty/repodata/{01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 → 01a3b-filelists.sqlite.bz2} +0 -0
  237. /data/spec/functional/assets/yumrepo-empty/repodata/{401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz → 401dc-filelists.xml.gz} +0 -0
  238. /data/spec/functional/assets/yumrepo-empty/repodata/{5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 → 5dc1e-primary.sqlite.bz2} +0 -0
  239. /data/spec/functional/assets/yumrepo-empty/repodata/{6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz → 6bf96-other.xml.gz} +0 -0
  240. /data/spec/functional/assets/yumrepo-empty/repodata/{7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 → 7c365-other.sqlite.bz2} +0 -0
  241. /data/spec/functional/assets/yumrepo-empty/repodata/{dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz → dabe2-primary.xml.gz} +0 -0
@@ -29,7 +29,6 @@ require_relative "../mixin/file_class"
29
29
  require_relative "../mixin/enforce_ownership_and_permissions"
30
30
  require_relative "../resource/file/verification/json"
31
31
  require_relative "../resource/file/verification/yaml"
32
- require_relative "../target_io"
33
32
  require_relative "../util/backup"
34
33
  require_relative "../util/diff"
35
34
  require_relative "../util/selinux"
@@ -54,7 +53,7 @@ class Chef
54
53
  include Chef::Util::Selinux
55
54
  include Chef::Mixin::FileClass
56
55
 
57
- provides :file, target_mode: true
56
+ provides :file
58
57
 
59
58
  attr_reader :deployment_strategy
60
59
 
@@ -76,7 +75,7 @@ class Chef
76
75
 
77
76
  # true if there is a non-file thing in the way that we need to unlink first
78
77
  @needs_unlinking =
79
- if ::TargetIO::File.exist?(new_resource.path)
78
+ if ::File.exist?(new_resource.path)
80
79
  if managing_symlink?
81
80
  !symlink_to_real_file?(new_resource.path)
82
81
  else
@@ -87,7 +86,7 @@ class Chef
87
86
  end
88
87
 
89
88
  # true if we are going to be creating a new file
90
- @needs_creating = !::TargetIO::File.exist?(new_resource.path) || needs_unlinking?
89
+ @needs_creating = !::File.exist?(new_resource.path) || needs_unlinking?
91
90
 
92
91
  # Let children resources override constructing the current_resource
93
92
  @current_resource ||= Chef::Resource::File.new(new_resource.name)
@@ -97,11 +96,7 @@ class Chef
97
96
  # we are updating an existing file
98
97
  if managing_content?
99
98
  logger.trace("#{new_resource} checksumming file at #{new_resource.path}.")
100
-
101
- resource_to_check = current_resource.path
102
- resource_to_check = ::TargetIO::File.open(current_resource.path) if ChefConfig::Config.target_mode?
103
-
104
- current_resource.checksum(checksum(resource_to_check))
99
+ current_resource.checksum(checksum(current_resource.path))
105
100
  else
106
101
  # if the file does not exist or is not a file, then the checksum is invalid/pointless
107
102
  current_resource.checksum(nil)
@@ -119,15 +114,15 @@ class Chef
119
114
  # Make sure the parent directory exists, otherwise fail. For why-run assume it would have been created.
120
115
  requirements.assert(:create, :create_if_missing, :touch) do |a|
121
116
  parent_directory = ::File.dirname(new_resource.path)
122
- a.assertion { ::TargetIO::File.directory?(parent_directory) }
117
+ a.assertion { ::File.directory?(parent_directory) }
123
118
  a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist.")
124
119
  a.whyrun("Assuming directory #{parent_directory} would have been created")
125
120
  end
126
121
 
127
122
  # Make sure the file is deletable if it exists, otherwise fail.
128
- if ::TargetIO::File.exist?(new_resource.path)
123
+ if ::File.exist?(new_resource.path)
129
124
  requirements.assert(:delete) do |a|
130
- a.assertion { ::TargetIO::File.writable?(new_resource.path) }
125
+ a.assertion { ::File.writable?(new_resource.path) }
131
126
  a.failure_message(Chef::Exceptions::InsufficientPermissions, "File #{new_resource.path} exists but is not writable so it cannot be deleted")
132
127
  end
133
128
  end
@@ -156,7 +151,7 @@ class Chef
156
151
  end
157
152
 
158
153
  action :create_if_missing do
159
- unless ::TargetIO::File.exist?(new_resource.path)
154
+ unless ::File.exist?(new_resource.path)
160
155
  action_create
161
156
  else
162
157
  logger.debug("#{new_resource} exists at #{new_resource.path} taking no action.")
@@ -164,10 +159,10 @@ class Chef
164
159
  end
165
160
 
166
161
  action :delete do
167
- if ::TargetIO::File.exist?(new_resource.path)
162
+ if ::File.exist?(new_resource.path)
168
163
  converge_by("delete file #{new_resource.path}") do
169
164
  do_backup unless file_class.symlink?(new_resource.path)
170
- ::TargetIO::File.delete(new_resource.path)
165
+ ::File.delete(new_resource.path)
171
166
  logger.info("#{new_resource} deleted file at #{new_resource.path}")
172
167
  end
173
168
  end
@@ -177,7 +172,7 @@ class Chef
177
172
  action_create
178
173
  converge_by("update utime on file #{new_resource.path}") do
179
174
  time = Time.now
180
- ::TargetIO::File.utime(time, time, new_resource.path)
175
+ ::File.utime(time, time, new_resource.path)
181
176
  logger.info("#{new_resource} updated atime and mtime to #{time}")
182
177
  end
183
178
  end
@@ -259,7 +254,7 @@ class Chef
259
254
  # If any of the above apply, returns a 3-tuple of Exception class,
260
255
  # exception message, whyrun message; otherwise returns a 3-tuple of nil.
261
256
  def verify_symlink_sanity(path)
262
- real_path = ::TargetIO::File.realpath(path)
257
+ real_path = ::File.realpath(path)
263
258
  if real_file?(real_path)
264
259
  [nil, nil, nil]
265
260
  else
@@ -288,15 +283,15 @@ class Chef
288
283
 
289
284
  def file_type_string(path)
290
285
  case
291
- when ::TargetIO::File.blockdev?(path)
286
+ when ::File.blockdev?(path)
292
287
  "block device"
293
- when ::TargetIO::File.chardev?(path)
288
+ when ::File.chardev?(path)
294
289
  "char device"
295
- when ::TargetIO::File.directory?(path)
290
+ when ::File.directory?(path)
296
291
  "directory"
297
- when ::TargetIO::File.pipe?(path)
292
+ when ::File.pipe?(path)
298
293
  "pipe"
299
- when ::TargetIO::File.socket?(path)
294
+ when ::File.socket?(path)
300
295
  "socket"
301
296
  when file_class.symlink?(path)
302
297
  "symlink"
@@ -306,12 +301,12 @@ class Chef
306
301
  end
307
302
 
308
303
  def real_file?(path)
309
- !file_class.symlink?(path) && ::TargetIO::File.file?(path)
304
+ !file_class.symlink?(path) && ::File.file?(path)
310
305
  end
311
306
 
312
307
  # like real_file? that follows (sane) symlinks
313
308
  def symlink_to_real_file?(path)
314
- real_file?(::TargetIO::File.realpath(path))
309
+ real_file?(::File.realpath(path))
315
310
  rescue Errno::ELOOP, Errno::ENOENT
316
311
  false
317
312
  end
@@ -319,15 +314,15 @@ class Chef
319
314
  # Similar to File.exist?, but also returns true in the case that the
320
315
  # named file is a broken symlink.
321
316
  def l_exist?(path)
322
- ::TargetIO::File.exist?(path) || file_class.symlink?(path)
317
+ ::File.exist?(path) || file_class.symlink?(path)
323
318
  end
324
319
 
325
320
  def unlink(path)
326
321
  # Directories can not be unlinked. Remove them using FileUtils.
327
- if ::TargetIO::File.directory?(path)
328
- TargetIO::FileUtils.rm_rf(path)
322
+ if ::File.directory?(path)
323
+ FileUtils.rm_rf(path)
329
324
  else
330
- ::TargetIO::File.unlink(path)
325
+ ::File.unlink(path)
331
326
  end
332
327
  end
333
328
 
@@ -349,8 +344,8 @@ class Chef
349
344
  new_resource.verify.each do |v|
350
345
  unless v.verify(tempfile.path)
351
346
  backupfile = "#{Chef::Config[:file_cache_path]}/failed_validations/#{::File.basename(tempfile.path)}"
352
- TargetIO::FileUtils.mkdir_p ::File.dirname(backupfile)
353
- TargetIO::FileUtils.cp tempfile.path, backupfile
347
+ FileUtils.mkdir_p ::File.dirname(backupfile)
348
+ FileUtils.cp tempfile.path, backupfile
354
349
  raise Chef::Exceptions::ValidationFailed.new "Proposed content for #{new_resource.path} failed verification #{new_resource.sensitive ? "[sensitive]" : "#{v}\n#{v.output}"}\nTemporary file moved to #{backupfile}"
355
350
  end
356
351
  end
@@ -379,11 +374,6 @@ class Chef
379
374
  end
380
375
 
381
376
  def do_backup(file = nil)
382
- if ChefConfig::Config.target_mode?
383
- Chef::Log.info("#{@new_resource} backup skipped in Target Mode")
384
- return
385
- end
386
-
387
377
  Chef::Util::Backup.new(new_resource, file).backup!
388
378
  end
389
379
 
@@ -393,14 +383,11 @@ class Chef
393
383
 
394
384
  def update_file_contents
395
385
  do_backup unless needs_creating?
396
- deployment_strategy.deploy(tempfile.path, ::TargetIO::File.realpath(new_resource.path).force_encoding(Chef::Config[:ruby_encoding]))
386
+ deployment_strategy.deploy(tempfile.path, ::File.realpath(new_resource.path).force_encoding(Chef::Config[:ruby_encoding]))
397
387
  logger.info("#{new_resource} updated file contents #{new_resource.path}")
398
388
  if managing_content?
399
389
  # save final checksum for reporting.
400
- resource_to_check = new_resource.path
401
- resource_to_check = ::TargetIO::File.open(resource_to_check) if ChefConfig::Config.target_mode?
402
-
403
- new_resource.final_checksum = checksum(resource_to_check)
390
+ new_resource.final_checksum = checksum(new_resource.path)
404
391
  end
405
392
  end
406
393
 
@@ -413,7 +400,7 @@ class Chef
413
400
  end
414
401
 
415
402
  # the file? on the next line suppresses the case in why-run when we have a not-file here that would have otherwise been removed
416
- if ::TargetIO::File.file?(new_resource.path) && contents_changed?
403
+ if ::File.file?(new_resource.path) && contents_changed?
417
404
  description = [ "update content in file #{new_resource.path} from \
418
405
  #{short_cksum(current_resource.checksum)} to #{short_cksum(tempfile_checksum)}" ]
419
406
 
@@ -445,7 +432,7 @@ class Chef
445
432
  if resource_updated? && Chef::Config[:enable_selinux_file_permission_fixup]
446
433
  if selinux_enabled?
447
434
  converge_by("restore selinux security context") do
448
- restore_security_context(::TargetIO::File.realpath(new_resource.path), recursive)
435
+ restore_security_context(::File.realpath(new_resource.path), recursive)
449
436
  end
450
437
  else
451
438
  logger.trace "selinux utilities can not be found. Skipping selinux permission fixup."
@@ -26,7 +26,7 @@ class Chef
26
26
  class Git < Chef::Provider
27
27
 
28
28
  extend Forwardable
29
- provides :git, target_mode: true
29
+ provides :git
30
30
 
31
31
  GIT_VERSION_PATTERN = Regexp.compile("git version (\\d+\\.\\d+.\\d+)")
32
32
 
@@ -58,7 +58,7 @@ class Chef
58
58
  # Parent directory of the target must exist.
59
59
  requirements.assert(:checkout, :sync) do |a|
60
60
  dirname = ::File.dirname(cwd)
61
- a.assertion { ::TargetIO::File.directory?(dirname) }
61
+ a.assertion { ::File.directory?(dirname) }
62
62
  a.whyrun("Directory #{dirname} does not exist, this run will fail unless it has been previously created. Assuming it would have been created.")
63
63
  a.failure_message(Chef::Exceptions::MissingParentDirectory,
64
64
  "Cannot clone #{new_resource} to #{cwd}, the enclosing directory #{dirname} does not exist")
@@ -101,7 +101,7 @@ class Chef
101
101
  action :export do
102
102
  action_checkout
103
103
  converge_by("complete the export by removing #{cwd}.git after checkout") do
104
- TargetIO::FileUtils.rm_rf(::File.join(cwd, ".git"))
104
+ FileUtils.rm_rf(::File.join(cwd, ".git"))
105
105
  end
106
106
  end
107
107
 
@@ -138,16 +138,16 @@ class Chef
138
138
  end
139
139
 
140
140
  def existing_git_clone?
141
- ::TargetIO::File.exist?(::File.join(cwd, ".git"))
141
+ ::File.exist?(::File.join(cwd, ".git"))
142
142
  end
143
143
 
144
144
  def target_dir_non_existent_or_empty?
145
- !::TargetIO::File.exist?(cwd) || TargetIO::Dir.entries(cwd).sort == [".", ".."]
145
+ !::File.exist?(cwd) || Dir.entries(cwd).sort == [".", ".."]
146
146
  end
147
147
 
148
148
  def find_current_revision
149
149
  logger.trace("#{new_resource} finding current git revision")
150
- if ::TargetIO::File.exist?(::File.join(cwd, ".git"))
150
+ if ::File.exist?(::File.join(cwd, ".git"))
151
151
  # 128 is returned when we're not in a git repo. this is fine
152
152
  result = git("rev-parse", "HEAD", cwd: cwd, returns: [0, 128]).stdout.strip
153
153
  end
@@ -413,9 +413,9 @@ class Chef
413
413
  require "etc" unless defined?(Etc)
414
414
  case user
415
415
  when Integer
416
- TargetIO::Etc.getpwuid(user).dir
416
+ Etc.getpwuid(user).dir
417
417
  else
418
- TargetIO::Etc.getpwnam(user.to_s).dir
418
+ Etc.getpwnam(user.to_s).dir
419
419
  end
420
420
  end
421
421
  end
@@ -22,7 +22,7 @@ class Chef
22
22
  class Provider
23
23
  class Group
24
24
  class Aix < Chef::Provider::Group::Groupadd
25
- provides :group, platform: "aix", target_mode: true
25
+ provides :group, platform: "aix"
26
26
 
27
27
  def required_binaries
28
28
  [ "/usr/bin/mkgroup",
@@ -21,7 +21,7 @@ class Chef
21
21
  class Group
22
22
  class Dscl < Chef::Provider::Group
23
23
 
24
- provides :group, os: "darwin", target_mode: true
24
+ provides :group, os: "darwin"
25
25
 
26
26
  def dscl(*args)
27
27
  argdup = args.dup
@@ -22,7 +22,7 @@ class Chef
22
22
  class Provider
23
23
  class Group
24
24
  class Gpasswd < Chef::Provider::Group::Groupadd
25
- provides :group, target_mode: true
25
+ provides :group
26
26
 
27
27
  def load_current_resource
28
28
  super
@@ -31,7 +31,7 @@ class Chef
31
31
  def define_resource_requirements
32
32
  super
33
33
  requirements.assert(:all_actions) do |a|
34
- a.assertion { ::TargetIO::File.exist?("/usr/bin/gpasswd") }
34
+ a.assertion { ::File.exist?("/usr/bin/gpasswd") }
35
35
  a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/bin/gpasswd for #{new_resource}"
36
36
  # No whyrun alternative: this component should be available in the base install of any given system that uses it
37
37
  end
@@ -35,7 +35,7 @@ class Chef
35
35
  super
36
36
  required_binaries.each do |required_binary|
37
37
  requirements.assert(:all_actions) do |a|
38
- a.assertion { ::TargetIO::File.exist?(required_binary) }
38
+ a.assertion { ::File.exist?(required_binary) }
39
39
  a.failure_message Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{new_resource}"
40
40
  # No whyrun alternative: this component should be available in the base install of any given system that uses it
41
41
  end
@@ -21,12 +21,12 @@ class Chef
21
21
  class Group
22
22
  class Groupmod < Chef::Provider::Group
23
23
 
24
- provides :group, os: "netbsd", target_mode: true
24
+ provides :group, os: "netbsd"
25
25
 
26
26
  def load_current_resource
27
27
  super
28
28
  %w{group user}.each do |binary|
29
- raise Chef::Exceptions::Group, "Could not find binary /usr/sbin/#{binary} for #{new_resource}" unless ::TargetIO::File.exist?("/usr/sbin/#{binary}")
29
+ raise Chef::Exceptions::Group, "Could not find binary /usr/sbin/#{binary} for #{new_resource}" unless ::File.exist?("/usr/sbin/#{binary}")
30
30
  end
31
31
  end
32
32
 
@@ -20,7 +20,7 @@ class Chef
20
20
  class Provider
21
21
  class Group
22
22
  class Pw < Chef::Provider::Group
23
- provides :group, platform: "freebsd", target_mode: true
23
+ provides :group, platform: "freebsd"
24
24
 
25
25
  def load_current_resource
26
26
  super
@@ -30,7 +30,7 @@ class Chef
30
30
  super
31
31
 
32
32
  requirements.assert(:all_actions) do |a|
33
- a.assertion { ::TargetIO::File.exist?("/usr/sbin/pw") }
33
+ a.assertion { ::File.exist?("/usr/sbin/pw") }
34
34
  a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/pw for #{new_resource}"
35
35
  # No whyrun alternative: this component should be available in the base install of any given system that uses it
36
36
  end
@@ -25,7 +25,7 @@ class Chef
25
25
 
26
26
  # this provides line is setup to only catch the solaris2 platform, but
27
27
  # NOT other platforms in the Solaris platform_family. (See usermod provider.)
28
- provides :group, platform: "solaris2", target_mode: true
28
+ provides :group, platform: "solaris2"
29
29
 
30
30
  def load_current_resource
31
31
  super
@@ -35,7 +35,7 @@ class Chef
35
35
  super
36
36
 
37
37
  requirements.assert(:all_actions) do |a|
38
- a.assertion { ::TargetIO::File.exist?("/usr/sbin/usermod") && ::TargetIO::File.exist?("/usr/sbin/groupmod") }
38
+ a.assertion { ::File.exist?("/usr/sbin/usermod") && ::File.exist?("/usr/sbin/groupmod") }
39
39
  a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod or /usr/sbin/groupmod for #{new_resource}"
40
40
  # No whyrun alternative: this component should be available in the base install of any given system that uses it
41
41
  end
@@ -23,7 +23,7 @@ class Chef
23
23
  class Group
24
24
  class Usermod < Chef::Provider::Group::Groupadd
25
25
 
26
- provides :group, os: %w{openbsd solaris2}, target_mode: true
26
+ provides :group, os: %w{openbsd solaris2}
27
27
 
28
28
  def load_current_resource
29
29
  super
@@ -33,7 +33,7 @@ class Chef
33
33
  super
34
34
 
35
35
  requirements.assert(:all_actions) do |a|
36
- a.assertion { ::TargetIO::File.exist?("/usr/sbin/usermod") }
36
+ a.assertion { ::File.exist?("/usr/sbin/usermod") }
37
37
  a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod for #{new_resource}"
38
38
  # No whyrun alternative: this component should be available in the base install of any given system that uses it
39
39
  end
@@ -36,7 +36,7 @@ class Chef
36
36
 
37
37
  group_info = nil
38
38
  begin
39
- group_info = TargetIO::Etc.getgrnam(new_resource.group_name)
39
+ group_info = Etc.getgrnam(new_resource.group_name)
40
40
  rescue ArgumentError
41
41
  @group_exists = false
42
42
  logger.trace("#{new_resource} group does not exist")
@@ -23,12 +23,12 @@ class Chef
23
23
  class Provider
24
24
  class HttpRequest < Chef::Provider
25
25
 
26
- provides :http_request, target_mode: true
26
+ provides :http_request
27
27
 
28
28
  attr_writer :http
29
29
 
30
30
  def http
31
- @http ||= TargetIO::HTTP.new(new_resource.url)
31
+ @http ||= Chef::HTTP::Simple.new(new_resource.url)
32
32
  end
33
33
 
34
34
  def load_current_resource; end
@@ -60,6 +60,7 @@ class Chef
60
60
  new_resource.headers
61
61
  )
62
62
  logger.info("#{new_resource} GET to #{new_resource.url} successful")
63
+ logger.trace("#{new_resource} GET request response: #{body}")
63
64
  end
64
65
  end
65
66
 
@@ -22,7 +22,7 @@ class Chef
22
22
  class Provider
23
23
  class Ifconfig
24
24
  class Aix < Chef::Provider::Ifconfig
25
- provides :ifconfig, platform: "aix", target_mode: true
25
+ provides :ifconfig, platform: "aix"
26
26
 
27
27
  def load_current_resource
28
28
  @current_resource = Chef::Resource::Ifconfig.new(new_resource.name)
@@ -23,7 +23,7 @@ class Chef
23
23
  class Provider
24
24
  class Ifconfig
25
25
  class Debian < Chef::Provider::Ifconfig
26
- provides :ifconfig, platform_family: %w{debian}, target_mode: true
26
+ provides :ifconfig, platform_family: %w{debian}
27
27
 
28
28
  INTERFACES_FILE = "/etc/network/interfaces".freeze
29
29
  INTERFACES_DOT_D_DIR = "/etc/network/interfaces.d".freeze
@@ -81,7 +81,7 @@ iface <%= new_resource.device %> <%= new_resource.family %> static
81
81
 
82
82
  def enforce_interfaces_dot_d_sanity
83
83
  # on ubuntu 18.04+ there's no interfaces file and it uses interfaces.d by default
84
- return if ::TargetIO::File.directory?(INTERFACES_DOT_D_DIR) && !::TargetIO::File.exist?(INTERFACES_FILE)
84
+ return if ::File.directory?(INTERFACES_DOT_D_DIR) && !::File.exist?(INTERFACES_FILE)
85
85
 
86
86
  # create /etc/network/interfaces.d via dir if it's missing
87
87
  directory INTERFACES_DOT_D_DIR
@@ -90,7 +90,7 @@ iface <%= new_resource.device %> <%= new_resource.family %> static
90
90
  interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, "\\.") # escape dots for the regexp
91
91
  regexp = %r{^\s*source\s+#{interfaces_dot_d_for_regexp}/\*\s*$}
92
92
 
93
- return if ::TargetIO::File.exist?(INTERFACES_FILE) && regexp.match(IO.read(INTERFACES_FILE))
93
+ return if ::File.exist?(INTERFACES_FILE) && regexp.match(IO.read(INTERFACES_FILE))
94
94
 
95
95
  converge_by("modifying #{INTERFACES_FILE} to source #{INTERFACES_DOT_D_DIR}") do
96
96
  conf = Chef::Util::FileEdit.new(INTERFACES_FILE)
@@ -22,7 +22,7 @@ class Chef
22
22
  class Provider
23
23
  class Ifconfig
24
24
  class Redhat < Chef::Provider::Ifconfig
25
- provides :ifconfig, platform_family: "fedora_derived", target_mode: true
25
+ provides :ifconfig, platform_family: "fedora_derived"
26
26
 
27
27
  def initialize(new_resource, run_context)
28
28
  super(new_resource, run_context)
@@ -31,7 +31,7 @@ class Chef
31
31
  # device 'eth1'
32
32
  # end
33
33
  class Ifconfig < Chef::Provider
34
- provides :ifconfig, target_mode: true
34
+ provides :ifconfig
35
35
 
36
36
  attr_accessor :config_template
37
37
  attr_accessor :config_path
@@ -28,7 +28,7 @@ class Chef
28
28
  class Provider
29
29
  class Link < Chef::Provider
30
30
 
31
- provides :link, target_mode: true
31
+ provides :link
32
32
 
33
33
  include Chef::Mixin::EnforceOwnershipAndPermissions
34
34
  include Chef::Mixin::FileClass
@@ -43,8 +43,8 @@ class Chef
43
43
  )
44
44
  else
45
45
  current_resource.link_type(:hard)
46
- if ::TargetIO::File.exist?(current_resource.target_file)
47
- if ::TargetIO::File.exist?(new_resource.to) &&
46
+ if ::File.exist?(current_resource.target_file)
47
+ if ::File.exist?(new_resource.to) &&
48
48
  file_class.stat(current_resource.target_file).ino ==
49
49
  file_class.stat(new_resource.to).ino
50
50
  current_resource.to(canonicalize(new_resource.to))
@@ -92,14 +92,14 @@ class Chef
92
92
  # However if the new symlink will point to a file and the current symlink is pointing at a
93
93
  # directory we want to throw an exception and calling ::File.unlink on the directory symlink
94
94
  # will throw the correct ones.
95
- if ChefUtils.windows? && ::TargetIO::File.directory?(new_resource.to) &&
96
- ::TargetIO::File.directory?(current_resource.target_file)
95
+ if ChefUtils.windows? && ::File.directory?(new_resource.to) &&
96
+ ::File.directory?(current_resource.target_file)
97
97
  converge_by("unlink existing windows symlink to dir at #{new_resource.target_file}") do
98
- ::TargetIO::Dir.unlink(new_resource.target_file)
98
+ ::Dir.unlink(new_resource.target_file)
99
99
  end
100
100
  else
101
101
  converge_by("unlink existing symlink to file at #{new_resource.target_file}") do
102
- ::TargetIO::File.unlink(new_resource.target_file)
102
+ ::File.unlink(new_resource.target_file)
103
103
  end
104
104
  end
105
105
  end
@@ -134,14 +134,14 @@ class Chef
134
134
 
135
135
  action :delete do
136
136
  if current_resource.to # Exists
137
- if ChefUtils.windows? && ::TargetIO::File.directory?(current_resource.target_file)
137
+ if ChefUtils.windows? && ::File.directory?(current_resource.target_file)
138
138
  converge_by("delete link to dir at #{new_resource.target_file}") do
139
- ::TargetIO::Dir.delete(new_resource.target_file)
139
+ ::Dir.delete(new_resource.target_file)
140
140
  logger.info("#{new_resource} deleted")
141
141
  end
142
142
  else
143
143
  converge_by("delete link to file at #{new_resource.target_file}") do
144
- ::TargetIO::File.delete(new_resource.target_file)
144
+ ::File.delete(new_resource.target_file)
145
145
  logger.info("#{new_resource} deleted")
146
146
  end
147
147
  end
@@ -21,7 +21,7 @@ class Chef
21
21
  class Provider
22
22
  class Mount
23
23
  class Aix < Chef::Provider::Mount::Mount
24
- provides :mount, platform: "aix", target_mode: true
24
+ provides :mount, platform: "aix"
25
25
 
26
26
  # Override for aix specific handling
27
27
  def initialize(new_resource, run_context)
@@ -163,7 +163,7 @@ class Chef
163
163
  # disable, then enable.
164
164
  disable_fs
165
165
  end
166
- ::TargetIO::File.open("/etc/filesystems", "a") do |fstab|
166
+ ::File.open("/etc/filesystems", "a") do |fstab|
167
167
  fstab.puts("\n\n#{@new_resource.mount_point}:")
168
168
  if network_device?
169
169
  device_details = device_fstab.split(":")
@@ -194,7 +194,7 @@ class Chef
194
194
  contents = []
195
195
  if @current_resource.enabled
196
196
  found_device = false
197
- ::TargetIO::File.open("/etc/filesystems", "r").each_line do |line|
197
+ ::File.open("/etc/filesystems", "r").each_line do |line|
198
198
  case line
199
199
  when %r{^/.+:\s*$}
200
200
  if /#{Regexp.escape(@new_resource.mount_point)}+:/.match?(line)
@@ -207,7 +207,7 @@ class Chef
207
207
  contents << line
208
208
  end
209
209
  end
210
- ::TargetIO::File.open("/etc/filesystems", "w") do |fstab|
210
+ ::File.open("/etc/filesystems", "w") do |fstab|
211
211
  contents.each { |line| fstab.puts line }
212
212
  end
213
213
  else
@@ -23,7 +23,7 @@ class Chef
23
23
  class Mount
24
24
  class Linux < Chef::Provider::Mount::Mount
25
25
 
26
- provides :mount, os: "linux", target_mode: true
26
+ provides :mount, os: "linux"
27
27
 
28
28
  # Check to see if the volume is mounted.
29
29
  # "findmnt" outputs the mount points with volume.
@@ -39,8 +39,8 @@ class Chef
39
39
 
40
40
  def mounted?
41
41
  mounted = false
42
- real_mount_point = if ::TargetIO::File.exist? @new_resource.mount_point
43
- ::TargetIO::File.realpath(@new_resource.mount_point)
42
+ real_mount_point = if ::File.exist? @new_resource.mount_point
43
+ ::File.realpath(@new_resource.mount_point)
44
44
  else
45
45
  @new_resource.mount_point
46
46
  end
@@ -83,4 +83,4 @@ class Chef
83
83
  end
84
84
  end
85
85
  end
86
- end
86
+ end