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
@@ -89,4 +89,3 @@ class Chef
89
89
  end
90
90
  end
91
91
  end
92
-
@@ -17,7 +17,6 @@
17
17
  #
18
18
 
19
19
  require 'pathname'
20
- require 'chef/mixin/shell_out'
21
20
  require 'chef/provider/user'
22
21
 
23
22
  class Chef
@@ -25,8 +24,6 @@ class Chef
25
24
  class User
26
25
  class Useradd < Chef::Provider::User
27
26
 
28
- include Chef::Mixin::ShellOut
29
-
30
27
  UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:password, "-p"], [:shell, "-s"], [:uid, "-u"]]
31
28
 
32
29
  def create_user
@@ -19,7 +19,7 @@
19
19
  class Chef
20
20
  class Provider
21
21
  class WhyrunSafeRubyBlock < Chef::Provider::RubyBlock
22
- def action_run
22
+ def action_create
23
23
  @new_resource.block.call
24
24
  @new_resource.updated_by_last_action(true)
25
25
  @run_context.events.resource_update_applied(@new_resource, :create, "execute the whyrun_safe_ruby_block #{@new_resource.name}")
@@ -24,7 +24,6 @@ require 'chef/provider/cron/solaris'
24
24
  require 'chef/provider/cron/aix'
25
25
  require 'chef/provider/deploy'
26
26
  require 'chef/provider/directory'
27
- require 'chef/provider/dsc_script'
28
27
  require 'chef/provider/env'
29
28
  require 'chef/provider/erl_call'
30
29
  require 'chef/provider/execute'
@@ -544,7 +544,7 @@ F
544
544
  # Serialize this object as a hash
545
545
  def to_json(*a)
546
546
  results = as_json
547
- Chef::JSONCompat.to_json(results, *a)
547
+ results.to_json(*a)
548
548
  end
549
549
 
550
550
  def to_hash
@@ -662,9 +662,6 @@ F
662
662
  end
663
663
  ensure
664
664
  @elapsed_time = Time.now - start_time
665
- # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
666
- # A negative value can occur when a resource changes the system time backwards
667
- @elapsed_time = 0 if @elapsed_time < 0
668
665
  events.resource_completed(self)
669
666
  end
670
667
  end
@@ -31,26 +31,17 @@ class Chef
31
31
 
32
32
  provides :package, :on_platforms => ["freebsd"]
33
33
 
34
- attr_accessor :created_as_type
35
34
 
36
35
  def initialize(name, run_context=nil)
37
36
  super
38
37
  @resource_name = :freebsd_package
39
- @created_as_type = "freebsd_package"
40
38
  end
41
39
 
42
40
  def after_created
43
41
  assign_provider
44
42
  end
45
43
 
46
- # This resource can be invoked with multiple names package & freebsd_package.
47
- # We override the to_s method to ensure the key in resource collection
48
- # matches the type resource is declared as using created_as_type. This
49
- # logic can be removed once Chef does this for all resource in Chef 12:
50
- # https://github.com/opscode/chef/issues/1817
51
- def to_s
52
- "#{created_as_type}[#{name}]"
53
- end
44
+
54
45
 
55
46
  private
56
47
 
@@ -77,3 +68,4 @@ class Chef
77
68
  end
78
69
  end
79
70
  end
71
+
@@ -112,21 +112,10 @@ class Chef
112
112
  if action_names.empty?
113
113
  defined?(@actions) ? @actions : from_superclass(:actions, []).dup
114
114
  else
115
- # BC-compat way for checking if actions have already been defined
116
- if defined?(@actions)
117
- @actions.push(*action_names)
118
- else
119
- @actions = action_names
120
- end
115
+ @actions = action_names
121
116
  end
122
117
  end
123
118
 
124
- # @deprecated
125
- def self.valid_actions(*args)
126
- Chef::Log.warn("`valid_actions' is deprecated, please use actions `instead'!")
127
- actions(*args)
128
- end
129
-
130
119
  # Set the run context on the class. Used to provide access to the node
131
120
  # during class definition.
132
121
  def self.run_context=(run_context)
@@ -44,8 +44,6 @@ class Chef
44
44
  :manage_home => false,
45
45
  :non_unique => false
46
46
  }
47
- @iterations = 27855
48
- @salt = nil
49
47
  @allowed_actions.push(:create, :remove, :modify, :manage, :lock, :unlock)
