chef 12.4.3-universal-mingw32 → 12.5.1-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +21 -25
  3. data/Gemfile +46 -0
  4. data/README.md +4 -4
  5. data/Rakefile +4 -110
  6. data/bin/chef-service-manager +3 -1
  7. data/distro/common/html/knife_cookbook_site.html +18 -18
  8. data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
  9. data/lib/chef.rb +1 -1
  10. data/lib/chef/application.rb +1 -1
  11. data/lib/chef/application/apply.rb +19 -1
  12. data/lib/chef/application/client.rb +11 -5
  13. data/lib/chef/application/knife.rb +2 -2
  14. data/lib/chef/application/solo.rb +1 -1
  15. data/lib/chef/application/windows_service_manager.rb +19 -12
  16. data/lib/chef/chef_class.rb +46 -0
  17. data/lib/chef/chef_fs/config.rb +22 -24
  18. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
  19. data/lib/chef/chef_fs/file_pattern.rb +4 -15
  20. data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
  21. data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
  22. data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
  23. data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
  24. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
  25. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
  26. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
  27. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
  28. data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
  29. data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
  30. data/lib/chef/chef_fs/file_system/cookbook_dir.rb +4 -4
  31. data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
  32. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
  33. data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
  34. data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
  35. data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
  36. data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
  37. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
  38. data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
  39. data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
  40. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
  41. data/lib/chef/chef_fs/knife.rb +35 -7
  42. data/lib/chef/chef_fs/path_utils.rb +65 -34
  43. data/lib/chef/client.rb +2 -3
  44. data/lib/chef/config.rb +34 -2
  45. data/lib/chef/{mixin/wstring.rb → constants.rb} +9 -13
  46. data/lib/chef/cookbook/metadata.rb +25 -3
  47. data/lib/chef/cookbook/synchronizer.rb +1 -1
  48. data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
  49. data/lib/chef/cookbook_version.rb +3 -3
  50. data/lib/chef/delayed_evaluator.rb +21 -0
  51. data/lib/chef/deprecation/mixin/template.rb +1 -2
  52. data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
  53. data/lib/chef/deprecation/provider/file.rb +1 -1
  54. data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
  55. data/lib/chef/deprecation/provider/remote_file.rb +1 -2
  56. data/lib/chef/deprecation/provider/template.rb +1 -1
  57. data/lib/chef/deprecation/warnings.rb +3 -4
  58. data/lib/chef/dsl/reboot_pending.rb +3 -2
  59. data/lib/chef/dsl/recipe.rb +26 -7
  60. data/lib/chef/dsl/resources.rb +2 -2
  61. data/lib/chef/event_dispatch/base.rb +51 -22
  62. data/lib/chef/event_dispatch/dispatcher.rb +21 -6
  63. data/lib/chef/event_dispatch/dsl.rb +64 -0
  64. data/lib/chef/exceptions.rb +28 -1
  65. data/lib/chef/file_content_management/tempfile.rb +1 -1
  66. data/lib/chef/formatters/base.rb +3 -0
  67. data/lib/chef/formatters/doc.rb +56 -6
  68. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
  69. data/lib/chef/formatters/minimal.rb +2 -2
  70. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -1
  71. data/lib/chef/http/http_request.rb +1 -1
  72. data/lib/chef/knife.rb +35 -55
  73. data/lib/chef/knife/bootstrap.rb +41 -0
  74. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
  75. data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
  76. data/lib/chef/knife/bootstrap/templates/README.md +3 -4
  77. data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
  78. data/lib/chef/knife/cookbook_create.rb +1 -1
  79. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  80. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  81. data/lib/chef/knife/cookbook_site_share.rb +6 -6
  82. data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
  83. data/lib/chef/knife/core/bootstrap_context.rb +12 -4
  84. data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
  85. data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
  86. data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
  87. data/lib/chef/knife/core/node_presenter.rb +24 -1
  88. data/lib/chef/knife/core/object_loader.rb +1 -0
  89. data/lib/chef/knife/core/subcommand_loader.rb +131 -146
  90. data/lib/chef/knife/node_run_list_remove.rb +12 -1
  91. data/lib/chef/knife/null.rb +10 -0
  92. data/lib/chef/knife/rehash.rb +62 -0
  93. data/lib/chef/knife/search.rb +3 -3
  94. data/lib/chef/knife/ssh.rb +52 -30
  95. data/lib/chef/knife/ssl_check.rb +3 -2
  96. data/lib/chef/knife/user_edit.rb +1 -2
  97. data/lib/chef/local_mode.rb +5 -0
  98. data/lib/chef/log.rb +5 -1
  99. data/lib/chef/mixin/deprecation.rb +8 -8
  100. data/lib/chef/mixin/params_validate.rb +362 -135
  101. data/lib/chef/mixin/template.rb +48 -0
  102. data/lib/chef/mixin/which.rb +1 -1
  103. data/lib/chef/mixin/wide_string.rb +72 -0
  104. data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
  105. data/lib/chef/mixin/windows_env_helper.rb +4 -1
  106. data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
  107. data/lib/chef/monkey_patches/win32/registry.rb +72 -0
  108. data/lib/chef/node.rb +116 -3
  109. data/lib/chef/node_map.rb +2 -2
  110. data/lib/chef/platform/handler_map.rb +0 -5
  111. data/lib/chef/platform/provider_mapping.rb +5 -6
  112. data/lib/chef/platform/query_helpers.rb +46 -4
  113. data/lib/chef/platform/rebooter.rb +1 -1
  114. data/lib/chef/platform/service_helpers.rb +30 -32
  115. data/lib/chef/policy_builder.rb +1 -8
  116. data/lib/chef/policy_builder/dynamic.rb +186 -0
  117. data/lib/chef/policy_builder/expand_node_object.rb +30 -15
  118. data/lib/chef/policy_builder/policyfile.rb +155 -18
  119. data/lib/chef/property.rb +568 -0
  120. data/lib/chef/provider.rb +222 -13
  121. data/lib/chef/provider/batch.rb +8 -0
  122. data/lib/chef/provider/deploy.rb +5 -7
  123. data/lib/chef/provider/directory.rb +14 -2
  124. data/lib/chef/provider/dsc_resource.rb +5 -9
  125. data/lib/chef/provider/group/pw.rb +1 -1
  126. data/lib/chef/provider/ifconfig.rb +2 -2
  127. data/lib/chef/provider/lwrp_base.rb +1 -75
  128. data/lib/chef/provider/mount.rb +7 -3
  129. data/lib/chef/provider/package.rb +1 -1
  130. data/lib/chef/provider/package/dpkg.rb +5 -11
  131. data/lib/chef/provider/package/rpm.rb +2 -2
  132. data/lib/chef/provider/package/rubygems.rb +1 -1
  133. data/lib/chef/provider/package/windows/msi.rb +2 -2
  134. data/lib/chef/provider/package/yum.rb +17 -5
  135. data/lib/chef/provider/powershell_script.rb +59 -23
  136. data/lib/chef/provider/registry_key.rb +5 -5
  137. data/lib/chef/provider/remote_directory.rb +190 -102
  138. data/lib/chef/provider/service.rb +12 -2
  139. data/lib/chef/provider/service/aix.rb +1 -1
  140. data/lib/chef/provider/service/debian.rb +3 -5
  141. data/lib/chef/provider/service/freebsd.rb +1 -1
  142. data/lib/chef/provider/service/gentoo.rb +3 -3
  143. data/lib/chef/provider/service/init.rb +3 -3
  144. data/lib/chef/provider/service/insserv.rb +2 -4
  145. data/lib/chef/provider/service/invokercd.rb +2 -4
  146. data/lib/chef/provider/service/macosx.rb +5 -1
  147. data/lib/chef/provider/service/openbsd.rb +2 -1
  148. data/lib/chef/provider/service/redhat.rb +52 -16
  149. data/lib/chef/provider/service/simple.rb +2 -2
  150. data/lib/chef/provider/service/systemd.rb +3 -5
  151. data/lib/chef/provider/service/upstart.rb +4 -6
  152. data/lib/chef/provider/subversion.rb +13 -7
  153. data/lib/chef/provider/template/content.rb +16 -6
  154. data/lib/chef/provider/user/solaris.rb +32 -4
  155. data/lib/chef/provider/windows_script.rb +3 -5
  156. data/lib/chef/provider_resolver.rb +2 -2
  157. data/lib/chef/recipe.rb +1 -8
  158. data/lib/chef/resource.rb +563 -90
  159. data/lib/chef/resource/action_class.rb +83 -0
  160. data/lib/chef/resource/chef_gem.rb +3 -3
  161. data/lib/chef/resource/deploy.rb +8 -2
  162. data/lib/chef/resource/dsc_script.rb +2 -0
  163. data/lib/chef/resource/file/verification.rb +7 -1
  164. data/lib/chef/resource/lwrp_base.rb +1 -7
  165. data/lib/chef/resource/registry_key.rb +1 -1
  166. data/lib/chef/resource/service.rb +10 -2
  167. data/lib/chef/resource/subversion.rb +5 -0
  168. data/lib/chef/resource/windows_script.rb +6 -2
  169. data/lib/chef/resource/yum_package.rb +10 -1
  170. data/lib/chef/resource_resolver.rb +3 -3
  171. data/lib/chef/run_context.rb +402 -83
  172. data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
  173. data/lib/chef/run_lock.rb +30 -21
  174. data/lib/chef/util/powershell/ps_credential.rb +4 -0
  175. data/lib/chef/util/windows.rb +0 -32
  176. data/lib/chef/util/windows/net_group.rb +85 -106
  177. data/lib/chef/util/windows/net_use.rb +35 -71
  178. data/lib/chef/util/windows/net_user.rb +0 -1
  179. data/lib/chef/util/windows/volume.rb +19 -19
  180. data/lib/chef/version.rb +3 -3
  181. data/lib/chef/win32/api.rb +1 -0
  182. data/lib/chef/win32/api/file.rb +20 -0
  183. data/lib/chef/win32/api/net.rb +163 -43
  184. data/lib/chef/win32/api/registry.rb +51 -0
  185. data/lib/chef/win32/api/system.rb +23 -0
  186. data/lib/chef/win32/api/unicode.rb +0 -43
  187. data/lib/chef/win32/crypto.rb +2 -1
  188. data/lib/chef/win32/file.rb +28 -3
  189. data/lib/chef/win32/mutex.rb +1 -2
  190. data/lib/chef/win32/net.rb +162 -8
  191. data/lib/chef/win32/process.rb +13 -0
  192. data/lib/chef/win32/registry.rb +35 -30
  193. data/lib/chef/win32/security.rb +1 -1
  194. data/lib/chef/win32/security/token.rb +1 -1
  195. data/lib/chef/win32/system.rb +62 -0
  196. data/lib/chef/win32/unicode.rb +7 -2
  197. data/lib/chef/win32/version.rb +0 -4
  198. data/lib/chef/workstation_config_loader.rb +3 -158
  199. data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
  200. data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
  201. data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
  202. data/spec/data/dsc_lcm.pfx +0 -0
  203. data/spec/data/run_context/cookbooks/include/recipes/default.rb +24 -0
  204. data/spec/data/run_context/cookbooks/include/recipes/includee.rb +3 -0
  205. data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
  206. data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
  207. data/spec/functional/knife/ssh_spec.rb +16 -0
  208. data/spec/functional/rebooter_spec.rb +1 -1
  209. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  210. data/spec/functional/resource/dsc_resource_spec.rb +2 -0
  211. data/spec/functional/resource/dsc_script_spec.rb +91 -2
  212. data/spec/functional/resource/group_spec.rb +67 -44
  213. data/spec/functional/resource/{powershell_spec.rb → powershell_script_spec.rb} +107 -18
  214. data/spec/functional/resource/windows_service_spec.rb +1 -1
  215. data/spec/functional/run_lock_spec.rb +368 -189
  216. data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +16 -23
  217. data/spec/functional/win32/service_manager_spec.rb +2 -2
  218. data/spec/integration/client/client_spec.rb +51 -0
  219. data/spec/integration/knife/chef_repo_path_spec.rb +13 -11
  220. data/spec/integration/knife/download_spec.rb +4 -0
  221. data/spec/integration/knife/list_spec.rb +8 -0
  222. data/spec/integration/knife/upload_spec.rb +1 -1
  223. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -16
  224. data/spec/integration/recipes/remote_directory.rb +74 -0
  225. data/spec/integration/recipes/resource_action_spec.rb +363 -0
  226. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
  227. data/spec/integration/recipes/resource_load_spec.rb +206 -0
  228. data/spec/spec_helper.rb +9 -0
  229. data/spec/support/platform_helpers.rb +13 -0
  230. data/spec/support/shared/context/win32.rb +34 -0
  231. data/spec/support/shared/functional/win32_service.rb +2 -1
  232. data/spec/support/shared/functional/windows_script.rb +63 -26
  233. data/spec/support/shared/unit/mock_shellout.rb +46 -0
  234. data/spec/support/shared/unit/provider/file.rb +10 -4
  235. data/spec/unit/application/client_spec.rb +16 -3
  236. data/spec/unit/application/knife_spec.rb +2 -2
  237. data/spec/unit/application/solo_spec.rb +4 -3
  238. data/spec/unit/chef_class_spec.rb +23 -4
  239. data/spec/unit/chef_fs/path_util_spec.rb +108 -0
  240. data/spec/unit/client_spec.rb +6 -1
  241. data/spec/unit/config_spec.rb +31 -0
  242. data/spec/unit/cookbook/metadata_spec.rb +23 -3
  243. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  244. data/spec/unit/deprecation_spec.rb +3 -6
  245. data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
  246. data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
  247. data/spec/unit/event_dispatch/dsl_spec.rb +83 -0
  248. data/spec/unit/formatters/doc_spec.rb +32 -0
  249. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
  250. data/spec/unit/json_compat_spec.rb +4 -3
  251. data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
  252. data/spec/unit/knife/bootstrap_spec.rb +55 -3
  253. data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
  254. data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
  255. data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
  256. data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
  257. data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
  258. data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
  259. data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
  260. data/spec/unit/knife/ssl_check_spec.rb +4 -0
  261. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
  262. data/spec/unit/mixin/params_validate_spec.rb +4 -2
  263. data/spec/unit/mixin/template_spec.rb +5 -1
  264. data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
  265. data/spec/unit/node_spec.rb +220 -0
  266. data/spec/unit/platform/query_helpers_spec.rb +146 -3
  267. data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
  268. data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
  269. data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
  270. data/spec/unit/property/state_spec.rb +506 -0
  271. data/spec/unit/property/validation_spec.rb +663 -0
  272. data/spec/unit/property_spec.rb +1094 -0
  273. data/spec/unit/provider/deploy_spec.rb +5 -5
  274. data/spec/unit/provider/directory_spec.rb +35 -0
  275. data/spec/unit/provider/dsc_resource_spec.rb +3 -10
  276. data/spec/unit/provider/ifconfig_spec.rb +22 -2
  277. data/spec/unit/provider/mount/aix_spec.rb +2 -1
  278. data/spec/unit/provider/mount/mount_spec.rb +6 -0
  279. data/spec/unit/provider/mount/windows_spec.rb +14 -0
  280. data/spec/unit/provider/mount_spec.rb +12 -1
  281. data/spec/unit/provider/package/dpkg_spec.rb +8 -1
  282. data/spec/unit/provider/package/rpm_spec.rb +18 -1
  283. data/spec/unit/provider/package/rubygems_spec.rb +18 -0
  284. data/spec/unit/provider/package/yum_spec.rb +97 -24
  285. data/spec/unit/provider/powershell_script_spec.rb +106 -0
  286. data/spec/unit/provider/registry_key_spec.rb +12 -0
  287. data/spec/unit/provider/remote_directory_spec.rb +1 -2
  288. data/spec/unit/provider/service/aix_service_spec.rb +3 -3
  289. data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
  290. data/spec/unit/provider/service/macosx_spec.rb +4 -4
  291. data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
  292. data/spec/unit/provider/service/redhat_spec.rb +88 -8
  293. data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
  294. data/spec/unit/provider/service/windows_spec.rb +211 -200
  295. data/spec/unit/provider/subversion_spec.rb +50 -31
  296. data/spec/unit/provider/template/content_spec.rb +93 -2
  297. data/spec/unit/provider/user/solaris_spec.rb +66 -9
  298. data/spec/unit/provider_resolver_spec.rb +707 -650
  299. data/spec/unit/provider_spec.rb +1 -3
  300. data/spec/unit/recipe_spec.rb +0 -4
  301. data/spec/unit/resource/deploy_spec.rb +7 -1
  302. data/spec/unit/resource/dsc_script_spec.rb +4 -0
  303. data/spec/unit/resource/file/verification_spec.rb +33 -5
  304. data/spec/unit/resource/{powershell_spec.rb → powershell_script_spec.rb} +17 -13
  305. data/spec/unit/resource/service_spec.rb +4 -4
  306. data/spec/unit/resource/subversion_spec.rb +4 -0
  307. data/spec/unit/resource/yum_package_spec.rb +10 -1
  308. data/spec/unit/resource_spec.rb +2 -2
  309. data/spec/unit/run_context/child_run_context_spec.rb +133 -0
  310. data/spec/unit/run_context_spec.rb +7 -0
  311. data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
  312. data/spec/unit/win32/registry_spec.rb +394 -0
  313. data/tasks/external_tests.rb +47 -23
  314. data/tasks/maintainers.rb +155 -14
  315. metadata +64 -53
  316. data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
  317. data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
  318. data/spec/unit/provider/powershell_spec.rb +0 -80
  319. data/spec/unit/registry_helper_spec.rb +0 -376
  320. data/spec/unit/workstation_config_loader_spec.rb +0 -283
