chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -4
  3. data/README.md +12 -13
  4. data/VERSION +1 -1
  5. data/acceptance/Gemfile +4 -4
  6. data/acceptance/Gemfile.lock +70 -69
  7. data/chef-universal-mingw32.gemspec +2 -3
  8. data/chef.gemspec +6 -6
  9. data/lib/chef/api_client.rb +8 -10
  10. data/lib/chef/api_client_v1.rb +9 -11
  11. data/lib/chef/application/apply.rb +8 -10
  12. data/lib/chef/application/client.rb +1 -1
  13. data/lib/chef/application/exit_code.rb +3 -5
  14. data/lib/chef/application/knife.rb +2 -2
  15. data/lib/chef/application/windows_service.rb +29 -30
  16. data/lib/chef/application/windows_service_manager.rb +1 -1
  17. data/lib/chef/audit/audit_event_proxy.rb +2 -2
  18. data/lib/chef/audit/control_group_data.rb +1 -1
  19. data/lib/chef/chef_class.rb +1 -0
  20. data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
  21. data/lib/chef/chef_fs/command_line.rb +15 -16
  22. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
  23. data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
  24. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
  25. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  26. data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
  27. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
  28. data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
  29. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
  30. data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
  31. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
  32. data/lib/chef/chef_fs/file_pattern.rb +2 -2
  33. data/lib/chef/chef_fs/file_system.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
  35. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
  36. data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
  37. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
  38. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
  39. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
  40. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
  41. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
  42. data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
  43. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
  44. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
  45. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
  46. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
  47. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
  48. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
  49. data/lib/chef/chef_fs/parallelizer.rb +9 -11
  50. data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
  51. data/lib/chef/cookbook/metadata.rb +26 -26
  52. data/lib/chef/cookbook/syntax_check.rb +1 -1
  53. data/lib/chef/cookbook_version.rb +3 -3
  54. data/lib/chef/data_bag.rb +1 -1
  55. data/lib/chef/data_bag_item.rb +3 -3
  56. data/lib/chef/data_collector.rb +3 -4
  57. data/lib/chef/decorator.rb +1 -1
  58. data/lib/chef/deprecated.rb +30 -0
  59. data/lib/chef/dsl/audit.rb +2 -2
  60. data/lib/chef/dsl/declare_resource.rb +1 -1
  61. data/lib/chef/dsl/platform_introspection.rb +29 -31
  62. data/lib/chef/dsl/reboot_pending.rb +1 -1
  63. data/lib/chef/dsl/resources.rb +6 -8
  64. data/lib/chef/encrypted_data_bag_item.rb +2 -2
  65. data/lib/chef/environment.rb +9 -11
  66. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  67. data/lib/chef/exceptions.rb +4 -1
  68. data/lib/chef/file_access_control/unix.rb +14 -14
  69. data/lib/chef/file_access_control/windows.rb +1 -1
  70. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
  71. data/lib/chef/formatters/error_mapper.rb +6 -6
  72. data/lib/chef/http/api_versions.rb +50 -0
  73. data/lib/chef/http/validate_content_length.rb +2 -2
  74. data/lib/chef/json_compat.rb +6 -10
  75. data/lib/chef/key.rb +5 -5
  76. data/lib/chef/knife.rb +4 -4
  77. data/lib/chef/knife/cookbook_site_install.rb +2 -2
  78. data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
  79. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  80. data/lib/chef/knife/core/status_presenter.rb +1 -1
  81. data/lib/chef/knife/core/ui.rb +19 -25
  82. data/lib/chef/knife/data_bag_secret_options.rb +1 -1
  83. data/lib/chef/knife/deps.rb +32 -34
  84. data/lib/chef/knife/help.rb +1 -1
  85. data/lib/chef/knife/list.rb +1 -1
  86. data/lib/chef/knife/search.rb +2 -2
  87. data/lib/chef/knife/ssh.rb +37 -27
  88. data/lib/chef/knife/ssl_check.rb +1 -1
  89. data/lib/chef/knife/user_delete.rb +1 -1
  90. data/lib/chef/mash.rb +1 -1
  91. data/lib/chef/mixin/command.rb +2 -2
  92. data/lib/chef/mixin/create_path.rb +3 -5
  93. data/lib/chef/mixin/from_file.rb +2 -2
  94. data/lib/chef/mixin/get_source_from_package.rb +2 -2
  95. data/lib/chef/mixin/notifying_block.rb +7 -9
  96. data/lib/chef/mixin/params_validate.rb +3 -3
  97. data/lib/chef/mixin/securable.rb +1 -1
  98. data/lib/chef/mixin/shell_out.rb +23 -3
  99. data/lib/chef/mixin/unformatter.rb +2 -2
  100. data/lib/chef/mixin/uris.rb +4 -6
  101. data/lib/chef/mixin/versioned_api.rb +69 -0
  102. data/lib/chef/mixin/which.rb +25 -8
  103. data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
  104. data/lib/chef/mixin/xml_escape.rb +3 -5
  105. data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
  106. data/lib/chef/node.rb +8 -8
  107. data/lib/chef/node/attribute.rb +4 -4
  108. data/lib/chef/node/common_api.rb +5 -7
  109. data/lib/chef/org.rb +10 -12
  110. data/lib/chef/platform/provider_mapping.rb +7 -7
  111. data/lib/chef/platform/query_helpers.rb +1 -1
  112. data/lib/chef/policy_builder/policyfile.rb +1 -0
  113. data/lib/chef/property.rb +31 -0
  114. data/lib/chef/provider/batch.rb +1 -1
  115. data/lib/chef/provider/breakpoint.rb +1 -1
  116. data/lib/chef/provider/cookbook_file.rb +3 -3
  117. data/lib/chef/provider/cron.rb +38 -38
  118. data/lib/chef/provider/deploy.rb +81 -81
  119. data/lib/chef/provider/deploy/revision.rb +3 -5
  120. data/lib/chef/provider/directory.rb +32 -32
  121. data/lib/chef/provider/dsc_resource.rb +22 -6
  122. data/lib/chef/provider/env.rb +28 -28
  123. data/lib/chef/provider/env/windows.rb +1 -1
  124. data/lib/chef/provider/erl_call.rb +13 -13
  125. data/lib/chef/provider/execute.rb +5 -2
  126. data/lib/chef/provider/file.rb +49 -51
  127. data/lib/chef/provider/git.rb +55 -55
  128. data/lib/chef/provider/http_request.rb +36 -36
  129. data/lib/chef/provider/launchd.rb +2 -2
  130. data/lib/chef/provider/link.rb +50 -50
  131. data/lib/chef/provider/log.rb +2 -2
  132. data/lib/chef/provider/mdadm.rb +25 -25
  133. data/lib/chef/provider/mount/aix.rb +2 -2
  134. data/lib/chef/provider/mount/mount.rb +2 -2
  135. data/lib/chef/provider/ohai.rb +1 -1
  136. data/lib/chef/provider/osx_profile.rb +23 -23
  137. data/lib/chef/provider/package.rb +74 -56
  138. data/lib/chef/provider/package/aix.rb +55 -52
  139. data/lib/chef/provider/package/apt.rb +15 -13
  140. data/lib/chef/provider/package/cab.rb +49 -20
  141. data/lib/chef/provider/package/chocolatey.rb +9 -10
  142. data/lib/chef/provider/package/dnf.rb +20 -18
  143. data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
  144. data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
  145. data/lib/chef/provider/package/dnf/version.rb +1 -1
  146. data/lib/chef/provider/package/dpkg.rb +8 -9
  147. data/lib/chef/provider/package/easy_install.rb +22 -22
  148. data/lib/chef/provider/package/freebsd/base.rb +10 -10
  149. data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
  150. data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
  151. data/lib/chef/provider/package/freebsd/port.rb +7 -7
  152. data/lib/chef/provider/package/homebrew.rb +11 -10
  153. data/lib/chef/provider/package/ips.rb +18 -23
  154. data/lib/chef/provider/package/macports.rb +23 -23
  155. data/lib/chef/provider/package/msu.rb +11 -11
  156. data/lib/chef/provider/package/openbsd.rb +25 -22
  157. data/lib/chef/provider/package/pacman.rb +16 -16
  158. data/lib/chef/provider/package/paludis.rb +26 -27
  159. data/lib/chef/provider/package/portage.rb +22 -22
  160. data/lib/chef/provider/package/powershell.rb +17 -17
  161. data/lib/chef/provider/package/rpm.rb +25 -25
  162. data/lib/chef/provider/package/rubygems.rb +60 -60
  163. data/lib/chef/provider/package/smartos.rb +16 -16
  164. data/lib/chef/provider/package/solaris.rb +44 -44
  165. data/lib/chef/provider/package/windows.rb +3 -3
  166. data/lib/chef/provider/package/windows/exe.rb +6 -6
  167. data/lib/chef/provider/package/windows/msi.rb +6 -6
  168. data/lib/chef/provider/package/yum.rb +318 -268
  169. data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
  170. data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
  171. data/lib/chef/provider/package/zypper.rb +11 -11
  172. data/lib/chef/provider/powershell_script.rb +15 -7
  173. data/lib/chef/provider/reboot.rb +10 -10
  174. data/lib/chef/provider/registry_key.rb +39 -39
  175. data/lib/chef/provider/remote_directory.rb +3 -3
  176. data/lib/chef/provider/remote_file.rb +3 -3
  177. data/lib/chef/provider/route.rb +1 -1
  178. data/lib/chef/provider/ruby_block.rb +3 -3
  179. data/lib/chef/provider/script.rb +42 -6
  180. data/lib/chef/provider/service.rb +49 -49
  181. data/lib/chef/provider/service/solaris.rb +1 -1
  182. data/lib/chef/provider/service/systemd.rb +1 -1
  183. data/lib/chef/provider/subversion.rb +39 -39
  184. data/lib/chef/provider/systemd_unit.rb +2 -0
  185. data/lib/chef/provider/template.rb +3 -3
  186. data/lib/chef/provider/user.rb +42 -42
  187. data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
  188. data/lib/chef/resource.rb +27 -16
  189. data/lib/chef/resource/apt_repository.rb +0 -1
  190. data/lib/chef/resource/chef_gem.rb +1 -1
  191. data/lib/chef/resource/dnf_package.rb +6 -3
  192. data/lib/chef/resource/dsc_resource.rb +9 -1
  193. data/lib/chef/resource/execute.rb +70 -6
  194. data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
  195. data/lib/chef/resource/freebsd_package.rb +1 -1
  196. data/lib/chef/resource/gem_package.rb +1 -1
  197. data/lib/chef/resource/launchd.rb +13 -1
  198. data/lib/chef/resource/package.rb +2 -2
  199. data/lib/chef/resource/registry_key.rb +1 -1
  200. data/lib/chef/resource/yum_package.rb +12 -3
  201. data/lib/chef/resource/yum_repository.rb +0 -1
  202. data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
  203. data/lib/chef/resource_collection/resource_set.rb +2 -2
  204. data/lib/chef/resource_reporter.rb +1 -1
  205. data/lib/chef/run_context.rb +3 -3
  206. data/lib/chef/run_list/run_list_item.rb +1 -1
  207. data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
  208. data/lib/chef/server_api.rb +2 -0
  209. data/lib/chef/server_api_versions.rb +40 -0
  210. data/lib/chef/shell.rb +1 -1
  211. data/lib/chef/shell/ext.rb +3 -3
  212. data/lib/chef/shell/shell_session.rb +1 -1
  213. data/lib/chef/user.rb +9 -11
  214. data/lib/chef/user_v1.rb +9 -11
  215. data/lib/chef/util/diff.rb +1 -1
  216. data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
  217. data/lib/chef/util/selinux.rb +1 -1
  218. data/lib/chef/util/windows/net_group.rb +18 -30
  219. data/lib/chef/util/windows/net_use.rb +7 -11
  220. data/lib/chef/util/windows/net_user.rb +11 -17
  221. data/lib/chef/util/windows/volume.rb +9 -15
  222. data/lib/chef/version.rb +1 -1
  223. data/lib/chef/version_class.rb +1 -1
  224. data/lib/chef/win32/api.rb +4 -6
  225. data/lib/chef/win32/api/file.rb +25 -31
  226. data/lib/chef/win32/api/installer.rb +2 -2
  227. data/lib/chef/win32/file.rb +4 -6
  228. data/lib/chef/win32/registry.rb +9 -9
  229. data/lib/chef/win32/security.rb +2 -2
  230. data/lib/chef/win32/security/acl.rb +2 -2
  231. data/lib/chef/win32/unicode.rb +2 -2
  232. data/lib/chef/win32/version.rb +1 -1
  233. data/spec/data/prefer_metadata_json/metadata.json +51 -0
  234. data/spec/data/prefer_metadata_json/metadata.rb +6 -0
  235. data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
  236. data/spec/functional/knife/ssh_spec.rb +5 -5
  237. data/spec/functional/resource/batch_spec.rb +5 -1
  238. data/spec/functional/resource/dsc_script_spec.rb +2 -4
  239. data/spec/functional/resource/execute_spec.rb +17 -0
  240. data/spec/functional/resource/user/dscl_spec.rb +2 -4
  241. data/spec/integration/client/client_spec.rb +33 -0
  242. data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
  243. data/spec/spec_helper.rb +4 -0
  244. data/spec/support/chef_helpers.rb +5 -7
  245. data/spec/support/platform_helpers.rb +6 -0
  246. data/spec/support/platforms/prof/gc.rb +4 -6
  247. data/spec/support/shared/context/client.rb +1 -1
  248. data/spec/support/shared/functional/execute_resource.rb +150 -0
  249. data/spec/support/shared/functional/windows_script.rb +74 -4
  250. data/spec/support/shared/unit/execute_resource.rb +37 -0
  251. data/spec/support/shared/unit/provider/file.rb +10 -0
  252. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
  253. data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
  254. data/spec/unit/http/api_versions_spec.rb +69 -0
  255. data/spec/unit/knife/ssh_spec.rb +34 -36
  256. data/spec/unit/mixin/versioned_api_spec.rb +107 -0
  257. data/spec/unit/mixin/which.rb +160 -0
  258. data/spec/unit/platform_spec.rb +28 -1
  259. data/spec/unit/provider/deploy_spec.rb +1 -1
  260. data/spec/unit/provider/directory_spec.rb +10 -0
  261. data/spec/unit/provider/dsc_resource_spec.rb +175 -0
  262. data/spec/unit/provider/execute_spec.rb +0 -1
  263. data/spec/unit/provider/launchd_spec.rb +2 -2
  264. data/spec/unit/provider/package/aix_spec.rb +22 -22
  265. data/spec/unit/provider/package/apt_spec.rb +27 -27
  266. data/spec/unit/provider/package/cab_spec.rb +59 -5
  267. data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
  268. data/spec/unit/provider/package/dpkg_spec.rb +16 -16
  269. data/spec/unit/provider/package/easy_install_spec.rb +18 -18
  270. data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
  271. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
  272. data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
  273. data/spec/unit/provider/package/homebrew_spec.rb +9 -9
  274. data/spec/unit/provider/package/ips_spec.rb +37 -31
  275. data/spec/unit/provider/package/macports_spec.rb +10 -10
  276. data/spec/unit/provider/package/openbsd_spec.rb +10 -10
  277. data/spec/unit/provider/package/pacman_spec.rb +6 -6
  278. data/spec/unit/provider/package/paludis_spec.rb +7 -7
  279. data/spec/unit/provider/package/portage_spec.rb +6 -7
  280. data/spec/unit/provider/package/rpm_spec.rb +23 -23
  281. data/spec/unit/provider/package/rubygems_spec.rb +38 -38
  282. data/spec/unit/provider/package/solaris_spec.rb +15 -15
  283. data/spec/unit/provider/package/windows_spec.rb +2 -1
  284. data/spec/unit/provider/package/yum_spec.rb +51 -43
  285. data/spec/unit/provider/package/zypper_spec.rb +34 -34
  286. data/spec/unit/provider/package_spec.rb +8 -0
  287. data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
  288. data/spec/unit/provider/route_spec.rb +7 -1
  289. data/spec/unit/provider/script_spec.rb +49 -6
  290. data/spec/unit/resource/dsc_resource_spec.rb +6 -0
  291. data/spec/unit/resource/execute_spec.rb +214 -0
  292. data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
  293. data/spec/unit/resource/freebsd_package_spec.rb +2 -2
  294. data/spec/unit/resource/package_spec.rb +5 -0
  295. data/spec/unit/resource/yum_package_spec.rb +42 -1
  296. data/spec/unit/resource_reporter_spec.rb +1 -1
  297. data/spec/unit/resource_spec.rb +18 -0
  298. data/spec/unit/server_api_versions_spec.rb +44 -0
  299. data/spec/unit/util/selinux_spec.rb +3 -14
  300. data/spec/unit/win32/error_spec.rb +67 -0
  301. data/spec/unit/win32/security_spec.rb +66 -0
  302. data/tasks/changelog.rb +1 -1
  303. data/tasks/dependencies.rb +20 -4
  304. metadata +39 -18
  305. data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -91,11 +91,9 @@ class Chef