50
48
  end
51
49
 
@@ -107,22 +105,6 @@ class Chef
107
105
  )
108
106
  end
109
107
 
110
- def salt(arg=nil)
111
- set_or_return(
112
- :salt,
113
- arg,
114
- :kind_of => [ String ]
115
- )
116
- end
117
-
118
- def iterations(arg=nil)
119
- set_or_return(
120
- :iterations,
121
- arg,
122
- :kind_of => [ Integer ]
123
- )
124
- end
125
-
126
108
  def system(arg=nil)
127
109
  set_or_return(
128
110
  :system,
@@ -198,7 +198,7 @@ class Chef
198
198
  'json_class' => self.class.name,
199
199
  'instance_vars' => instance_vars
200
200
  }
201
- Chef::JSONCompat.to_json(results, *a)
201
+ results.to_json(*a)
202
202
  end
203
203
 
204
204
  def self.json_create(o)
@@ -230,18 +230,18 @@ class Chef
230
230
  resource_history_url = "reports/nodes/#{node_name}/runs/#{run_id}"
231
231
  Chef::Log.info("Sending resource update report (run-id: #{run_id})")
232
232
  Chef::Log.debug run_data.inspect
233
- compressed_data = encode_gzip(Chef::JSONCompat.to_json(run_data))
234
- Chef::Log.debug("Sending compressed run data...")
235
- # Since we're posting compressed data we can not directly call post_rest which expects JSON
236
- reporting_url = @rest_client.create_url(resource_history_url)
233
+ compressed_data = encode_gzip(run_data.to_json)
237
234
  begin
235
+ Chef::Log.debug("Sending compressed run data...")
236
+ # Since we're posting compressed data we can not directly call post_rest which expects JSON
237
+ reporting_url = @rest_client.create_url(resource_history_url)
238
238
  @rest_client.raw_http_request(:POST, reporting_url, headers({'Content-Encoding' => 'gzip'}), compressed_data)
239
- rescue StandardError => e
240
- if e.respond_to? :response
239
+ rescue Net::HTTPServerException => e
240
+ if e.response.code.to_s == "400"
241
241
  Chef::FileCache.store("failed-reporting-data.json", Chef::JSONCompat.to_json_pretty(run_data), 0640)
242
- Chef::Log.error("Failed to post reporting data to server (HTTP #{e.response.code}), saving to #{Chef::FileCache.load("failed-reporting-data.json", false)}")
242
+ Chef::Log.error("Failed to post reporting data to server (HTTP 400), saving to #{Chef::FileCache.load("failed-reporting-data.json", false)}")
243
243
  else
244
- Chef::Log.error("Failed to post reporting data to server (#{e})")
244
+ Chef::Log.error("Failed to post reporting data to server (HTTP #{e.response.code.to_s})")
245
245
  end
246
246
  end
247
247
  else
@@ -273,7 +273,7 @@ class Chef
273
273
  resource_record.for_json
274
274
  end
275
275
  run_data["status"] = @status
276
- run_data["run_list"] = Chef::JSONCompat.to_json(@run_status.node.run_list)
276
+ run_data["run_list"] = @run_status.node.run_list.to_json
277
277
  run_data["total_res_count"] = @total_res_count.to_s
278
278
  run_data["data"] = {}
279
279
  run_data["start_time"] = start_time.to_s
@@ -283,7 +283,7 @@ class Chef
283
283
  exception_data = {}
284
284
  exception_data["class"] = exception.inspect
285
285
  exception_data["message"] = exception.message
286
- exception_data["backtrace"] = Chef::JSONCompat.to_json(exception.backtrace)
286
+ exception_data["backtrace"] = exception.backtrace.to_json
287
287
  exception_data["description"] = @error_descriptions
288
288
  run_data["data"]["exception"] = exception_data
289
289
  end
@@ -28,7 +28,6 @@ require 'chef/resource/deploy'
28
28
  require 'chef/resource/deploy_revision'
29
29
  require 'chef/resource/directory'
30
30
  require 'chef/resource/dpkg_package'
31
- require 'chef/resource/dsc_script'
32
31
  require 'chef/resource/easy_install_package'
33
32
  require 'chef/resource/env'
34
33
  require 'chef/resource/erl_call'
@@ -143,7 +143,7 @@ class Chef
143
143
 