@@ -23,7 +23,7 @@ class Chef
23
23
  # == Deprecation::Provider::RemoteFile
24
24
  # This module contains the deprecated functions of
25
25
  # Chef::Provider::RemoteFile. These functions are refactored to different
26
- # components. They are frozen and will be removed in Chef 12.
26
+ # components. They are frozen and will be removed in Chef 13.
27
27
  #
28
28
  module RemoteFile
29
29
 
@@ -83,4 +83,3 @@ class Chef
83
83
  end
84
84
  end
85
85
  end
86
-
@@ -25,7 +25,7 @@ class Chef
25
25
  # == Deprecation::Provider::Template
26
26
  # This module contains the deprecated functions of
27
27
  # Chef::Provider::Template. These functions are refactored to different
28
- # components. They are frozen and will be removed in Chef 12.
28
+ # components. They are frozen and will be removed in Chef 13.
29
29
  #
30
30
  module Template
31
31
 
@@ -25,10 +25,9 @@ class Chef
25
25
  m = instance_method(name)
26
26
  define_method(name) do |*args|
27
27
  message = []
28
- message << "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef 12."
29
- message << "Please update your cookbooks accordingly. Accessed from:"
30
- caller[0..3].each {|l| message << l}
31
- Chef::Log.deprecation message
28
+ message << "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef 13."
29
+ message << "Please update your cookbooks accordingly."
30
+ Chef.log_deprecation(message)
32
31
  super(*args)
