chef 11.18.12-x86-mingw32 → 12.0.0.alpha.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +10 -0
  3. data/README.md +1 -1
  4. data/distro/common/html/_sources/index.txt +5 -2
  5. data/distro/common/html/_sources/knife_serve.txt +19 -0
  6. data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
  7. data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
  8. data/distro/common/html/_static/basic.css +1 -1
  9. data/distro/common/html/_static/doctools.js +1 -1
  10. data/distro/common/html/_static/searchtools.js +1 -1
  11. data/distro/common/html/_static/websupport.js +1 -1
  12. data/distro/common/html/ctl_chef_client.html +19 -9
  13. data/distro/common/html/ctl_chef_server.html +7 -1
  14. data/distro/common/html/ctl_chef_shell.html +3 -4
  15. data/distro/common/html/ctl_chef_solo.html +12 -7
  16. data/distro/common/html/index.html +19 -12
  17. data/distro/common/html/knife.html +1 -2
  18. data/distro/common/html/knife_bootstrap.html +16 -5
  19. data/distro/common/html/knife_client.html +8 -5
  20. data/distro/common/html/knife_common_options.html +11 -12
  21. data/distro/common/html/knife_configure.html +2 -3
  22. data/distro/common/html/knife_cookbook.html +16 -17
  23. data/distro/common/html/knife_cookbook_site.html +19 -18
  24. data/distro/common/html/knife_data_bag.html +6 -7
  25. data/distro/common/html/knife_delete.html +2 -3
  26. data/distro/common/html/knife_deps.html +2 -3
  27. data/distro/common/html/knife_diff.html +3 -4
  28. data/distro/common/html/knife_download.html +6 -7
  29. data/distro/common/html/knife_edit.html +0 -1
  30. data/distro/common/html/knife_environment.html +3 -4
  31. data/distro/common/html/knife_exec.html +0 -1
  32. data/distro/common/html/knife_index_rebuild.html +0 -1
  33. data/distro/common/html/knife_list.html +5 -6
  34. data/distro/common/html/knife_node.html +13 -6
  35. data/distro/common/html/knife_raw.html +0 -1
  36. data/distro/common/html/knife_recipe_list.html +0 -1
  37. data/distro/common/html/knife_role.html +1 -2
  38. data/distro/common/html/knife_search.html +2 -3
  39. data/distro/common/html/knife_serve.html +79 -0
  40. data/distro/common/html/knife_show.html +1 -2
  41. data/distro/common/html/knife_ssh.html +2 -3
  42. data/distro/common/html/knife_ssl_check.html +12 -9
  43. data/distro/common/html/knife_ssl_fetch.html +9 -10
  44. data/distro/common/html/knife_status.html +2 -3
  45. data/distro/common/html/knife_tag.html +0 -1
  46. data/distro/common/html/knife_upload.html +3 -4
  47. data/distro/common/html/knife_user.html +2 -3
  48. data/distro/common/html/knife_using.html +0 -1
  49. data/distro/common/html/knife_xargs.html +3 -4
  50. data/distro/common/html/search.html +0 -1
  51. data/distro/common/html/searchindex.js +1 -1
  52. data/lib/chef/api_client.rb +1 -1
  53. data/lib/chef/application.rb +24 -67
  54. data/lib/chef/application/client.rb +1 -1
  55. data/lib/chef/application/knife.rb +1 -1
  56. data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
  57. data/lib/chef/chef_fs/command_line.rb +2 -3
  58. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
  59. data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
  60. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
  61. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
  62. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
  63. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
  64. data/lib/chef/config.rb +26 -2
  65. data/lib/chef/config_fetcher.rb +1 -1
  66. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  67. data/lib/chef/cookbook/metadata.rb +1 -1
  68. data/lib/chef/cookbook/synchronizer.rb +50 -8
  69. data/lib/chef/cookbook_uploader.rb +9 -23
  70. data/lib/chef/cookbook_version.rb +3 -2
  71. data/lib/chef/data_bag.rb +1 -1
  72. data/lib/chef/data_bag_item.rb +1 -1
  73. data/lib/chef/dsl/recipe.rb +1 -14
  74. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  75. data/lib/chef/environment.rb +1 -1
  76. data/lib/chef/exceptions.rb +2 -24
  77. data/lib/chef/file_content_management/tempfile.rb +8 -1
  78. data/lib/chef/formatters/base.rb +0 -7
  79. data/lib/chef/http.rb +12 -19
  80. data/lib/chef/http/json_input.rb +12 -1
  81. data/lib/chef/json_compat.rb +45 -64
  82. data/lib/chef/knife.rb +2 -5
  83. data/lib/chef/knife/bootstrap.rb +2 -2
  84. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  85. data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
  86. data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
  87. data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
  88. data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
  89. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  90. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
  91. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
  92. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  93. data/lib/chef/knife/cookbook_site_install.rb +10 -34
  94. data/lib/chef/knife/cookbook_site_list.rb +1 -1
  95. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  96. data/lib/chef/knife/cookbook_site_share.rb +3 -3
  97. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  98. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  99. data/lib/chef/knife/cookbook_upload.rb +1 -1
  100. data/lib/chef/knife/core/subcommand_loader.rb +0 -24
  101. data/lib/chef/knife/core/ui.rb +8 -7
  102. data/lib/chef/knife/deps.rb +2 -3
  103. data/lib/chef/knife/serve.rb +2 -1
  104. data/lib/chef/local_mode.rb +105 -0
  105. data/lib/chef/mixin/file_class.rb +1 -4
  106. data/lib/chef/mixin/shell_out.rb +15 -0
  107. data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
  108. data/lib/chef/node.rb +1 -1
  109. data/lib/chef/platform/query_helpers.rb +1 -5
  110. data/lib/chef/policy_builder/expand_node_object.rb +3 -0
  111. data/lib/chef/provider.rb +2 -0
  112. data/lib/chef/provider/cookbook_file.rb +0 -1
  113. data/lib/chef/provider/deploy.rb +0 -1
  114. data/lib/chef/provider/deploy/revision.rb +1 -1
  115. data/lib/chef/provider/env.rb +10 -25
  116. data/lib/chef/provider/env/windows.rb +23 -10
  117. data/lib/chef/provider/execute.rb +0 -3
  118. data/lib/chef/provider/file.rb +0 -3
  119. data/lib/chef/provider/git.rb +0 -6
  120. data/lib/chef/provider/group/dscl.rb +9 -27
  121. data/lib/chef/provider/group/gpasswd.rb +0 -3
  122. data/lib/chef/provider/group/groupmod.rb +0 -4
  123. data/lib/chef/provider/group/suse.rb +0 -3
  124. data/lib/chef/provider/group/usermod.rb +0 -3
  125. data/lib/chef/provider/link.rb +22 -5
  126. data/lib/chef/provider/log.rb +15 -4
  127. data/lib/chef/provider/mdadm.rb +0 -3
  128. data/lib/chef/provider/mount/mount.rb +0 -2
  129. data/lib/chef/provider/mount/solaris.rb +0 -2
  130. data/lib/chef/provider/package.rb +0 -1
  131. data/lib/chef/provider/package/apt.rb +0 -3
  132. data/lib/chef/provider/package/dpkg.rb +0 -1
  133. data/lib/chef/provider/package/easy_install.rb +0 -4
  134. data/lib/chef/provider/package/freebsd/base.rb +0 -3
  135. data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
  136. data/lib/chef/provider/package/freebsd/port.rb +0 -2
  137. data/lib/chef/provider/package/ips.rb +0 -3
  138. data/lib/chef/provider/package/paludis.rb +0 -5
  139. data/lib/chef/provider/package/portage.rb +0 -2
  140. data/lib/chef/provider/package/rpm.rb +2 -4
  141. data/lib/chef/provider/package/rubygems.rb +0 -4
  142. data/lib/chef/provider/package/smartos.rb +0 -3
  143. data/lib/chef/provider/package/windows/msi.rb +0 -2
  144. data/lib/chef/provider/package/yum.rb +0 -4
  145. data/lib/chef/provider/package/zypper.rb +0 -3
  146. data/lib/chef/provider/registry_key.rb +0 -2
  147. data/lib/chef/provider/remote_directory.rb +0 -1
  148. data/lib/chef/provider/remote_file.rb +0 -1
  149. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
  150. data/lib/chef/provider/remote_file/content.rb +0 -1
  151. data/lib/chef/provider/remote_file/fetcher.rb +0 -2
  152. data/lib/chef/provider/remote_file/ftp.rb +0 -1
  153. data/lib/chef/provider/resource_update.rb +0 -3
  154. data/lib/chef/provider/service/freebsd.rb +0 -3
  155. data/lib/chef/provider/service/init.rb +0 -3
  156. data/lib/chef/provider/service/macosx.rb +0 -1
  157. data/lib/chef/provider/service/redhat.rb +0 -2
  158. data/lib/chef/provider/service/simple.rb +0 -3
  159. data/lib/chef/provider/service/solaris.rb +0 -3
  160. data/lib/chef/provider/service/systemd.rb +15 -14
  161. data/lib/chef/provider/service/windows.rb +0 -3
  162. data/lib/chef/provider/subversion.rb +0 -2
  163. data/lib/chef/provider/template.rb +0 -2
  164. data/lib/chef/provider/template/content.rb +0 -1
  165. data/lib/chef/provider/user/dscl.rb +156 -549
  166. data/lib/chef/provider/user/solaris.rb +0 -1
  167. data/lib/chef/provider/user/useradd.rb +0 -3
  168. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  169. data/lib/chef/providers.rb +0 -1
  170. data/lib/chef/resource.rb +1 -4
  171. data/lib/chef/resource/freebsd_package.rb +2 -10
  172. data/lib/chef/resource/lwrp_base.rb +1 -12
  173. data/lib/chef/resource/user.rb +0 -18
  174. data/lib/chef/resource_collection.rb +1 -1
  175. data/lib/chef/resource_reporter.rb +10 -10
  176. data/lib/chef/resources.rb +0 -1
  177. data/lib/chef/role.rb +3 -3
  178. data/lib/chef/run_list.rb +1 -1
  179. data/lib/chef/tasks/chef_repo.rake +131 -264
  180. data/lib/chef/user.rb +1 -1
  181. data/lib/chef/util/path_helper.rb +2 -2
  182. data/lib/chef/version.rb +9 -1
  183. data/lib/chef/win32/api/system.rb +0 -9
  184. data/spec/data/bootstrap/test-hints.erb +1 -1
  185. data/spec/data/bootstrap/test.erb +1 -1
  186. data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
  187. data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
  188. data/spec/functional/knife/exec_spec.rb +1 -1
  189. data/spec/functional/mixin/shell_out_spec.rb +48 -0
  190. data/spec/functional/resource/base.rb +0 -10
  191. data/spec/functional/resource/group_spec.rb +1 -5
  192. data/spec/functional/resource/link_spec.rb +8 -0
  193. data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
  194. data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
  195. data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
  196. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
  197. data/spec/integration/knife/chefignore_spec.rb +1 -1
  198. data/spec/integration/knife/common_options_spec.rb +50 -3
  199. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
  200. data/spec/integration/knife/delete_spec.rb +1 -1
  201. data/spec/integration/knife/deps_spec.rb +1 -1
  202. data/spec/integration/knife/diff_spec.rb +3 -3
  203. data/spec/integration/knife/download_spec.rb +3 -3
  204. data/spec/integration/knife/list_spec.rb +1 -1
  205. data/spec/integration/knife/raw_spec.rb +1 -11
  206. data/spec/integration/knife/redirection_spec.rb +1 -1
  207. data/spec/integration/knife/serve_spec.rb +2 -2
  208. data/spec/integration/knife/show_spec.rb +1 -1
  209. data/spec/integration/knife/upload_spec.rb +9 -9
  210. data/spec/spec_helper.rb +0 -9
  211. data/spec/support/pedant/pedant_config.rb +2 -1
  212. data/spec/support/pedant/run_pedant.rb +2 -1
  213. data/spec/support/platform_helpers.rb +5 -24
  214. data/spec/support/shared/integration/integration_helper.rb +2 -1
  215. data/spec/support/shared/matchers.rb +17 -0
  216. data/spec/tiny_server.rb +1 -2
  217. data/spec/unit/api_client_spec.rb +3 -3
  218. data/spec/unit/application_spec.rb +9 -32
  219. data/spec/unit/config_fetcher_spec.rb +1 -1
  220. data/spec/unit/cookbook/metadata_spec.rb +3 -7
  221. data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
  222. data/spec/unit/cookbook_loader_spec.rb +1 -1
  223. data/spec/unit/cookbook_uploader_spec.rb +160 -0
  224. data/spec/unit/cookbook_version_spec.rb +0 -4
  225. data/spec/unit/data_bag_item_spec.rb +1 -5
  226. data/spec/unit/data_bag_spec.rb +1 -5
  227. data/spec/unit/deprecation_spec.rb +1 -1
  228. data/spec/unit/dsl/recipe_spec.rb +12 -0
  229. data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
  230. data/spec/unit/environment_spec.rb +3 -7
  231. data/spec/unit/exceptions_spec.rb +0 -6
  232. data/spec/unit/http/json_input_spec.rb +128 -0
  233. data/spec/unit/json_compat_spec.rb +17 -58
  234. data/spec/unit/knife/client_create_spec.rb +3 -3
  235. data/spec/unit/knife/configure_client_spec.rb +6 -5
  236. data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
  237. data/spec/unit/knife/cookbook_download_spec.rb +5 -5
  238. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
  239. data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
  240. data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
  241. data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
  242. data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
  243. data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
  244. data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
  245. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
  246. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
  247. data/spec/unit/knife/tag_create_spec.rb +3 -3
  248. data/spec/unit/knife/tag_delete_spec.rb +3 -3
  249. data/spec/unit/knife/user_create_spec.rb +1 -1
  250. data/spec/unit/knife_spec.rb +14 -14
  251. data/spec/unit/lwrp_spec.rb +1 -21
  252. data/spec/unit/mixin/shell_out_spec.rb +92 -0
  253. data/spec/unit/node_spec.rb +0 -4
  254. data/spec/unit/platform/query_helpers_spec.rb +0 -23
  255. data/spec/unit/provider/env/windows_spec.rb +34 -70
  256. data/spec/unit/provider/env_spec.rb +11 -76
  257. data/spec/unit/provider/group/dscl_spec.rb +1 -38
  258. data/spec/unit/provider/log_spec.rb +18 -0
  259. data/spec/unit/provider/package/rpm_spec.rb +0 -12
  260. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
  261. data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
  262. data/spec/unit/provider/user/dscl_spec.rb +264 -660
  263. data/spec/unit/provider/user/useradd_spec.rb +0 -1
  264. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  265. data/spec/unit/provider_spec.rb +12 -0
  266. data/spec/unit/recipe_spec.rb +0 -41
  267. data/spec/unit/resource_collection_spec.rb +1 -5
  268. data/spec/unit/resource_reporter_spec.rb +3 -51
  269. data/spec/unit/resource_spec.rb +3 -14
  270. data/spec/unit/rest_spec.rb +1 -4
  271. data/spec/unit/role_spec.rb +0 -10
  272. data/spec/unit/run_list_spec.rb +1 -5
  273. data/spec/unit/user_spec.rb +1 -5
  274. metadata +20 -100
  275. data/lib/chef/mixin/windows_env_helper.rb +0 -56
  276. data/lib/chef/provider/dsc_script.rb +0 -175
  277. data/lib/chef/resource/dsc_script.rb +0 -126
  278. data/lib/chef/streaming_cookbook_uploader.rb +0 -205
  279. data/lib/chef/util/dsc/configuration_generator.rb +0 -115
  280. data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
  281. data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
  282. data/lib/chef/util/dsc/resource_info.rb +0 -26
  283. data/lib/chef/util/powershell/cmdlet.rb +0 -136
  284. data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
  285. data/spec/data/mac_users/10.7-8.plist.xml +0 -559
  286. data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
  287. data/spec/data/mac_users/10.7.plist.xml +0 -559
  288. data/spec/data/mac_users/10.7.shadow.xml +0 -11
  289. data/spec/data/mac_users/10.8.plist.xml +0 -559
  290. data/spec/data/mac_users/10.8.shadow.xml +0 -21
  291. data/spec/data/mac_users/10.9.plist.xml +0 -560
  292. data/spec/data/mac_users/10.9.shadow.xml +0 -21
  293. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +0 -51
  294. data/spec/functional/resource/dsc_script_spec.rb +0 -382
  295. data/spec/functional/resource/env_spec.rb +0 -182
  296. data/spec/functional/resource/user/dscl_spec.rb +0 -199
  297. data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
  298. data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
  299. data/spec/support/shared/shared_examples.rb +0 -10
  300. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
  301. data/spec/unit/formatters/base_spec.rb +0 -48
  302. data/spec/unit/provider/dsc_script_spec.rb +0 -174
  303. data/spec/unit/resource/dsc_script_spec.rb +0 -98
  304. data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
  305. data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
  306. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
  307. data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -18,16 +18,13 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- if Chef::Platform.windows?