144
144
  # Serialize this object as a hash
145
145
  def to_json(*a)
146
- Chef::JSONCompat.to_json(to_hash, *a)
146
+ to_hash.to_json(*a)
147
147
  end
148
148
 
149
149
  def update_from!(o)
@@ -236,8 +236,8 @@ class Chef
236
236
  paths = Array(Chef::Config[:role_path])
237
237
  paths.each do |path|
238
238
  roles_files = Dir.glob(File.join(path, "**", "**"))
239
- js_files = roles_files.select { |file| file.match /\/#{name}\.json$/ }
240
- rb_files = roles_files.select { |file| file.match /\/#{name}\.rb$/ }
239
+ js_files = roles_files.select { |file| file.match /#{name}\.json$/ }
240
+ rb_files = roles_files.select { |file| file.match /#{name}\.rb$/ }
241
241
  if js_files.count > 1 or rb_files.count > 1
242
242
  raise Chef::Exceptions::DuplicateRole, "Multiple roles of same type found named #{name}"
243
243
  end
@@ -86,7 +86,7 @@ class Chef
86
86
  end
87
87
 
88
88
  def to_json(*args)
89
- Chef::JSONCompat.to_json(to_a.map { |item| item.to_s}, *args)
89
+ to_a.map { |item| item.to_s}.to_json(*args)
90
90
  end
91
91
 
92
92
  def empty?
@@ -1,6 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@opscode.com>)
3
3
  # Copyright:: Copyright (c) 2008, 2009 Opscode, Inc.
4
+ # Copyright:: Copyright (c) 2014, Chef Software, Inc.
4
5
  # License:: Apache License, Version 2.0
5
6
  #
6
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,320 +16,186 @@
15
16
  # See the License for the specific language governing permissions and
16
17
  # limitations under the License.
17
18
  #
18
-
19
- require 'rubygems'
20
- require 'chef/json_compat'
21
- require 'chef'
22
- require 'chef/role'
23
- require 'chef/cookbook/metadata'
24
- require 'tempfile'
19
+ TOPDIR = '.'
25
20
  require 'rake'
26
21
 
27
- # Allow REMOTE options to be overridden on the command line
28
- REMOTE_HOST = ENV["REMOTE_HOST"] if ENV["REMOTE_HOST"] != nil
29
- REMOTE_SUDO = ENV["REMOTE_SUDO"] if ENV["REMOTE_SUDO"] != nil
30
- if defined? REMOTE_HOST
31
- REMOTE_PATH_PREFIX = "#{REMOTE_HOST}:"
32
- REMOTE_EXEC_PREFIX = "ssh #{REMOTE_HOST}"
33
- REMOTE_EXEC_PREFIX += " sudo" if defined? REMOTE_SUDO
34
- LOCAL_EXEC_PREFIX = ""
35
- else
36
- REMOTE_PATH_PREFIX = ""
37
- REMOTE_EXEC_PREFIX = ""
38
- LOCAL_EXEC_PREFIX = "sudo"
39
- end
40
-
41
- desc "Update your repository from source control"
42
- task :update do
43
- puts "** Updating your repository"
44
-
45
- case $vcs
46
- when :svn
47
- sh %{svn up}
48
- when :git
49
- pull = false
50
- IO.foreach(File.join(TOPDIR, ".git", "config")) do |line|
51
- pull = true if line =~ /\[remote "origin"\]/
52
- end
53
- if pull
54
- sh %{git pull}
55
- else
56
- puts "* Skipping git pull, no origin specified"
57
- end
58
- else
59
- puts "* No SCM configured, skipping update"
60
- end
22
+ desc "By default, print deprecation notice"
23
+ task :default do
24
+ puts deprecation_notice
61
25
  end
62
26
 
63
27
  desc "Install the latest copy of the repository on this Chef Server"
64
- task :install => [ :update, :roles, :upload_cookbooks ] do
65
- if File.exists?(File.join(TOPDIR, "config", "server.rb"))
66
- puts "* Installing new Chef Server Config"
67
- sh "#{LOCAL_EXEC_PREFIX} rsync -rlt --delete --exclude '.svn' --exclude '.git*' config/server.rb #{REMOTE_PATH_PREFIX}#{CHEF_SERVER_CONFIG}"
68
- end
69
- if File.exists?(File.join(TOPDIR, "config", "client.rb"))
70
- puts "* Installing new Chef Client Config"
71
- sh "#{LOCAL_EXEC_PREFIX} rsync -rlt --delete --exclude '.svn' --exclude '.git*' config/client.rb #{REMOTE_PATH_PREFIX}#{CHEF_CLIENT_CONFIG}"
72
- end
28
+ task :install do
29
+ puts deprecation_notice
30
+ puts 'The `install` rake task, which included the `update`, `roles`, and'
31
+ puts '`upload_cookbooks` rake tasks is replaced by the `knife upload`'
32
+ puts 'sub-command. The notion of "installing" the chef-repo to the Chef'
33
+ puts 'Server. Previously the `install` task would manage server and'
34
+ puts 'client configuration. This will not work at all on Chef Server 11+'
35
+ puts 'and client configuration should be managed with the `chef-client`'
36
+ puts 'cookbook.'
73
37
  end
74
38
 
75
- desc "By default, run rake test_cookbooks"
76
- task :default => [ :test_cookbooks ]
39
+ desc "Update your repository from source control"
40
+ task :update do
41
+ puts deprecation_notice
42
+ puts 'The `update` rake task previously updated the chef-repo from'
43
+ puts 'the detected version control system, either svn or git. However,'
44
+ puts 'it has not been recommended for users for years. Most users in'
45
+ puts 'the community use `git`, so the Subversion functionality is not'
46
+ puts 'required, and `git pull` is sufficient for many workflows. The'
47
+ puts 'world of git workflows is rather different now than it was when'
48
+ puts 'this rake task was created.'
49
+ end
77
50
 
78
51
  desc "Create a new cookbook (with COOKBOOK=name, optional CB_PREFIX=site-)"
79
52
  task :new_cookbook do
80
- puts "***WARN: rake new_cookbook is deprecated. Please use 'knife cookbook create COOKBOOK' command.***"
81
- create_cookbook(File.join(TOPDIR, "#{ENV["CB_PREFIX"]}cookbooks"))
82
- create_readme(File.join(TOPDIR, "#{ENV["CB_PREFIX"]}cookbooks"))
83
- create_metadata(File.join(TOPDIR, "#{ENV["CB_PREFIX"]}cookbooks"))
84
- end
85
-
86
- def create_cookbook(dir)
87
- raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
88
- puts "** Creating cookbook #{ENV["COOKBOOK"]}"
89
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "attributes")}"
90
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "recipes")}"
91
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "definitions")}"
92
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "libraries")}"
93
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "resources")}"
94
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "providers")}"
95
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "files", "default")}"
96
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "templates", "default")}"
97
- unless File.exists?(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"))
98
- open(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"), "w") do |file|
99
- file.puts <<-EOH
100
- #
101
- # Cookbook Name:: #{ENV["COOKBOOK"]}
102
- # Recipe:: default
103
- #
104
- # Copyright #{Time.now.year}, #{COMPANY_NAME}
105
- #
106
- EOH
107
- case NEW_COOKBOOK_LICENSE
108
- when :apachev2
109
- file.puts <<-EOH
110
- # Licensed under the Apache License, Version 2.0 (the "License");
111
- # you may not use this file except in compliance with the License.
112
- # You may obtain a copy of the License at
113
- #
114
- # http://www.apache.org/licenses/LICENSE-2.0
115
- #
116
- # Unless required by applicable law or agreed to in writing, software
117
- # distributed under the License is distributed on an "AS IS" BASIS,
118
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
- # See the License for the specific language governing permissions and
120
- # limitations under the License.
121
- #
122
- EOH
123
- when :none
124
- file.puts <<-EOH
125
- # All rights reserved - Do Not Redistribute
126
- #
127
- EOH
128
- end
129
- end
130
- end
131
- end
132
-
133
- def create_readme(dir)
134
- raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
135
- puts "** Creating README for cookbook: #{ENV["COOKBOOK"]}"
136
- unless File.exists?(File.join(dir, ENV["COOKBOOK"], "README.rdoc"))
137
- open(File.join(dir, ENV["COOKBOOK"], "README.md"), "w") do |file|
138
- file.puts <<-EOH
139
- Description
140
- ===========
141
-
142
- Requirements
143
- ============
144
-
145
- Attributes
146
- ==========
147
-
148
- Usage
149
- =====
150
-
151
- EOH
152
- end
153
- end
154
- end
155
-
156
- def create_metadata(dir)
157
- raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
158
- puts "** Creating metadata for cookbook: #{ENV["COOKBOOK"]}"
159
-
160
- case NEW_COOKBOOK_LICENSE
161
- when :apachev2
162
- license = "Apache 2.0"
163
- when :none
164
- license = "All rights reserved"
165
- end
166
-
167
- unless File.exists?(File.join(dir, ENV["COOKBOOK"], "metadata.rb"))
168
- open(File.join(dir, ENV["COOKBOOK"], "metadata.rb"), "w") do |file|
169
- if File.exists?(File.join(dir, ENV["COOKBOOK"], 'README.rdoc'))
170
- long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))"
171
- end
172
- file.puts <<-EOH
173
- maintainer "#{COMPANY_NAME}"
174
- maintainer_email "#{SSL_EMAIL_ADDRESS}"
175
- license "#{license}"
176
- description "Installs/Configures #{ENV["COOKBOOK"]}"
177
- #{long_description}
178
- version "0.1"
179
- EOH
180
- end
181
- end
53
+ cb = ENV['COOKBOOK'] || 'my_cookbook_name'
54
+ puts deprecation_notice
55
+ puts 'The `new_cookbook` rake task is replaced by the ChefDK cookbook'
56
+ puts 'generator. To generate a new cookbook run:'
57
+ puts
58
+ puts "chef generate cookbook #{ENV['COOKBOOK']}"
59
+ puts
60
+ puts 'Or, if you are not using ChefDK, use `knife cookbook create`:'
61
+ puts
62
+ puts "knife cookbook create #{ENV['COOKBOOK']}"
182
63
  end