91
91
  end
92
92
 
93
93
  def load_cache
94
- begin
95
- Chef::JSONCompat.parse(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
96
- rescue Chef::Exceptions::FileNotFound
97
- sorted_releases_from_filesystem
98
- end
94
+ Chef::JSONCompat.parse(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
95
+ rescue Chef::Exceptions::FileNotFound
96
+ sorted_releases_from_filesystem
99
97
  end
100
98
 
101
99
  def save_cache(cache)
@@ -34,12 +34,12 @@ class Chef
34
34
  end
35
35
 
36
36
  def load_current_resource
37
- @current_resource = Chef::Resource::Directory.new(@new_resource.name)
38
- @current_resource.path(@new_resource.path)
39
- if ::File.exists?(@current_resource.path) && @action != :create_if_missing
40
- load_resource_attributes_from_file(@current_resource)
37
+ @current_resource = Chef::Resource::Directory.new(new_resource.name)
38
+ current_resource.path(new_resource.path)
39
+ if ::File.exists?(current_resource.path) && @action != :create_if_missing
40
+ load_resource_attributes_from_file(current_resource)
41
41
  end
42
- @current_resource
42
+ current_resource
43
43
  end
44
44
 
45
45
  def define_resource_requirements
@@ -49,9 +49,9 @@ class Chef
49
49
  requirements.assert(:create) do |a|
50
50
  # Make sure the parent dir exists, or else fail.
51
51
  # for why run, print a message explaining the potential error.
52
- parent_directory = ::File.dirname(@new_resource.path)
52
+ parent_directory = ::File.dirname(new_resource.path)
53
53
  a.assertion do
54
- if @new_resource.recursive
54
+ if new_resource.recursive
55
55
  does_parent_exist = lambda do |base_dir|
56
56
  base_dir = ::File.dirname(base_dir)
57
57
  if ::File.exist?(base_dir)
@@ -60,20 +60,20 @@ class Chef
60
60
  does_parent_exist.call(base_dir)
61
61
  end
62
62
  end
63
- does_parent_exist.call(@new_resource.path)
63
+ does_parent_exist.call(new_resource.path)
64
64
  else
65
65
  ::File.directory?(parent_directory)
66
66
  end
67
67
  end
68
- a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist, cannot create #{@new_resource.path}")
68
+ a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist, cannot create #{new_resource.path}")
69
69
  a.whyrun("Assuming directory #{parent_directory} would have been created")
70
70
  end
71
71
 
72
72
  requirements.assert(:create) do |a|
73
- parent_directory = ::File.dirname(@new_resource.path)
73
+ parent_directory = ::File.dirname(new_resource.path)
74
74
  a.assertion do
75
- if @new_resource.recursive
76
- # find the lowest-level directory in @new_resource.path that already exists
75
+ if new_resource.recursive
76
+ # find the lowest-level directory in new_resource.path that already exists
77
77
  # make sure we have write permissions to that directory
78
78
  is_parent_writable = lambda do |base_dir|
79
79
  base_dir = ::File.dirname(base_dir)
@@ -89,7 +89,7 @@ class Chef
89
89
  is_parent_writable.call(base_dir)
90
90
  end
91
91
  end
92
- is_parent_writable.call(@new_resource.path)
92
+ is_parent_writable.call(new_resource.path)
93
93
  else
94
94
  # in why run mode & parent directory does not exist no permissions check is required
95
95
  # If not in why run, permissions must be valid and we rely on prior assertion that dir exists
@@ -97,7 +97,7 @@ class Chef
97
97
  if Chef::FileAccessControl.writable?(parent_directory)
98
98
  true
99
99
  elsif Chef::Util::PathHelper.is_sip_path?(parent_directory, node)
100
- Chef::Util::PathHelper.writable_sip_path?(@new_resource.path)
100
+ Chef::Util::PathHelper.writable_sip_path?(new_resource.path)
101
101
  else
102
102
  false
103
103
  end
@@ -107,18 +107,18 @@ class Chef
107
107
  end
108
108
  end
109
109
  a.failure_message(Chef::Exceptions::InsufficientPermissions,
110
- "Cannot create #{@new_resource} at #{@new_resource.path} due to insufficient permissions")
110
+ "Cannot create #{new_resource} at #{new_resource.path} due to insufficient permissions")
111
111
  end
112
112
 
113
113
  requirements.assert(:delete) do |a|
114
114
  a.assertion do
115
- if ::File.exists?(@new_resource.path)
116
- ::File.directory?(@new_resource.path) && Chef::FileAccessControl.writable?(@new_resource.path)
115
+ if ::File.exists?(new_resource.path)
116
+ ::File.directory?(new_resource.path) && Chef::FileAccessControl.writable?(new_resource.path)
117
117
  else
118
118
  true
119
119
  end
120
120
  end
121
- a.failure_message(RuntimeError, "Cannot delete #{@new_resource} at #{@new_resource.path}!")
121
+ a.failure_message(RuntimeError, "Cannot delete #{new_resource} at #{new_resource.path}!")
122
122
  # No why-run handling here:
123
123
  # * if we don't have permissions, this is unlikely to be changed earlier in the run
124
124
  # * if the target is a file (not a dir), there's no reasonable path by which this would have been changed
@@ -126,32 +126,32 @@ class Chef
126
126
  end
127
127
 
128
128
  def action_create
129
- unless ::File.exists?(@new_resource.path)
130
- converge_by("create new directory #{@new_resource.path}") do
131
- if @new_resource.recursive == true
132
- ::FileUtils.mkdir_p(@new_resource.path)
129
+ unless ::File.exists?(new_resource.path)
130
+ converge_by("create new directory #{new_resource.path}") do
131
+ if new_resource.recursive == true
132
+ ::FileUtils.mkdir_p(new_resource.path)
133
133
  else
134
- ::Dir.mkdir(@new_resource.path)
134
+ ::Dir.mkdir(new_resource.path)
135
135
  end
136
- Chef::Log.info("#{@new_resource} created directory #{@new_resource.path}")
136
+ Chef::Log.info("#{new_resource} created directory #{new_resource.path}")
137
137
  end
138
138
  end
139
139
  do_acl_changes
140
140
  do_selinux(true)
141
- load_resource_attributes_from_file(@new_resource)
141
+ load_resource_attributes_from_file(new_resource) unless Chef::Config[:why_run]
142
142
  end
143
143
 
144
144
  def action_delete
145
- if ::File.exists?(@new_resource.path)
146
- converge_by("delete existing directory #{@new_resource.path}") do
147
- if @new_resource.recursive == true
145
+ if ::File.exists?(new_resource.path)
146
+ converge_by("delete existing directory #{new_resource.path}") do
147
+ if new_resource.recursive == true
148
148
  # we don't use rm_rf here because it masks all errors, including
149
149
  # IO errors or permission errors that would prvent the deletion
150
- FileUtils.rm_r(@new_resource.path)
151
- Chef::Log.info("#{@new_resource} deleted #{@new_resource.path} recursively")
150
+ FileUtils.rm_r(new_resource.path)
151
+ Chef::Log.info("#{new_resource} deleted #{new_resource.path} recursively")
152
152
  else
153
- ::Dir.delete(@new_resource.path)
154
- Chef::Log.info("#{@new_resource} deleted #{@new_resource.path}")
153
+ ::Dir.delete(new_resource.path)
154
+ Chef::Log.info("#{new_resource} deleted #{new_resource.path}")
155
155
  end
156
156
  end
157
157
  end
@@ -29,6 +29,7 @@ class Chef
29
29
  super
30
30
  @new_resource = new_resource
31
31
  @module_name = new_resource.module_name
32
+ @module_version = new_resource.module_version
32
33
  @reboot_resource = nil
33
34
  end
34
35
 
@@ -65,6 +66,13 @@ class Chef
65
66
  a.whyrun err + ["Assuming a previous resource sets the RefreshMode."]
66
67
  a.block_action!
67
68
  end
69
+ requirements.assert(:run) do |a|
70
+ a.assertion { module_usage_valid? }
71
+ err = ["module_name must be supplied along with module_version."]
72
+ a.failure_message Chef::Exceptions::DSCModuleNameMissing,
73
+ err
74
+ a.block_action!
75
+ end
68
76
  end
69
77
 
70
78
  protected
@@ -92,6 +100,10 @@ class Chef
92
100
  Chef::Platform.supports_refresh_mode_enabled?(node)
93
101
  end
94
102
 
103
+ def module_usage_valid?
104
+ !(!@module_name && @module_version)
105
+ end
106
+
95
107
  def generate_description
96
108
  @converge_description
97
109
  end
@@ -148,10 +160,14 @@ class Chef
148
160
  end
149
161
  end
150
162
 
163
+ def module_info_object
164
+ @module_version.nil? ? module_name : "@{ModuleName='#{module_name}';ModuleVersion='#{@module_version}'}"
165
+ end
166
+
151
167
  def invoke_resource(method, output_format = :object)
152
- properties = translate_type(@new_resource.properties)
153
- switches = "-Method #{method} -Name #{@new_resource.resource}"\
154
- " -Property #{properties} -Module #{module_name} -Verbose"
168
+ properties = translate_type(new_resource.properties)
169
+ switches = "-Method #{method} -Name #{new_resource.resource}"\
170
+ " -Property #{properties} -Module #{module_info_object} -Verbose"
155
171
  cmdlet = Chef::Util::Powershell::Cmdlet.new(
156
172
  node,
157
173
  "Invoke-DscResource #{switches}",
@@ -172,15 +188,15 @@ class Chef
172
188
 
173
189
  def create_reboot_resource
174
190
  @reboot_resource = Chef::Resource::Reboot.new(
175
- "Reboot for #{@new_resource.name}",
191
+ "Reboot for #{new_resource.name}",
176
192
  run_context
177
193
  ).tap do |r|
178
- r.reason("Reboot for #{@new_resource.resource}.")
194
+ r.reason("Reboot for #{new_resource.resource}.")
179
195
  end
180
196
  end
181
197
 
182
198
  def reboot_if_required
183
- reboot_action = @new_resource.reboot_action
199
+ reboot_action = new_resource.reboot_action
184
200
  unless @reboot_resource.nil?
185
201
  case reboot_action
186
202
  when :nothing
@@ -34,17 +34,17 @@ class Chef
34
34
  end
35
35
 
36
36
  def load_current_resource
37
- @current_resource = Chef::Resource::Env.new(@new_resource.name)
38
- @current_resource.key_name(@new_resource.key_name)
37
+ @current_resource = Chef::Resource::Env.new(new_resource.name)
38
+ current_resource.key_name(new_resource.key_name)
39
39
 
40
- if env_key_exists(@new_resource.key_name)
41
- @current_resource.value(env_value(@new_resource.key_name))
40
+ if env_key_exists(new_resource.key_name)
41
+ current_resource.value(env_value(new_resource.key_name))
42
42
  else
43
43
  @key_exists = false
44
- Chef::Log.debug("#{@new_resource} key does not exist")
44
+ Chef::Log.debug("#{new_resource} key does not exist")
45
45
  end
46
46
 
47
- @current_resource
47
+ current_resource
48
48
  end
49
49
 
50
50
  def env_value(key_name)
@@ -61,7 +61,7 @@ class Chef
61
61
  # <true>:: If a change is required
62
62
  # <false>:: If a change is not required
63
63
  def requires_modify_or_create?
64
- if @new_resource.delim
64
+ if new_resource.delim
65
65
  #e.g. check for existing value within PATH
66
66
  new_values.inject(0) do |index, val|
67
67
  next_index = current_values.find_index val
@@ -70,7 +70,7 @@ class Chef
70
70
  end
71
71
  false
72
72
  else
73
- @new_resource.value != @current_resource.value
73
+ new_resource.value != current_resource.value
74
74
  end
75
75
  end
76
76
 
@@ -80,13 +80,13 @@ class Chef
80
80
  if @key_exists
81
81
  if requires_modify_or_create?
82
82
  modify_env
83
- Chef::Log.info("#{@new_resource} altered")
84
- @new_resource.updated_by_last_action(true)
83
+ Chef::Log.info("#{new_resource} altered")
84
+ new_resource.updated_by_last_action(true)
85
85
  end
86
86
  else
87
87
  create_env
88
- Chef::Log.info("#{@new_resource} created")
89
- @new_resource.updated_by_last_action(true)
88
+ Chef::Log.info("#{new_resource} created")
89
+ new_resource.updated_by_last_action(true)
90
90
  end
91
91
  end
92
92
 
@@ -97,24 +97,24 @@ class Chef
97
97
  # <false>:: Caller should delete the key, either no :delim was specific or value was empty
98
98
  # after we removed the element.
99
99
  def delete_element
100
- return false unless @new_resource.delim #no delim: delete the key
100
+ return false unless new_resource.delim #no delim: delete the key
101
101
  needs_delete = new_values.any? { |v| current_values.include?(v) }
102
102
  if !needs_delete
103
- Chef::Log.debug("#{@new_resource} element '#{@new_resource.value}' does not exist")
103
+ Chef::Log.debug("#{new_resource} element '#{new_resource.value}' does not exist")
104
104
  return true #do not delete the key
105
105
  else
106
106
  new_value =
107
107
  current_values.select do |item|
108
108
  not new_values.include?(item)
109
- end.join(@new_resource.delim)
109
+ end.join(new_resource.delim)
110
110
 
111
111
  if new_value.empty?
112
112
  return false #nothing left here, delete the key
113
113
  else
114
- old_value = @new_resource.value(new_value)
114
+ old_value = new_resource.value(new_value)
115
115
  create_env
116
- Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
117
- @new_resource.updated_by_last_action(true)
116
+ Chef::Log.debug("#{new_resource} deleted #{old_value} element")
117
+ new_resource.updated_by_last_action(true)
118
118
  return true #we removed the element and updated; do not delete the key
119
119
  end
120
120
  end
@@ -123,8 +123,8 @@ class Chef
123
123
  def action_delete
124
124
  if @key_exists && !delete_element
125
125
  delete_env
126
- Chef::Log.info("#{@new_resource} deleted")
127
- @new_resource.updated_by_last_action(true)
126
+ Chef::Log.info("#{new_resource} deleted")
127
+ new_resource.updated_by_last_action(true)
128
128
  end
129
129
  end
130
130
 
@@ -132,16 +132,16 @@ class Chef
132
132
  if @key_exists
133
133
  if requires_modify_or_create?
134
134
  modify_env
135
- Chef::Log.info("#{@new_resource} modified")
136
- @new_resource.updated_by_last_action(true)
135
+ Chef::Log.info("#{new_resource} modified")
136
+ new_resource.updated_by_last_action(true)
137
137
  end
138
138
  else
139
- raise Chef::Exceptions::Env, "Cannot modify #{@new_resource} - key does not exist!"
139
+ raise Chef::Exceptions::Env, "Cannot modify #{new_resource} - key does not exist!"
140
140
  end
141
141
  end
142
142
 
143
143
  def create_env
144
- raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :#{@new_resource.action}"
144
+ raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :#{new_resource.action}"
145
145
  end
146
146
 
147
147
  def delete_env
@@ -149,20 +149,20 @@ class Chef
149
149
  end
150
150
 
151
151
  def modify_env
152
- if @new_resource.delim
153
- @new_resource.value((new_values + current_values).uniq.join(@new_resource.delim))
152
+ if new_resource.delim
153
+ new_resource.value((new_values + current_values).uniq.join(new_resource.delim))
154
154
  end
155
155
  create_env
156
156
  end
157
157
 
158
158
  # Returns the current values to split by delimiter
159
159
  def current_values
160
- @current_values ||= @current_resource.value.split(@new_resource.delim)
160
+ @current_values ||= current_resource.value.split(new_resource.delim)
161
161
  end
162
162
 
163
163
  # Returns the new values to split by delimiter
164
164
  def new_values
165
- @new_values ||= @new_resource.value.split(@new_resource.delim)
165
+ @new_values ||= new_resource.value.split(new_resource.delim)
166
166
  end
167
167
  end
168
168
  end
@@ -54,7 +54,7 @@ class Chef
54
54
 
55
55
  def env_value(key_name)
56
56
  obj = env_obj(key_name)
57
- return obj ? obj.variablevalue : ENV[key_name]
57
+ obj ? obj.variablevalue : ENV[key_name]
58
58
  end
59
59
 
60
60
  def env_obj(key_name)
@@ -40,20 +40,20 @@ class Chef
40
40
  end
41
41
 
42
42
  def action_run
43
- case @new_resource.name_type
43
+ case new_resource.name_type
44
44
  when "sname"
45
- node = "-sname #{@new_resource.node_name}"
45
+ node = "-sname #{new_resource.node_name}"
46
46
  when "name"
47
- node = "-name #{@new_resource.node_name}"
47
+ node = "-name #{new_resource.node_name}"
48
48
  end
49
49
 
50
- if @new_resource.cookie
51
- cookie = "-c #{@new_resource.cookie}"
50
+ if new_resource.cookie
51
+ cookie = "-c #{new_resource.cookie}"
52
52
  else
53
53
  cookie = ""
54
54
  end
55
55
 
56
- if @new_resource.distributed
56
+ if new_resource.distributed
57
57
  distributed = "-s"
58
58
  else
59
59
  distributed = ""
@@ -65,15 +65,15 @@ class Chef
65
65
  begin
66
66
  pid, stdin, stdout, stderr = popen4(command, :waitlast => true)
67
67
 
68
- Chef::Log.debug("#{@new_resource} running")
69
- Chef::Log.debug("#{@new_resource} command: #{command}")
70
- Chef::Log.debug("#{@new_resource} code: #{@new_resource.code}")
68
+ Chef::Log.debug("#{new_resource} running")
69
+ Chef::Log.debug("#{new_resource} command: #{command}")
70
+ Chef::Log.debug("#{new_resource} code: #{new_resource.code}")
71
71
 
72
- @new_resource.code.each_line { |line| stdin.puts(line.chomp) }
72
+ new_resource.code.each_line { |line| stdin.puts(line.chomp) }
73
73
 
74
74
  stdin.close
75
75
 
76
- Chef::Log.debug("#{@new_resource} output: ")
76
+ Chef::Log.debug("#{new_resource} output: ")
77
77
 
78
78
  stdout_output = ""
79
79
  stdout.each_line { |line| stdout_output << line }
@@ -93,9 +93,9 @@ class Chef
93
93
  raise Chef::Exceptions::ErlCall, stdout_output
94
94
  end
95
95
 
96
- @new_resource.updated_by_last_action(true)
96
+ new_resource.updated_by_last_action(true)
97
97
 
98
- Chef::Log.debug("#{@new_resource} #{stdout_output}")
98
+ Chef::Log.debug("#{new_resource} #{stdout_output}")
99
99
  Chef::Log.info("#{@new_resouce} ran successfully")
100
100
  ensure
101
101
  Process.wait(pid) if pid
@@ -27,7 +27,7 @@ class Chef
27
27
 
28
28
  provides :execute
29
29
 
30
- def_delegators :@new_resource, :command, :returns, :environment, :user, :group, :cwd, :umask, :creates
30
+ def_delegators :new_resource, :command, :returns, :environment, :user, :domain, :password, :group, :cwd, :umask, :creates
31
31
 
32
32
  def load_current_resource
33
33
  current_resource = Chef::Resource::Execute.new(new_resource.name)
@@ -39,7 +39,7 @@ class Chef
39
39
  end
40
40
 
41
41
  def define_resource_requirements
42
- # @todo: this should change to raise in some appropriate major version bump.
42
+ # @todo: this should change to raise in some appropriate major version bump.
43
43
  if creates && creates_relative? && !cwd
44
44
  Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)"
45
45
  end
@@ -92,6 +92,8 @@ class Chef
92
92
  opts[:returns] = returns if returns
93
93
  opts[:environment] = environment if environment
94
94
  opts[:user] = user if user
95
+ opts[:domain] = domain if domain
96
+ opts[:password] = password if password
95
97
  opts[:group] = group if group
96
98
  opts[:cwd] = cwd if cwd
97
99
  opts[:umask] = umask if umask
@@ -120,6 +122,7 @@ class Chef
120
122
  ( cwd && creates_relative? ) ? ::File.join(cwd, creates) : creates
121
123
  ))
122
124
  end
125
+
123
126
  end
124
127
  end
125
128
  end