22
- require 'chef/win32/file'
23
- end
24
-
25
21
  class Chef
26
22
  module Mixin
27
23
  module FileClass
28
24
 
29
25
  def file_class
30
26
  @host_os_file ||= if Chef::Platform.windows?
27
+ require 'chef/win32/file'
31
28
  Chef::ReservedNames::Win32::File
32
29
  else
33
30
  ::File
@@ -44,6 +44,21 @@ class Chef
44
44
  cmd
45
45
  end
46
46
 
47
+ # environment['LC_ALL'] should be nil or what the user specified
48
+ def shell_out_with_systems_locale(*command_args)
49
+ args = command_args.dup
50
+ if args.last.is_a?(Hash)
51
+ options = args.last
52
+ env_key = options.has_key?(:env) ? :env : :environment
53
+ options[env_key] ||= {}
54
+ options[env_key]['LC_ALL'] ||= nil
55
+ else
56
+ args << { :environment => { 'LC_ALL' => nil } }
57
+ end
58
+
59
+ shell_out(*args)
60
+ end
61
+
47
62
  DEPRECATED_OPTIONS =
48
63
  [ [:command_log_level, :log_level],
49
64
  [:command_log_prepend, :log_tag] ]
@@ -41,22 +41,6 @@ class Chef
41
41
  is_i386_process_on_x86_64_windows?