183
64
 
184
65
  desc "Create a new self-signed SSL certificate for FQDN=foo.example.com"
185
66
  task :ssl_cert do
186
- $expect_verbose = true
187
- fqdn = ENV["FQDN"]
188
- fqdn =~ /^(.+?)\.(.+)$/
189
- hostname = $1
190
- domain = $2
191
- raise "Must provide FQDN!" unless fqdn && hostname && domain
192
- keyfile = fqdn.gsub("*", "wildcard")
193
- puts "** Creating self signed SSL Certificate for #{fqdn}"
194
- sh("(cd #{CADIR} && openssl genrsa 2048 > #{keyfile}.key)")
195
- sh("(cd #{CADIR} && chmod 644 #{keyfile}.key)")
196
- puts "* Generating Self Signed Certificate Request"
197
- tf = Tempfile.new("#{keyfile}.ssl-conf")
198
- ssl_config = <<EOH
199
- [ req ]
200
- distinguished_name = req_distinguished_name
201
- prompt = no
202
-
203
- [ req_distinguished_name ]
204
- C = #{SSL_COUNTRY_NAME}
205
- ST = #{SSL_STATE_NAME}
206
- L = #{SSL_LOCALITY_NAME}
207
- O = #{COMPANY_NAME}
208
- OU = #{SSL_ORGANIZATIONAL_UNIT_NAME}
209
- CN = #{fqdn}
210
- emailAddress = #{SSL_EMAIL_ADDRESS}
211
- EOH
212
- tf.puts(ssl_config)
213
- tf.close
214
- sh("(cd #{CADIR} && openssl req -config '#{tf.path}' -new -x509 -nodes -sha1 -days 3650 -key #{keyfile}.key > #{keyfile}.crt)")
215
- sh("(cd #{CADIR} && openssl x509 -noout -fingerprint -text < #{keyfile}.crt > #{keyfile}.info)")
216
- sh("(cd #{CADIR} && cat #{keyfile}.crt #{keyfile}.key > #{keyfile}.pem)")
217
- sh("(cd #{CADIR} && chmod 644 #{keyfile}.pem)")
218
- end
219
-
220
- rule(%r{\b(?:site-)?cookbooks/[^/]+/metadata\.json\Z} => [ proc { |task_name| task_name.sub(/\.[^.]+$/, '.rb') } ]) do |t|
221
- system("knife cookbook metadata from file #{t.source}")
67
+ puts deprecation_notice
68
+ puts 'The `ssl_cert` rake task is superseded by using the CHEF-maintained'
69
+ puts '`openssl` cookbook\'s `openssl_x509` resource which can generate'
70
+ puts 'self-signed certificate chains as convergent resources.'
71
+ puts
72
+ puts 'https://supermarket.getchef.com/cookbooks/openssl'
222
73
  end