33
32
  end
34
33
  end
@@ -45,11 +45,12 @@ class Chef
45
45
  registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') ||
46
46
 
47
47
  # Vista + Server 2008 and newer may have reboots pending from CBS
48
- registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired') ||
48
+ registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') ||
49
49
 
50
50
  # The mere existence of the UpdateExeVolatile key should indicate a pending restart for certain updates
51
51
  # http://support.microsoft.com/kb/832475
52
- (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') &&
52
+ Chef::Platform.windows_server_2003? &&
53
+ (registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') &&
53
54
  !registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? &&
54
55
  [1,2,3].include?(registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0][:data]))
55
56
  elsif platform?("ubuntu")
@@ -19,12 +19,10 @@
19
19
 
20
20
  require 'chef/mixin/convert_to_class_name'
21
21
  require 'chef/exceptions'
22
- require 'chef/resource_builder'
23
22
  require 'chef/mixin/shell_out'
24
23
  require 'chef/mixin/powershell_out'
25
24
  require 'chef/dsl/resources'
26
25
  require 'chef/dsl/definitions'
27
- require 'chef/resource'
28
26
 
29
27
  class Chef
30
28
  module DSL
@@ -122,9 +120,9 @@ class Chef
122
120
 
123
121
  def describe_self_for_error