42
42
  end
43
43
 
44
- def with_os_architecture(node)
45
- wow64_redirection_state = nil
46
-
47
- if wow64_architecture_override_required?(node, node_windows_architecture(node))
48
- wow64_redirection_state = disable_wow64_file_redirection(node)
49
- end
50
-
51
- begin
52
- yield
53
- ensure
54
- if wow64_redirection_state
55
- restore_wow64_file_redirection(node, wow64_redirection_state)
56
- end
57
- end
58
- end
59
-
60
44
  def node_supports_windows_architecture?(node, desired_architecture)
61
45
  assert_valid_windows_architecture!(desired_architecture)
62
46
  return (node_windows_architecture(node) == :x86_64 ||
@@ -416,7 +416,7 @@ class Chef
416
416
 
417
417
  # Serialize this object as a hash
418
418
  def to_json(*a)
419
- Chef::JSONCompat.to_json(for_json, *a)
419
+ for_json.to_json(*a)
420
420
  end
421
421
 
422
422
  def for_json
@@ -45,11 +45,7 @@ class Chef
45
45
 
46
46
  is_server_2003
47
47
  end
48
-
49
- def supports_dsc?(node)
50
- node[:languages] && node[:languages][:powershell] &&
51
- node[:languages][:powershell][:version].to_i >= 4
52
- end
53
48
  end
49
+
54
50
  end
55
51
  end
@@ -176,6 +176,9 @@ class Chef
176
176
  end
177
177
 
178
178
  synchronizer = Chef::CookbookSynchronizer.new(cookbook_hash, events)
179
+ if temporary_policy?
180
+ synchronizer.remove_obsoleted_files = false
181
+ end
179
182
  synchronizer.sync_cookbooks
180
183
 
181
184
  # register the file cache path in the cookbook path so that CookbookLoader actually picks up the synced cookbooks
@@ -22,11 +22,13 @@ require 'chef/mixin/convert_to_class_name'
22
22
  require 'chef/dsl/recipe'
23
23
  require 'chef/mixin/enforce_ownership_and_permissions'
24
24
  require 'chef/mixin/why_run'
25
+ require 'chef/mixin/shell_out'
25
26
 
26
27
  class Chef
27
28
  class Provider
28
29
  include Chef::DSL::Recipe
29
30
  include Chef::Mixin::WhyRun
31
+ include Chef::Mixin::ShellOut
30
32
 
31
33
  attr_accessor :new_resource
32
34
  attr_accessor :current_resource
@@ -49,4 +49,3 @@ class Chef
49
49
  end
50
50
  end
51
51
  end
52
-
@@ -174,7 +174,6 @@ class Chef
174
174
  restart
175
175
  end
176
176
 
177
-
178
177
  def callback(what, callback_code=nil)
179
178
  @collection = Chef::ResourceCollection.new
180
179
  case callback_code
@@ -97,7 +97,7 @@ class Chef
97
97
  end
98
98
 
99
99
  def save_cache(cache)
100
- Chef::FileCache.store("revision-deploys/#{new_resource.name}", Chef::JSONCompat.to_json(cache))
100
+ Chef::FileCache.store("revision-deploys/#{new_resource.name}", cache.to_json)
101
101
  cache
102
102
  end
103
103
 
@@ -58,22 +58,20 @@ class Chef
58
58
  # ==== Returns
59
59
  # <true>:: If a change is required
60
60
  # <false>:: If a change is not required
61
- def requires_modify_or_create?
61
+ def compare_value
62
62
  if @new_resource.delim
63
63
  #e.g. check for existing value within PATH
64
- not new_values.all? do |val|
65
- current_values.include? val
64
+ not @current_resource.value.split(@new_resource.delim).any? do |val|
65
+ val == @new_resource.value
66
66
  end
67
67
  else
68
68
  @new_resource.value != @current_resource.value
69
69
  end
70
70
  end
71
71
 
72
- alias_method :compare_value, :requires_modify_or_create?
73
-
74
72
  def action_create
75
73
  if @key_exists
76
- if requires_modify_or_create?
74
+ if compare_value
77
75
  modify_env
78
76
  Chef::Log.info("#{@new_resource} altered")
79
77
  @new_resource.updated_by_last_action(true)
@@ -93,14 +91,13 @@ class Chef
93
91
  # after we removed the element.
94
92
  def delete_element
95
93
  return false unless @new_resource.delim #no delim: delete the key
96
- needs_delete = new_values.any? { |v| current_values.include?(v) }
97
- if !needs_delete
94
+ if compare_value
98
95
  Chef::Log.debug("#{@new_resource} element '#{@new_resource.value}' does not exist")
99
96
  return true #do not delete the key
100
97
  else
101
98
  new_value =
102
- current_values.select { |item|
103
- not new_values.include?(item)
99
+ @current_resource.value.split(@new_resource.delim).select { |item|
100
+ item != @new_resource.value
104
101
  }.join(@new_resource.delim)
105
102
 
106
103
  if new_value.empty?
@@ -125,7 +122,7 @@ class Chef
125
122
 
126
123
  def action_modify
127
124
  if @key_exists
128
- if requires_modify_or_create?
125
+ if compare_value
129
126
  modify_env
130
127
  Chef::Log.info("#{@new_resource} modified")
131
128
  @new_resource.updated_by_last_action(true)
@@ -145,23 +142,11 @@ class Chef
145
142
 
146
143
  def modify_env
147
144
  if @new_resource.delim
148
- values = new_values.reject do |v|
149
- current_values.include?(v)
150
- end
151
- @new_resource.value((values + [@current_resource.value]).join(@new_resource.delim))
145
+ #e.g. add to PATH
146
+ @new_resource.value << @new_resource.delim << @current_resource.value
152
147
  end
153
148
  create_env
154
149
  end
155
-
156
- # Returns the current values to split by delimiter
157
- def current_values
158
- @current_values ||= @current_resource.value.split(@new_resource.delim)
159
- end
160
-
161
- # Returns the new values to split by delimiter
162
- def new_values
163
- @new_values ||= @new_resource.value.split(@new_resource.delim)
164
- end
165
150
  end
166
151
  end
167
152
  end
@@ -16,13 +16,13 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/mixin/windows_env_helper'
19
+ require 'chef/win32/api/system' if RUBY_PLATFORM =~ /mswin|mingw32|windows/
20
20
 
21
21
  class Chef
22
22
  class Provider
23
23
  class Env
24
24
  class Windows < Chef::Provider::Env
25
- include Chef::Mixin::WindowsEnvHelper
25
+ include Chef::ReservedNames::Win32::API::System if RUBY_PLATFORM =~ /mswin|mingw32|windows/
26
26
 
27
27
  def create_env
28
28
  obj = env_obj(@new_resource.key_name)
@@ -33,9 +33,7 @@ class Chef
33
33
  end
34
34
  obj.variablevalue = @new_resource.value
35
35
  obj.put_
36
- value = @new_resource.value
37
- value = expand_path(value) if @new_resource.key_name.upcase == 'PATH'
38
- ENV[@new_resource.key_name] = value
36
+ ENV[@new_resource.key_name] = @new_resource.value
39
37
  broadcast_env_change
40
38
  end
41
39
 
@@ -53,15 +51,30 @@ class Chef
53
51
  return obj ? obj.variablevalue : nil
54
52
  end
55
53
 
54
+ def find_env(environment_variables, key_name)
55
+ environment_variables.find do | environment_variable |
56
+ environment_variable['name'].downcase == key_name
57
+ end
58
+ end
59
+
56
60
  def env_obj(key_name)
57
61
  wmi = WmiLite::Wmi.new
58
- # Note that by design this query is case insensitive with regard to key_name
59
- environment_variables = wmi.query("select * from Win32_Environment where name = '#{key_name}'")
60
- if environment_variables && environment_variables.length > 0
61
- environment_variables[0].wmi_ole_object
62
- end
62
+ environment_variables = wmi.instances_of('Win32_Environment')
63
+ existing_variable = find_env(environment_variables, key_name)
64
+ existing_variable.nil? ? nil : existing_variable.wmi_ole_object
63
65
  end
64
66
 
67
+ #see: http://msdn.microsoft.com/en-us/library/ms682653%28VS.85%29.aspx
68
+ HWND_BROADCAST = 0xffff
69
+ WM_SETTINGCHANGE = 0x001A
70
+ SMTO_BLOCK = 0x0001
71
+ SMTO_ABORTIFHUNG = 0x0002
72
+ SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
73
+
74
+ def broadcast_env_change
75
+ flags = SMTO_BLOCK | SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG
76
+ SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string('Environment').address, flags, 5000, nil)
77
+ end
65
78
  end
66
79
  end
67
80
  end
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/mixin/shell_out'
20
19
  require 'chef/log'
21
20
  require 'chef/provider'
22
21
 
@@ -24,8 +23,6 @@ class Chef
24
23
  class Provider
25
24
  class Execute < Chef::Provider
26
25
 
27
- include Chef::Mixin::ShellOut
28
-
29
26
  def load_current_resource
30
27
  true
31
28
  end
@@ -25,7 +25,6 @@ require 'etc'
25
25
  require 'fileutils'
26
26
  require 'chef/scan_access_control'
27
27
  require 'chef/mixin/checksum'
28
- require 'chef/mixin/shell_out'
29
28
  require 'chef/mixin/file_class'
30
29
  require 'chef/util/backup'
31
30
  require 'chef/util/diff'
@@ -48,7 +47,6 @@ class Chef
48
47
  class File < Chef::Provider
49
48
  include Chef::Mixin::EnforceOwnershipAndPermissions
50
49
  include Chef::Mixin::Checksum
51
- include Chef::Mixin::ShellOut
52
50
  include Chef::Util::Selinux
53
51
  include Chef::Mixin::FileClass
54
52
 
@@ -247,7 +245,6 @@ class Chef
247
245
  "Assuming symlink source would be created by a previous resource" ]