223
74
 
224
75
  desc "Build cookbook metadata.json from metadata.rb"
225
- task :metadata => FileList[File.join(TOPDIR, '*cookbooks', ENV['COOKBOOK'] || '*', 'metadata.rb')].pathmap('%X.json')
226
-
227
- rule(%r{\broles/\S+\.json\Z} => [ proc { |task_name| task_name.sub(/\.[^.]+$/, '.rb') } ]) do |t|
228
- system("knife role from file #{t.source}")
76
+ task :metadata do
77
+ puts deprecation_notice
78
+ puts 'The `metadata` rake task is not recommended. Cookbook'
79
+ puts '`metadata.json` is automatically generated from `metadata.rb`'
80
+ puts 'by `knife` when uploading cookbooks to the Chef Server.'
229
81
  end
230
82
 
231
83
  desc "Update roles"
232
- task :roles => FileList[File.join(TOPDIR, 'roles', '**', '*.rb')].pathmap('%X.json')
84
+ task :roles do
85
+ puts deprecation_notice
86
+ puts 'The `roles` rake task is not recommended. If you are using Ruby'
87
+ puts 'role files (roles/*.rb), you can upload them all with:'
88
+ puts
89
+ puts 'knife role from file roles/*'
90
+ puts
91
+ puts 'If you are using JSON role files (roles/*.json), you can upload'
92
+ puts 'them all with:'
93
+ puts
94
+ puts 'knife upload roles/*.json'
95
+ end
233
96
 