124
122
  if respond_to?(:name)
125
- %Q[`#{self.class.name} "#{name}"']
123
+ %Q[`#{self.class} "#{name}"']
126
124
  elsif respond_to?(:recipe_name)
127
- %Q[`#{self.class.name} "#{recipe_name}"']
125
+ %Q[`#{self.class} "#{recipe_name}"']
128
126
  else
129
127
  to_s
130
128
  end
@@ -142,8 +140,7 @@ class Chef
142
140
  # method_missing manually. Not a fan. Not. A. Fan.
143
141
  #
144
142
  if respond_to?(method_symbol)
145
- Chef::Log.deprecation("Calling method_missing(#{method_symbol.inspect}) directly is deprecated in Chef 12 and will be removed in Chef 13.")
146
- Chef::Log.deprecation("Use public_send() or send() instead.")
143
+ Chef.log_deprecation("Calling method_missing(#{method_symbol.inspect}) directly is deprecated in Chef 12 and will be removed in Chef 13. Use public_send() or send() instead.")
147
144
  return send(method_symbol, *args, &block)
148
145
  end
149
146
 
@@ -152,7 +149,7 @@ class Chef
152
149
  # never called. DEPRECATED.
153
150
  #
154
151
  if run_context.definitions.has_key?(method_symbol.to_sym)
155
- Chef::Log.deprecation("Definition #{method_symbol} (#{run_context.definitions[method_symbol.to_sym]}) was added to the run_context without calling Chef::DSL::Definitions.add_definition(#{method_symbol.to_sym.inspect}). This will become required in Chef 13.")
152
+ Chef.log_deprecation("Definition #{method_symbol} (#{run_context.definitions[method_symbol.to_sym]}) was added to the run_context without calling Chef::DSL::Definitions.add_definition(#{method_symbol.to_sym.inspect}). This will become required in Chef 13.")
156
153
  Chef::DSL::Definitions.add_definition(method_symbol)
157
154
  return send(method_symbol, *args, &block)
158
155
  end
@@ -176,10 +173,32 @@ class Chef
176
173
  raise NameError, "No resource, method, or local variable named `#{method_symbol}' for #{describe_self_for_error}"
177
174
  end
178
175
  end
176
+
177
+ module FullDSL
178
+ require 'chef/dsl/data_query'
179
+ require 'chef/dsl/platform_introspection'
180
+ require 'chef/dsl/include_recipe'
181
+ require 'chef/dsl/registry_helper'
182
+ require 'chef/dsl/reboot_pending'
183
+ require 'chef/dsl/audit'
184
+ require 'chef/dsl/powershell'
185
+ include Chef::DSL::DataQuery
186
+ include Chef::DSL::PlatformIntrospection
187
+ include Chef::DSL::IncludeRecipe
188
+ include Chef::DSL::Recipe
189
+ include Chef::DSL::RegistryHelper
190
+ include Chef::DSL::RebootPending
191
+ include Chef::DSL::Audit
192
+ include Chef::DSL::Powershell
193
+ end
179
194
  end
180
195
  end
181
196
  end
182
197
 
198
+ # Avoid circular references for things that are only used in instance methods
199
+ require 'chef/resource_builder'
200
+ require 'chef/resource'
201
+
183
202
  # **DEPRECATED**
184
203
  # This used to be part of chef/mixin/recipe_definition_dsl_core. Load the file to activate the deprecation code.
185
204
  require 'chef/mixin/recipe_definition_dsl_core'
@@ -11,14 +11,14 @@ class Chef
11
11
  begin
12
12
  module_eval(<<-EOM, __FILE__, __LINE__+1)
13
13
  def #{dsl_name}(*args, &block)
14
- Chef::Log.deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
14
+ Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
15
15
  declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block)
16
16
  end
17
17
  EOM
18
18
  rescue SyntaxError
19
19
  # Handle the case where dsl_name has spaces, etc.
20
20
  define_method(dsl_name.to_sym) do |*args, &block|
21
- Chef::Log.deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1
21
+ Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1
22
22
  declare_resource(dsl_name, args[0], caller[0], &block)
23
23
  end
24
24
  end
@@ -47,14 +47,19 @@ class Chef
47
47
  def ohai_completed(node)
48
48
  end
49
49
 
50
- # Already have a client key, assuming this node has registered.
50
+ # Announce that we're not going to register the client. Generally because
51
+ # we already have the private key, or because we're deliberately not using
52
+ # a key.
51
53
  def skipping_registration(node_name, config)
52
54
  end
53
55
 
54
- # About to attempt to register as +node_name+
56
+ # About to attempt to create a private key registered to the server with
57
+ # client +node_name+.
55
58
  def registration_start(node_name, config)
56
59
  end
57
60
 
61
+ # Successfully created the private key and registered this client with the
62
+ # server.
58
63
  def registration_completed
59
64
  end
60
65
 
@@ -118,8 +123,8 @@ class Chef
118
123
  def cookbook_sync_start(cookbook_count)
119
124
  end
120
125
 
121
- # Called when cookbook +cookbook_name+ has been sync'd
122
- def synchronized_cookbook(cookbook_name)
126
+ # Called when cookbook +cookbook+ has been sync'd
127
+ def synchronized_cookbook(cookbook_name, cookbook)
123
128
  end
124
129
 
125
130
  # Called when an individual file in a cookbook has been updated
@@ -269,26 +274,37 @@ class Chef
269
274
  # def notifications_resolved
270
275
  # end
271
276
 
277
+ #
278
+ # Resource events and ordering:
279
+ #
280
+ # 1. Start the action
281
+ # - resource_action_start
282
+ # 2. Check the guard
283
+ # - resource_skipped: (goto 7) if only_if/not_if say to skip
284
+ # 3. Load the current resource
285
+ # - resource_current_state_loaded
286
+ # - resource_current_state_load_bypassed (if not why-run safe)
287
+ # 4. Check if why-run safe
288
+ # - resource_bypassed: (goto 7) if not why-run safe
289
+ # 5. During processing:
290
+ # - resource_update_applied: For each actual change (many per action)
291
+ # 6. Processing complete status:
292
+ # - resource_failed if the resource threw an exception while running
293
+ # - resource_failed_retriable: (goto 3) if resource failed and will be retried
294
+ # - resource_updated if the resource was updated (resource_update_applied will have been called)
295
+ # - resource_up_to_date if the resource was up to date (no resource_update_applied)
296
+ # 7. Processing complete:
297
+ # - resource_completed
298
+ #
299
+
272
300
  # Called before action is executed on a resource.
273
301
  def resource_action_start(resource, action, notification_type=nil, notifier=nil)
274
302
  end
275
303
 
276
- # Called when a resource fails, but will retry.
277
- def resource_failed_retriable(resource, action, retry_count, exception)
278
- end
279
-
280
- # Called when a resource fails and will not be retried.
281
- def resource_failed(resource, action, exception)
282
- end
283
-
284
304
  # Called when a resource action has been skipped b/c of a conditional
285
305
  def resource_skipped(resource, action, conditional)
286
306
  end
287
307
 
288
- # Called when a resource action has been completed
289
- def resource_completed(resource)
290
- end
291
-
292
308
  # Called after #load_current_resource has run.
293
309
  def resource_current_state_loaded(resource, action, current_resource)
294
310
  end
@@ -302,21 +318,33 @@ class Chef
302
318
  def resource_bypassed(resource, action, current_resource)
303
319
  end
304
320
 
305
- # Called when a resource has no converge actions, e.g., it was already correct.
306
- def resource_up_to_date(resource, action)
307
- end
308
-
309
321
  # Called when a change has been made to a resource. May be called multiple
310
322
  # times per resource, e.g., a file may have its content updated, and then
311
323
  # its permissions updated.
312
324
  def resource_update_applied(resource, action, update)
313
325
  end
314
326
 
327
+ # Called when a resource fails, but will retry.
328
+ def resource_failed_retriable(resource, action, retry_count, exception)
329
+ end
330
+
331
+ # Called when a resource fails and will not be retried.
332
+ def resource_failed(resource, action, exception)
333
+ end
334
+
315
335
  # Called after a resource has been completely converged, but only if
316
336
  # modifications were made.
317
337
  def resource_updated(resource, action)
318
338
  end
319
339
 
340
+ # Called when a resource has no converge actions, e.g., it was already correct.
341
+ def resource_up_to_date(resource, action)
342
+ end
343
+
344
+ # Called when a resource action has been completed
345
+ def resource_completed(resource)
346
+ end
347
+
320
348
  # A stream has opened.
321
349
  def stream_opened(stream, options = {})
322
350
  end
@@ -352,8 +380,9 @@ class Chef
352
380
  def whyrun_assumption(action, resource, message)
353
381
  end
354
382
 
355
- ## TODO: deprecation warning. this way we can queue them up and present
356
- # them all at once.
383
+ # Emit a message about something being deprecated.
384
+ def deprecation(message, location=caller(2..2)[0])
385
+ end
357
386
 
358
387
  # An uncategorized message. This supports the case that a user needs to
359
388
  # pass output that doesn't fit into one of the callbacks above. Note that
@@ -25,18 +25,33 @@ class Chef
25
25
  # define the forwarding in one go:
26
26
  #
27
27
 
28
- # Define a method that will be forwarded to all
29
- def self.def_forwarding_method(method_name)
30
- define_method(method_name) do |*args|
31
- @subscribers.each { |s| s.send(method_name, *args) }
28
+ def call_subscribers(method_name, *args)
29
+ @subscribers.each do |s|
30
+ # Skip new/unsupported event names.
31
+ next if !s.respond_to?(method_name)
32
+ mth = s.method(method_name)
33
+ # Trim arguments to match what the subscriber expects to allow
34
+ # adding new arguments without breaking compat.
35
+ if mth.arity < args.size && mth.arity >= 0
36
+ mth.call(*args.take(mth.arity))
37
+ else
38
+ mth.call(*args)
39
+ end
32
40
  end
33
41
  end
34
42
 
35
43
  (Base.instance_methods - Object.instance_methods).each do |method_name|
36
- def_forwarding_method(method_name)
44
+ class_eval <<-EOM
45
+ def #{method_name}(*args)
46
+ call_subscribers(#{method_name.inspect}, *args)
47
+ end
48
+ EOM
37
49
  end
38
50
 
51
+ # Special case deprecation, since it needs to know its caller
52
+ def deprecation(message, location=caller(2..2)[0])
53
+ call_subscribers(:deprecation, message, location)
54
+ end
39
55
  end
40
56
  end
41
57
  end
42
-
@@ -0,0 +1,64 @@
1
+ #
2
+ # Author:: Ranjib Dey (<ranjib@linux.com>)
3
+ # Copyright:: Copyright (c) 2015 Ranjib Dey
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ require 'chef/event_dispatch/base'
19
+ require 'chef/exceptions'
20
+ require 'chef/config'
21
+
22
+ class Chef
23
+ module EventDispatch
24
+ class DSL
25
+ attr_reader :handler
26
+
27
+ def initialize(name)
28
+ klass = Class.new(Chef::EventDispatch::Base) do
29
+ attr_reader :name
30
+ end
31
+ @handler = klass.new
32
+ @handler.instance_variable_set(:@name, name)
33
+
34
+ # Use event.register API to add anonymous handler if Chef.run_context
35
+ # and associated event dispatcher is set, else fallback to
36
+ # Chef::Config[:hanlder]
37
+ if Chef.run_context && Chef.run_context.events
38
+ Chef::Log.debug("Registering handler '#{name}' using events api")
39
+ Chef.run_context.events.register(handler)
40
+ else
41
+ Chef::Log.debug("Registering handler '#{name}' using global config")
42
+ Chef::Config[:event_handlers] << handler
43
+ end
44
+ end
45
+
46
+ # Adds a new event handler derived from base handler
47
+ # with user defined block against a chef event
48
+ #
49
+ # @return [Chef::EventDispatch::Base] a base handler object
50
+ def on(event_type, &block)
51
+ validate!(event_type)
52
+ handler.define_singleton_method(event_type) do |*args|
53
+ instance_exec(*args, &block)
54
+ end
55
+ end
56
+
57
+ private
58
+ def validate!(event_type)
59
+ all_event_types = (Chef::EventDispatch::Base.instance_methods - Object.instance_methods)
60
+ raise Chef::Exceptions::InvalidEventType, "Invalid event type: #{event_type}" unless all_event_types.include?(event_type)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -17,12 +17,16 @@
17
17
  # See the License for the specific language governing permissions and
18
18
  # limitations under the License.
19
19
 
20
+ require 'chef-config/exceptions'
21
+
20
22
  class Chef
21
23
  # == Chef::Exceptions
22
24
  # Chef's custom exceptions are all contained within the Chef::Exceptions
23
25
  # namespace.
24
26
  class Exceptions
25
27
 
28
+ ConfigurationError = ChefConfig::ConfigurationError
29
+
26
30
  # Backcompat with Chef::ShellOut code:
27
31
  require 'mixlib/shellout/exceptions'
28
32
 
@@ -68,7 +72,6 @@ class Chef
68
72
  class DuplicateRole < RuntimeError; end
69
73
  class ValidationFailed < ArgumentError; end
70
74
  class InvalidPrivateKey < ArgumentError; end
71
- class ConfigurationError < ArgumentError; end
72
75
  class MissingKeyAttribute < ArgumentError; end
73
76
  class KeyCommandInputError < ArgumentError; end
74
77
  class InvalidKeyArgument < ArgumentError; end
@@ -100,6 +103,11 @@ class Chef
100
103
  class ProviderNotFound < RuntimeError; end
101
104
  NoProviderAvailable = ProviderNotFound
102
105
  class VerificationNotFound < RuntimeError; end
106
+ class InvalidEventType < ArgumentError; end
107
+ class MultipleIdentityError < RuntimeError; end
108
+ # Used in Resource::ActionClass#load_current_resource to denote that
109
+ # the resource doesn't actually exist (for example, the file does not exist)
110
+ class CurrentValueDoesNotExist < RuntimeError; end
103
111
 
104
112
  # Can't find a Resource of this type that is valid on this platform.
105
113
  class NoSuchResourceType < NameError
@@ -108,6 +116,8 @@ class Chef
108
116
  end
109
117
  end
110
118
 
119
+ class InvalidPolicybuilderCall < ArgumentError; end
120
+
111
121
  class InvalidResourceSpecification < ArgumentError; end
112
122
  class SolrConnectionError < RuntimeError; end
113
123
  class IllegalChecksumRevert < RuntimeError; end
@@ -121,6 +131,23 @@ class Chef
121
131
  class EnclosingDirectoryDoesNotExist < ArgumentError; end
122
132
  # Errors originating from calls to the Win32 API
123
133
  class Win32APIError < RuntimeError; end
134
+
135
+ class Win32NetAPIError < Win32APIError
136
+ attr_reader :msg, :error_code
137
+ def initialize(msg, error_code)
138
+ @msg = msg
139
+ @error_code = error_code
140
+
141
+ formatted_message = ""
142
+ formatted_message << "---- Begin Win32 API output ----\n"
143
+ formatted_message << "Net Api Error Code: #{error_code}\n"
144
+ formatted_message << "Net Api Error Message: #{msg}\n"
145
+ formatted_message << "---- End Win32 API output ----\n"
146
+
147
+ super(formatted_message)
148
+ end
149
+ end
150
+
124
151
  # Thrown when Win32 API layer binds to non-existent Win32 function. Occurs
125
152
  # when older versions of Windows don't support newer Win32 API functions.
126
153
  class Win32APIFunctionNotImplemented < NotImplementedError; end