248
246
  end
249
247
 
250
-
251
248
  def content
252
249
  @content ||= begin
253
250
  load_current_resource if @current_resource.nil?
@@ -16,19 +16,15 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
-
20
19
  require 'chef/exceptions'
21
20
  require 'chef/log'
22
21
  require 'chef/provider'
23
- require 'chef/mixin/shell_out'
24
22
  require 'fileutils'
25
23
 
26
24
  class Chef
27
25
  class Provider
28
26
  class Git < Chef::Provider
29
27
 
30
- include Chef::Mixin::ShellOut
31
-
32
28
  def whyrun_supported?
33
29
  true
34
30
  end
@@ -51,7 +47,6 @@ class Chef
51
47
  "Cannot clone #{@new_resource} to #{@new_resource.destination}, the enclosing directory #{dirname} does not exist")
52
48
  end
53
49
 
54
-
55
50
  requirements.assert(:all_actions) do |a|
56
51
  a.assertion { !(@new_resource.revision =~ /^origin\//) }
57
52
  a.failure_message Chef::Exceptions::InvalidRemoteGitReference,
@@ -107,7 +102,6 @@ class Chef
107
102
  end
108
103
  end
109
104
 
110
-
111
105
  def existing_git_clone?
112
106
  ::File.exist?(::File.join(@new_resource.destination, ".git"))
113
107
  end
@@ -39,33 +39,11 @@ class Chef
39
39
  return result[2]
40
40
  end
41
41
 
42
- def load_current_resource
43
- @current_resource = Chef::Resource::Group.new(@new_resource.name)
44
- @current_resource.group_name(@new_resource.name)
45
- group_info = nil
46
- begin
47
- group_info = safe_dscl("read /Groups/#{@new_resource.name}")
48
- rescue Chef::Exceptions::Group
49
- @group_exists = false
50
- Chef::Log.debug("#{@new_resource} group does not exist")
51
- end
52
-
53
- if group_info
54
- group_info.each_line do |line|
55
- key, val = line.split(': ')
56
- val.strip! if val
57
- case key.downcase
58
- when 'primarygroupid'
59
- @new_resource.gid(val) unless @new_resource.gid
60
- @current_resource.gid(val)
61
- when 'groupmembership'
62
- @current_resource.members(val.split(' '))
63
- end
64
- end
65
- end
66
-
67
- @current_resource
68
- end
42
+ # This is handled in providers/group.rb by Etc.getgrnam()
43
+ # def group_exists?(group)
44
+ # groups = safe_dscl("list /Groups")
45
+ # !! ( groups =~ Regexp.new("\n#{group}\n") )
46
+ # end
69
47
 
70
48
  # get a free GID greater than 200
71
49
  def get_free_gid(search_limit=1000)
@@ -137,6 +115,10 @@ class Chef
137
115
  end
138
116
  end
139
117
 
118
+ def load_current_resource
119
+ super
120
+ end
121
+
140
122
  def create_group
141
123
  dscl_create_group
142
124
  set_gid
@@ -17,15 +17,12 @@
17
17
  #
18
18
 
19
19
  require 'chef/provider/group/groupadd'
20
- require 'chef/mixin/shell_out'
21
20
 
22
21
  class Chef
23
22
  class Provider
24
23
  class Group
25
24
  class Gpasswd < Chef::Provider::Group::Groupadd
26
25
 
27
- include Chef::Mixin::ShellOut
28
-
29
26
  def load_current_resource
30
27
  super
31
28
  end
@@ -16,15 +16,11 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/mixin/shell_out'
20
-
21
19
  class Chef
22
20
  class Provider
23
21
  class Group
24
22
  class Groupmod < Chef::Provider::Group
25
23
 
26
- include Chef::Mixin::ShellOut
27
-
28
24
  def load_current_resource
29
25
  super
30
26
  [ "group", "user" ].each do |binary|
@@ -17,15 +17,12 @@
17
17
  #
18
18
 
19
19
  require 'chef/provider/group/groupadd'
20
- require 'chef/mixin/shell_out'
21
20
 
22
21
  class Chef
23
22
  class Provider
24
23
  class Group
25
24
  class Suse < Chef::Provider::Group::Groupadd
26
25
 
27
- include Chef::Mixin::ShellOut
28
-
29
26
  def load_current_resource
30
27
  super
31
28
  end