234
97
  desc "Update a specific role"
235
- task :role, :role_name do |t, args|
236
- system("knife role from file #{File.join(TOPDIR, 'roles', args.role_name)}.rb")
98
+ task :role do
99
+ puts deprecation_notice
100
+ puts 'The `role` rake task is not recommended. If you are using Ruby'
101
+ puts 'role files, you can upload a single role with:'
102
+ puts
103
+ puts 'knife role from file rolename.rb'
104
+ puts
105
+ puts 'If you are using JSON role files, you can upload a single role with'
106
+ puts
107
+ puts 'knife upload roles/rolename.json'
237
108
  end
238
109
 
239
110
  desc "Upload all cookbooks"
240
- task :upload_cookbooks => [ :metadata ]
241
111
  task :upload_cookbooks do
242
- system("knife cookbook upload --all")
112
+ puts deprecation_notice
113
+ puts deprecated_cookbook_upload
243
114
  end
244
115
 
245
116
  desc "Upload a single cookbook"
246
- task :upload_cookbook => [ :metadata ]
247
- task :upload_cookbook, :cookbook do |t, args|
248
- system("knife cookbook upload #{args.cookbook}")
117
+ task :upload_cookbook do
118
+ puts deprecation_notice
119
+ puts deprecated_cookbook_upload
249
120
  end
250
121
 
251
122
  desc "Test all cookbooks"
252
123
  task :test_cookbooks do
253
- system("knife cookbook test --all")
124
+ puts deprecation_notice
125
+ puts 'The `test_cookbooks` rake task is no longer recommended. Previously'
126
+ puts 'it only performed a syntax check, and did no other kind of testing,'
127
+ puts 'and the Chef Community has a rich ecosystem of testing tools for'
128
+ puts 'various purposes:'
129
+ puts
130
+ puts '- knife cookbook test will perform a syntax check, as this task did'
131
+ puts ' before.'
132
+ puts '- rubocop and foodcritic will perform lint checking for Ruby and'
133
+ puts ' Chef cookbook style according to community standards.'
134
+ puts '- ChefSpec will perform unit testing'
135
+ puts '- Test Kitchen will perform convergence and post-convergence'
136
+ puts ' testing on virtual machines.'
254
137
  end
255
138
 
256
139
  desc "Test a single cookbook"
257
- task :test_cookbook, :cookbook do |t, args|
258
- system("knife cookbook test #{args.cookbook}")
259
- end
140
+ task :test_cookbook => [:test_cookbooks]
260
141
 
261
142
  namespace :databag do
262
- path = "data_bags"
263
-
264
143
  desc "Upload a single databag"
265
- task :upload, :databag do |t, args|
266
- input_databag = args[:databag] || 'none_specified'
267
- databag = File.join(path, input_databag)
268
-
269
- if File.exists?(databag) && File.directory?(databag)
270
- system "knife data bag create #{input_databag}"
271
- Dir.foreach(databag) do |item|
272
- name, type = item.split('.')
273
- if type == 'json' && name.length > 0
274
- system "knife data bag from file #{input_databag} " + File.join(databag, item)
275
- end
276
- end
277
- else
278
- puts "ERROR: Could not find the databag in your databag path (" + File.join(path, input_databag) + "), skipping it"
279
- end
144
+ task :upload do
145
+ puts deprecation_notice
146
+ puts 'The `data_bags:upload` task is not recommended. You should use'
147
+ puts 'the `knife upload` sub-command for uploading data bag items.'
148
+ puts
149
+ puts 'knife upload data_bags/bagname/itemname.json'
280
150
  end
281
151
 
282
152
  desc "Upload all databags"
283
153
  task :upload_all do
284
- if File.exists?(path) && File.directory?(path)
285
- Dir.foreach(path) do |databag|
286
- if databag == databag[/^[\-[:alnum:]_]+$/]
287
- Rake::Task['databag:upload'].execute( { :databag => databag } )
288
- end
289
- end
290
- else
291
- puts "ERROR: Could not find any databags, skipping it"
292
- end
154
+ puts deprecation_notice
155
+ puts 'The `data_bags:upload_all` task is not recommended. You should'
156
+ puts 'use the `knife upload` sub-command for uploading data bag items.'
157
+ puts
158
+ puts 'knife upload data_bags/*'
293
159
  end
294
160
 
295
161
  desc "Create a databag"
296
- task :create, :databag do |t, args|
297
- input_databag = args[:databag] || 'none_specified'
298
-
299
- FileUtils.mkdir(path) unless File.exists?(path)
300
- databag = File.join(path, input_databag)
301
- FileUtils.mkdir(databag) unless File.exists?(databag)
162
+ task :create do
163
+ puts deprecation_notice
164
+ puts deprecated_data_bag_creation
302
165
  end
303
166
 
304
167
  desc "Create a databag item stub"
305
- task :create_item, :databag, :item do |t, args|
306
- input_databag = args[:databag] || 'none_specified'
307
- input_item = args[:item] || false
308
-
309
- databag = File.join(path, input_databag)
310
- if File.exists?(databag) && File.directory?(databag)
311
- if input_item
312
- json_filename = File.join(databag, "#{input_item}.json")
313
- if !File.exists?(json_filename)
314
- stub = <<EOH
315
- {
316
- "id" : "#{input_item}"
317
- }
318
- EOH
319
- json_file = File.new(json_filename, "w")
320
- json_file.write(stub)
321
- json_file.close
322
- else
323
- puts "ERROR: databag item already exists (#{json_filename}), skipping it"
324
- end
325
- else
326
- puts "ERROR: No item id specified, skipping it"
327
- end
328
- else
329
- puts "ERROR: Could not find your databag (#{databag}), skipping it"
330
- end
168
+ task :create_item do
169
+ puts deprecation_notice
170
+ puts deprecated_data_bag_creation
331
171
  end
172
+ end
173
+
174
+ def deprecation_notice
175
+ %Q[*************************************************
176
+ NOTICE: Chef Repository Rake Tasks Are Deprecated
177
+ *************************************************
178
+ ]
332
179
 
333
180
  end
334
181
 
182
+ def deprecated_cookbook_upload
183
+ %Q[
184
+ The `upload_cookbook` and `upload_cookbooks` rake tasks are not
185
+ recommended. These tasks are replaced by other, better workflow
186
+ tools, such as `knife cookbook upload`, `knife upload`, or `berks`
187
+ ]
188
+ end
189
+
190
+ def deprecated_data_bag_creation
191
+ %Q[
192
+ The `data_bags:create` and `data_bags:create_item` tasks are not
193
+ recommended. You should create data bag items as JSON files in the data_bags
194
+ directory, with a sub-directory for each bag, and use `knife upload` to
195
+ upload them. For example, if you have a data bags named `users`, with
196
+ `finn`, and `jake` items, you would have:
197
+
198
+ ./data_bags/users/finn.json
199
+ ./data-bags/users/jake.json
200
+ ]
201
+ end