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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -4
  3. data/README.md +12 -13
  4. data/VERSION +1 -1
  5. data/acceptance/Gemfile +4 -4
  6. data/acceptance/Gemfile.lock +70 -69
  7. data/chef-universal-mingw32.gemspec +2 -3
  8. data/chef.gemspec +6 -6
  9. data/lib/chef/api_client.rb +8 -10
  10. data/lib/chef/api_client_v1.rb +9 -11
  11. data/lib/chef/application/apply.rb +8 -10
  12. data/lib/chef/application/client.rb +1 -1
  13. data/lib/chef/application/exit_code.rb +3 -5
  14. data/lib/chef/application/knife.rb +2 -2
  15. data/lib/chef/application/windows_service.rb +29 -30
  16. data/lib/chef/application/windows_service_manager.rb +1 -1
  17. data/lib/chef/audit/audit_event_proxy.rb +2 -2
  18. data/lib/chef/audit/control_group_data.rb +1 -1
  19. data/lib/chef/chef_class.rb +1 -0
  20. data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
  21. data/lib/chef/chef_fs/command_line.rb +15 -16
  22. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
  23. data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
  24. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
  25. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  26. data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
  27. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
  28. data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
  29. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
  30. data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
  31. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
  32. data/lib/chef/chef_fs/file_pattern.rb +2 -2
  33. data/lib/chef/chef_fs/file_system.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
  35. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
  36. data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
  37. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
  38. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
  39. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
  40. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
  41. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
  42. data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
  43. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
  44. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
  45. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
  46. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
  47. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
  48. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
  49. data/lib/chef/chef_fs/parallelizer.rb +9 -11
  50. data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
  51. data/lib/chef/cookbook/metadata.rb +26 -26
  52. data/lib/chef/cookbook/syntax_check.rb +1 -1
  53. data/lib/chef/cookbook_version.rb +3 -3
  54. data/lib/chef/data_bag.rb +1 -1
  55. data/lib/chef/data_bag_item.rb +3 -3
  56. data/lib/chef/data_collector.rb +3 -4
  57. data/lib/chef/decorator.rb +1 -1
  58. data/lib/chef/deprecated.rb +30 -0
  59. data/lib/chef/dsl/audit.rb +2 -2
  60. data/lib/chef/dsl/declare_resource.rb +1 -1
  61. data/lib/chef/dsl/platform_introspection.rb +29 -31
  62. data/lib/chef/dsl/reboot_pending.rb +1 -1
  63. data/lib/chef/dsl/resources.rb +6 -8
  64. data/lib/chef/encrypted_data_bag_item.rb +2 -2
  65. data/lib/chef/environment.rb +9 -11
  66. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  67. data/lib/chef/exceptions.rb +4 -1
  68. data/lib/chef/file_access_control/unix.rb +14 -14
  69. data/lib/chef/file_access_control/windows.rb +1 -1
  70. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
  71. data/lib/chef/formatters/error_mapper.rb +6 -6
  72. data/lib/chef/http/api_versions.rb +50 -0
  73. data/lib/chef/http/validate_content_length.rb +2 -2
  74. data/lib/chef/json_compat.rb +6 -10
  75. data/lib/chef/key.rb +5 -5
  76. data/lib/chef/knife.rb +4 -4
  77. data/lib/chef/knife/cookbook_site_install.rb +2 -2
  78. data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
  79. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  80. data/lib/chef/knife/core/status_presenter.rb +1 -1
  81. data/lib/chef/knife/core/ui.rb +19 -25
  82. data/lib/chef/knife/data_bag_secret_options.rb +1 -1
  83. data/lib/chef/knife/deps.rb +32 -34
  84. data/lib/chef/knife/help.rb +1 -1
  85. data/lib/chef/knife/list.rb +1 -1
  86. data/lib/chef/knife/search.rb +2 -2
  87. data/lib/chef/knife/ssh.rb +37 -27
  88. data/lib/chef/knife/ssl_check.rb +1 -1
  89. data/lib/chef/knife/user_delete.rb +1 -1
  90. data/lib/chef/mash.rb +1 -1
  91. data/lib/chef/mixin/command.rb +2 -2
  92. data/lib/chef/mixin/create_path.rb +3 -5
  93. data/lib/chef/mixin/from_file.rb +2 -2
  94. data/lib/chef/mixin/get_source_from_package.rb +2 -2
  95. data/lib/chef/mixin/notifying_block.rb +7 -9
  96. data/lib/chef/mixin/params_validate.rb +3 -3
  97. data/lib/chef/mixin/securable.rb +1 -1
  98. data/lib/chef/mixin/shell_out.rb +23 -3
  99. data/lib/chef/mixin/unformatter.rb +2 -2
  100. data/lib/chef/mixin/uris.rb +4 -6
  101. data/lib/chef/mixin/versioned_api.rb +69 -0
  102. data/lib/chef/mixin/which.rb +25 -8
  103. data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
  104. data/lib/chef/mixin/xml_escape.rb +3 -5
  105. data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
  106. data/lib/chef/node.rb +8 -8
  107. data/lib/chef/node/attribute.rb +4 -4
  108. data/lib/chef/node/common_api.rb +5 -7
  109. data/lib/chef/org.rb +10 -12
  110. data/lib/chef/platform/provider_mapping.rb +7 -7
  111. data/lib/chef/platform/query_helpers.rb +1 -1
  112. data/lib/chef/policy_builder/policyfile.rb +1 -0
  113. data/lib/chef/property.rb +31 -0
  114. data/lib/chef/provider/batch.rb +1 -1
  115. data/lib/chef/provider/breakpoint.rb +1 -1
  116. data/lib/chef/provider/cookbook_file.rb +3 -3
  117. data/lib/chef/provider/cron.rb +38 -38
  118. data/lib/chef/provider/deploy.rb +81 -81
  119. data/lib/chef/provider/deploy/revision.rb +3 -5
  120. data/lib/chef/provider/directory.rb +32 -32
  121. data/lib/chef/provider/dsc_resource.rb +22 -6
  122. data/lib/chef/provider/env.rb +28 -28
  123. data/lib/chef/provider/env/windows.rb +1 -1
  124. data/lib/chef/provider/erl_call.rb +13 -13
  125. data/lib/chef/provider/execute.rb +5 -2
  126. data/lib/chef/provider/file.rb +49 -51
  127. data/lib/chef/provider/git.rb +55 -55
  128. data/lib/chef/provider/http_request.rb +36 -36
  129. data/lib/chef/provider/launchd.rb +2 -2
  130. data/lib/chef/provider/link.rb +50 -50
  131. data/lib/chef/provider/log.rb +2 -2
  132. data/lib/chef/provider/mdadm.rb +25 -25
  133. data/lib/chef/provider/mount/aix.rb +2 -2
  134. data/lib/chef/provider/mount/mount.rb +2 -2
  135. data/lib/chef/provider/ohai.rb +1 -1
  136. data/lib/chef/provider/osx_profile.rb +23 -23
  137. data/lib/chef/provider/package.rb +74 -56
  138. data/lib/chef/provider/package/aix.rb +55 -52
  139. data/lib/chef/provider/package/apt.rb +15 -13
  140. data/lib/chef/provider/package/cab.rb +49 -20
  141. data/lib/chef/provider/package/chocolatey.rb +9 -10
  142. data/lib/chef/provider/package/dnf.rb +20 -18
  143. data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
  144. data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
  145. data/lib/chef/provider/package/dnf/version.rb +1 -1
  146. data/lib/chef/provider/package/dpkg.rb +8 -9
  147. data/lib/chef/provider/package/easy_install.rb +22 -22
  148. data/lib/chef/provider/package/freebsd/base.rb +10 -10
  149. data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
  150. data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
  151. data/lib/chef/provider/package/freebsd/port.rb +7 -7
  152. data/lib/chef/provider/package/homebrew.rb +11 -10
  153. data/lib/chef/provider/package/ips.rb +18 -23
  154. data/lib/chef/provider/package/macports.rb +23 -23
  155. data/lib/chef/provider/package/msu.rb +11 -11
  156. data/lib/chef/provider/package/openbsd.rb +25 -22
  157. data/lib/chef/provider/package/pacman.rb +16 -16
  158. data/lib/chef/provider/package/paludis.rb +26 -27
  159. data/lib/chef/provider/package/portage.rb +22 -22
  160. data/lib/chef/provider/package/powershell.rb +17 -17
  161. data/lib/chef/provider/package/rpm.rb +25 -25
  162. data/lib/chef/provider/package/rubygems.rb +60 -60
  163. data/lib/chef/provider/package/smartos.rb +16 -16
  164. data/lib/chef/provider/package/solaris.rb +44 -44
  165. data/lib/chef/provider/package/windows.rb +3 -3
  166. data/lib/chef/provider/package/windows/exe.rb +6 -6
  167. data/lib/chef/provider/package/windows/msi.rb +6 -6
  168. data/lib/chef/provider/package/yum.rb +318 -268
  169. data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
  170. data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
  171. data/lib/chef/provider/package/zypper.rb +11 -11
  172. data/lib/chef/provider/powershell_script.rb +15 -7
  173. data/lib/chef/provider/reboot.rb +10 -10
  174. data/lib/chef/provider/registry_key.rb +39 -39
  175. data/lib/chef/provider/remote_directory.rb +3 -3
  176. data/lib/chef/provider/remote_file.rb +3 -3
  177. data/lib/chef/provider/route.rb +1 -1
  178. data/lib/chef/provider/ruby_block.rb +3 -3
  179. data/lib/chef/provider/script.rb +42 -6
  180. data/lib/chef/provider/service.rb +49 -49
  181. data/lib/chef/provider/service/solaris.rb +1 -1
  182. data/lib/chef/provider/service/systemd.rb +1 -1
  183. data/lib/chef/provider/subversion.rb +39 -39
  184. data/lib/chef/provider/systemd_unit.rb +2 -0
  185. data/lib/chef/provider/template.rb +3 -3
  186. data/lib/chef/provider/user.rb +42 -42
  187. data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
  188. data/lib/chef/resource.rb +27 -16
  189. data/lib/chef/resource/apt_repository.rb +0 -1
  190. data/lib/chef/resource/chef_gem.rb +1 -1
  191. data/lib/chef/resource/dnf_package.rb +6 -3
  192. data/lib/chef/resource/dsc_resource.rb +9 -1
  193. data/lib/chef/resource/execute.rb +70 -6
  194. data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
  195. data/lib/chef/resource/freebsd_package.rb +1 -1
  196. data/lib/chef/resource/gem_package.rb +1 -1
  197. data/lib/chef/resource/launchd.rb +13 -1
  198. data/lib/chef/resource/package.rb +2 -2
  199. data/lib/chef/resource/registry_key.rb +1 -1
  200. data/lib/chef/resource/yum_package.rb +12 -3
  201. data/lib/chef/resource/yum_repository.rb +0 -1
  202. data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
  203. data/lib/chef/resource_collection/resource_set.rb +2 -2
  204. data/lib/chef/resource_reporter.rb +1 -1
  205. data/lib/chef/run_context.rb +3 -3
  206. data/lib/chef/run_list/run_list_item.rb +1 -1
  207. data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
  208. data/lib/chef/server_api.rb +2 -0
  209. data/lib/chef/server_api_versions.rb +40 -0
  210. data/lib/chef/shell.rb +1 -1
  211. data/lib/chef/shell/ext.rb +3 -3
  212. data/lib/chef/shell/shell_session.rb +1 -1
  213. data/lib/chef/user.rb +9 -11
  214. data/lib/chef/user_v1.rb +9 -11
  215. data/lib/chef/util/diff.rb +1 -1
  216. data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
  217. data/lib/chef/util/selinux.rb +1 -1
  218. data/lib/chef/util/windows/net_group.rb +18 -30
  219. data/lib/chef/util/windows/net_use.rb +7 -11
  220. data/lib/chef/util/windows/net_user.rb +11 -17
  221. data/lib/chef/util/windows/volume.rb +9 -15
  222. data/lib/chef/version.rb +1 -1
  223. data/lib/chef/version_class.rb +1 -1
  224. data/lib/chef/win32/api.rb +4 -6
  225. data/lib/chef/win32/api/file.rb +25 -31
  226. data/lib/chef/win32/api/installer.rb +2 -2
  227. data/lib/chef/win32/file.rb +4 -6
  228. data/lib/chef/win32/registry.rb +9 -9
  229. data/lib/chef/win32/security.rb +2 -2
  230. data/lib/chef/win32/security/acl.rb +2 -2
  231. data/lib/chef/win32/unicode.rb +2 -2
  232. data/lib/chef/win32/version.rb +1 -1
  233. data/spec/data/prefer_metadata_json/metadata.json +51 -0
  234. data/spec/data/prefer_metadata_json/metadata.rb +6 -0
  235. data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
  236. data/spec/functional/knife/ssh_spec.rb +5 -5
  237. data/spec/functional/resource/batch_spec.rb +5 -1
  238. data/spec/functional/resource/dsc_script_spec.rb +2 -4
  239. data/spec/functional/resource/execute_spec.rb +17 -0
  240. data/spec/functional/resource/user/dscl_spec.rb +2 -4
  241. data/spec/integration/client/client_spec.rb +33 -0
  242. data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
  243. data/spec/spec_helper.rb +4 -0
  244. data/spec/support/chef_helpers.rb +5 -7
  245. data/spec/support/platform_helpers.rb +6 -0
  246. data/spec/support/platforms/prof/gc.rb +4 -6
  247. data/spec/support/shared/context/client.rb +1 -1
  248. data/spec/support/shared/functional/execute_resource.rb +150 -0
  249. data/spec/support/shared/functional/windows_script.rb +74 -4
  250. data/spec/support/shared/unit/execute_resource.rb +37 -0
  251. data/spec/support/shared/unit/provider/file.rb +10 -0
  252. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
  253. data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
  254. data/spec/unit/http/api_versions_spec.rb +69 -0
  255. data/spec/unit/knife/ssh_spec.rb +34 -36
  256. data/spec/unit/mixin/versioned_api_spec.rb +107 -0
  257. data/spec/unit/mixin/which.rb +160 -0
  258. data/spec/unit/platform_spec.rb +28 -1
  259. data/spec/unit/provider/deploy_spec.rb +1 -1
  260. data/spec/unit/provider/directory_spec.rb +10 -0
  261. data/spec/unit/provider/dsc_resource_spec.rb +175 -0
  262. data/spec/unit/provider/execute_spec.rb +0 -1
  263. data/spec/unit/provider/launchd_spec.rb +2 -2
  264. data/spec/unit/provider/package/aix_spec.rb +22 -22
  265. data/spec/unit/provider/package/apt_spec.rb +27 -27
  266. data/spec/unit/provider/package/cab_spec.rb +59 -5
  267. data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
  268. data/spec/unit/provider/package/dpkg_spec.rb +16 -16
  269. data/spec/unit/provider/package/easy_install_spec.rb +18 -18
  270. data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
  271. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
  272. data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
  273. data/spec/unit/provider/package/homebrew_spec.rb +9 -9
  274. data/spec/unit/provider/package/ips_spec.rb +37 -31
  275. data/spec/unit/provider/package/macports_spec.rb +10 -10
  276. data/spec/unit/provider/package/openbsd_spec.rb +10 -10
  277. data/spec/unit/provider/package/pacman_spec.rb +6 -6
  278. data/spec/unit/provider/package/paludis_spec.rb +7 -7
  279. data/spec/unit/provider/package/portage_spec.rb +6 -7
  280. data/spec/unit/provider/package/rpm_spec.rb +23 -23
  281. data/spec/unit/provider/package/rubygems_spec.rb +38 -38
  282. data/spec/unit/provider/package/solaris_spec.rb +15 -15
  283. data/spec/unit/provider/package/windows_spec.rb +2 -1
  284. data/spec/unit/provider/package/yum_spec.rb +51 -43
  285. data/spec/unit/provider/package/zypper_spec.rb +34 -34
  286. data/spec/unit/provider/package_spec.rb +8 -0
  287. data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
  288. data/spec/unit/provider/route_spec.rb +7 -1
  289. data/spec/unit/provider/script_spec.rb +49 -6
  290. data/spec/unit/resource/dsc_resource_spec.rb +6 -0
  291. data/spec/unit/resource/execute_spec.rb +214 -0
  292. data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
  293. data/spec/unit/resource/freebsd_package_spec.rb +2 -2
  294. data/spec/unit/resource/package_spec.rb +5 -0
  295. data/spec/unit/resource/yum_package_spec.rb +42 -1
  296. data/spec/unit/resource_reporter_spec.rb +1 -1
  297. data/spec/unit/resource_spec.rb +18 -0
  298. data/spec/unit/server_api_versions_spec.rb +44 -0
  299. data/spec/unit/util/selinux_spec.rb +3 -14
  300. data/spec/unit/win32/error_spec.rb +67 -0
  301. data/spec/unit/win32/security_spec.rb +66 -0
  302. data/tasks/changelog.rb +1 -1
  303. data/tasks/dependencies.rb +20 -4
  304. metadata +39 -18
  305. data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -55,7 +55,7 @@ class Chef
55
55
  # If accessing the registry key failed, then we're probably not on
56
56
  # nano. Fail through.
57
57
  end
58
- return nano == 1
58
+ nano == 1
59
59
  end
60
60
 
61
61
  def supports_msi?
@@ -173,6 +173,7 @@ class Chef
173
173
  CookbookCacheCleaner.instance.skip_removal = true if named_run_list_requested?
174
174
 
175
175
  node.run_list(run_list)
176
+ node.automatic_attrs[:policy_revision] = revision_id
176
177
  node.automatic_attrs[:roles] = []
177
178
  node.automatic_attrs[:recipes] = run_list_expansion_ish.recipes
178
179
  run_list_expansion_ish
@@ -518,6 +518,13 @@ class Chef
518
518
  # be using the existing getter/setter to manipulate it instead.
519
519
  return if !instance_variable_name
520
520
 
521
+ # We deprecate any attempt to create a property that already exists as a
522
+ # method in some Classes that we know would cause our users problems.
523
+ # For example, creating a `hash` property could cause issues when adding
524
+ # a Chef::Resource instance to an data structure that expects to be able
525
+ # to call the `#hash` method and get back an appropriate Fixnum.
526
+ emit_property_redefinition_deprecations
527
+
521
528
  # We prefer this form because the property name won't show up in the
522
529
  # stack trace if you use `define_method`.
523
530
  declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1
@@ -632,6 +639,30 @@ class Chef
632
639
 
633
640
  private
634
641
 
642
+ def emit_property_redefinition_deprecations
643
+ # We only emit deprecations if this property already exists as an instance method.
644
+ # Weeding out class methods avoids unnecessary deprecations such Chef::Resource
645
+ # defining a `name` property when there's an already-existing `name` method
646
+ # for a Module.
647
+ return unless declared_in.instance_methods.include?(name)
648
+
649
+ # Only emit deprecations for some well-known classes. This will still
650
+ # allow more advanced users to subclass their own custom resources and
651
+ # override their own properties.
652
+ return unless [ Object, BasicObject, Kernel, Chef::Resource ].include?(declared_in.instance_method(name).owner)
653
+
654
+ # Allow top-level Chef::Resource proprties, such as `name`, to be overridden.
655
+ # As of this writing, `name` is the only Chef::Resource property created with the
656
+ # `property` definition, but this will allow for future properties to be extended
657
+ # as needed.
658
+ return if Chef::Resource.properties.keys.include?(name)
659
+
660
+ # Emit the deprecation.
661
+ resource_name = declared_in.respond_to?(:resource_name) ? declared_in.resource_name : declared_in
662
+ Chef.deprecated(:property_name_collision, "Property `#{name}` of resource `#{resource_name}` overwrites an existing method. " \
663
+ "Please use a different property name. This will raise an exception in Chef 13.")
664
+ end
665
+
635
666
  def exec_in_resource(resource, proc, *args)
636
667
  if resource
637
668
  if proc.arity > args.size
@@ -37,7 +37,7 @@ class Chef
37
37
  end
38
38
 
39
39
  def flags
40
- @new_resource.flags.nil? ? "/c" : new_resource.flags + " /c"
40
+ new_resource.flags.nil? ? "/c" : new_resource.flags + " /c"
41
41
  end
42
42
 
43
43
  end
@@ -28,7 +28,7 @@ class Chef
28
28
  def action_break
29
29
  if defined?(Shell) && Shell.running?
30
30
  run_context.resource_collection.iterator.pause
31
- @new_resource.updated_by_last_action(true)
31
+ new_resource.updated_by_last_action(true)
32
32
  run_context.resource_collection.iterator
33
33
  end
34
34
  end
@@ -36,15 +36,15 @@ class Chef
36
36
  end
37
37
 
38
38
  def load_current_resource
39
- @current_resource = Chef::Resource::CookbookFile.new(@new_resource.name)
39
+ @current_resource = Chef::Resource::CookbookFile.new(new_resource.name)
40
40
  super
41
41
  end
42
42
 
43
43
  private
44
44
 
45
45
  def managing_content?
46
- return true if @new_resource.checksum
47
- return true if !@new_resource.source.nil? && @action != :create_if_missing
46
+ return true if new_resource.checksum
47
+ return true if !new_resource.source.nil? && @action != :create_if_missing
48
48
  false
49
49
  end
50
50
 
@@ -48,15 +48,15 @@ class Chef
48
48
 
49
49
  def load_current_resource
50
50
  crontab_lines = []
51
- @current_resource = Chef::Resource::Cron.new(@new_resource.name)
52
- @current_resource.user(@new_resource.user)
51
+ @current_resource = Chef::Resource::Cron.new(new_resource.name)
52
+ current_resource.user(new_resource.user)
53
53
  @cron_exists = false
54
54
  if crontab = read_crontab
55
55
  cron_found = false
56
56
  crontab.each_line do |line|
57
57
  case line.chomp
58
- when "# Chef Name: #{@new_resource.name}"
59
- Chef::Log.debug("Found cron '#{@new_resource.name}'")
58
+ when "# Chef Name: #{new_resource.name}"
59
+ Chef::Log.debug("Found cron '#{new_resource.name}'")
60
60
  cron_found = true
61
61
  @cron_exists = true
62
62
  next
@@ -65,18 +65,18 @@ class Chef
65
65
  next
66
66
  when SPECIAL_PATTERN
67
67
  if cron_found
68
- @current_resource.time($2.to_sym)
69
- @current_resource.command($3)
68
+ current_resource.time($2.to_sym)
69
+ current_resource.command($3)
70
70
  cron_found = false
71
71
  end
72
72
  when CRON_PATTERN
73
73
  if cron_found
74
- @current_resource.minute($1)
75
- @current_resource.hour($2)
76
- @current_resource.day($3)
77
- @current_resource.month($4)
78
- @current_resource.weekday($5)
79
- @current_resource.command($6)
74
+ current_resource.minute($1)
75
+ current_resource.hour($2)
76
+ current_resource.day($3)
77
+ current_resource.month($4)
78
+ current_resource.weekday($5)
79
+ current_resource.command($6)
80
80
  cron_found = false
81
81
  end
82
82
  next
@@ -85,18 +85,18 @@ class Chef
85
85
  next
86
86
  end
87
87
  end
88
- Chef::Log.debug("Cron '#{@new_resource.name}' not found") unless @cron_exists
88
+ Chef::Log.debug("Cron '#{new_resource.name}' not found") unless @cron_exists
89
89
  else
90
- Chef::Log.debug("Cron empty for '#{@new_resource.user}'")
90
+ Chef::Log.debug("Cron empty for '#{new_resource.user}'")
91
91
  @cron_empty = true
92
92
  end
93
93
 
94
- @current_resource
94
+ current_resource
95
95
  end
96
96
 
97
97
  def cron_different?
98
98
  CRON_ATTRIBUTES.any? do |cron_var|
99
- @new_resource.send(cron_var) != @current_resource.send(cron_var)
99
+ new_resource.send(cron_var) != current_resource.send(cron_var)
100
100
  end
101
101
  end
102
102
 
@@ -109,12 +109,12 @@ class Chef
109
109
 
110
110
  if @cron_exists
111
111
  unless cron_different?
112
- Chef::Log.debug("Skipping existing cron entry '#{@new_resource.name}'")
112
+ Chef::Log.debug("Skipping existing cron entry '#{new_resource.name}'")
113
113
  return
114
114
  end
115
115
  read_crontab.each_line do |line|
116
116
  case line.chomp
117
- when "# Chef Name: #{@new_resource.name}"
117
+ when "# Chef Name: #{new_resource.name}"
118
118
  cron_found = true
119
119
  next
120
120
  when ENV_PATTERN
@@ -144,18 +144,18 @@ class Chef
144
144
  # Handle edge case where the Chef comment is the last line in the current crontab
145
145
  crontab << newcron if cron_found
146
146
 
147
- converge_by("update crontab entry for #{@new_resource}") do
147
+ converge_by("update crontab entry for #{new_resource}") do
148
148
  write_crontab crontab
149
- Chef::Log.info("#{@new_resource} updated crontab entry")
149
+ Chef::Log.info("#{new_resource} updated crontab entry")
150
150
  end
151
151
 
152
152
  else
153
153
  crontab = read_crontab unless @cron_empty
154
154
  crontab << newcron
155
155
 
156
- converge_by("add crontab entry for #{@new_resource}") do
156
+ converge_by("add crontab entry for #{new_resource}") do
157
157
  write_crontab crontab
158
- Chef::Log.info("#{@new_resource} added crontab entry")
158
+ Chef::Log.info("#{new_resource} added crontab entry")
159
159
  end
160
160
  end
161
161
  end
@@ -166,7 +166,7 @@ class Chef
166
166
  cron_found = false
167
167
  read_crontab.each_line do |line|
168
168
  case line.chomp
169
- when "# Chef Name: #{@new_resource.name}"
169
+ when "# Chef Name: #{new_resource.name}"
170
170
  cron_found = true
171
171
  next
172
172
  when ENV_PATTERN
@@ -187,10 +187,10 @@ class Chef
187
187
  end
188
188
  crontab << line
189
189
  end
190
- description = cron_found ? "remove #{@new_resource.name} from crontab" : "save unmodified crontab"
190
+ description = cron_found ? "remove #{new_resource.name} from crontab" : "save unmodified crontab"
191
191
  converge_by(description) do
192
192
  write_crontab crontab
193
- Chef::Log.info("#{@new_resource} deleted crontab entry")
193
+ Chef::Log.info("#{new_resource} deleted crontab entry")
194
194
  end
195
195
  end
196
196
  end
@@ -199,26 +199,26 @@ class Chef
199
199
 
200
200
  def set_environment_var(attr_name, attr_value)
201
201
  if %w{MAILTO PATH SHELL HOME}.include?(attr_name)
202
- @current_resource.send(attr_name.downcase.to_sym, attr_value.gsub(/^"|"$/, ""))
202
+ current_resource.send(attr_name.downcase.to_sym, attr_value.gsub(/^"|"$/, ""))
203
203
  else
204
- @current_resource.environment(@current_resource.environment.merge(attr_name => attr_value))
204
+ current_resource.environment(current_resource.environment.merge(attr_name => attr_value))
205
205
  end
206
206
  end
207
207
 
208
208
  def read_crontab
209
209
  crontab = nil
210
- status = popen4("crontab -l -u #{@new_resource.user}") do |pid, stdin, stdout, stderr|
210
+ status = popen4("crontab -l -u #{new_resource.user}") do |pid, stdin, stdout, stderr|
211
211
  crontab = stdout.read
212
212
  end
213
213
  if status.exitstatus > 1
214
- raise Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: #{status.exitstatus}"
214
+ raise Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: #{status.exitstatus}"
215
215
  end
216
216
  crontab
217
217
  end
218
218
 
219
219
  def write_crontab(crontab)
220
220
  write_exception = false
221
- status = popen4("crontab -u #{@new_resource.user} -", :waitlast => true) do |pid, stdin, stdout, stderr|
221
+ status = popen4("crontab -u #{new_resource.user} -", :waitlast => true) do |pid, stdin, stdout, stderr|
222
222
  begin
223
223
  stdin.write crontab
224
224
  rescue Errno::EPIPE => e
@@ -228,7 +228,7 @@ class Chef
228
228
  end
229
229
  end
230
230
  if status.exitstatus > 0 || write_exception
231
- raise Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: #{status.exitstatus}"
231
+ raise Chef::Exceptions::Cron, "Error updating state of #{new_resource.name}, exit: #{status.exitstatus}"
232
232
  end
233
233
  end
234
234
 
@@ -236,23 +236,23 @@ class Chef
236
236
  newcron = ""
237
237
  newcron << "# Chef Name: #{new_resource.name}\n"
238
238
  [ :mailto, :path, :shell, :home ].each do |v|
239
- newcron << "#{v.to_s.upcase}=\"#{@new_resource.send(v)}\"\n" if @new_resource.send(v)
239
+ newcron << "#{v.to_s.upcase}=\"#{new_resource.send(v)}\"\n" if new_resource.send(v)
240
240
  end
241
- @new_resource.environment.each do |name, value|
241
+ new_resource.environment.each do |name, value|
242
242
  newcron << "#{name}=#{value}\n"
243
243
  end
244
- if @new_resource.time
245
- newcron << "@#{@new_resource.time} #{@new_resource.command}\n"
244
+ if new_resource.time
245
+ newcron << "@#{new_resource.time} #{new_resource.command}\n"
246
246
  else
247
- newcron << "#{@new_resource.minute} #{@new_resource.hour} #{@new_resource.day} #{@new_resource.month} #{@new_resource.weekday} #{@new_resource.command}\n"
247
+ newcron << "#{new_resource.minute} #{new_resource.hour} #{new_resource.day} #{new_resource.month} #{new_resource.weekday} #{new_resource.command}\n"
248
248
  end
249
249
  newcron
250
250
  end
251
251
 
252
252
  def weekday_in_crontab
253
- weekday_in_crontab = WEEKDAY_SYMBOLS.index(@new_resource.weekday)
253
+ weekday_in_crontab = WEEKDAY_SYMBOLS.index(new_resource.weekday)
254
254
  if weekday_in_crontab.nil?
255
- @new_resource.weekday
255
+ new_resource.weekday
256
256
  else
257
257
  weekday_in_crontab.to_s
258
258
  end
@@ -42,7 +42,7 @@ class Chef
42
42
 
43
43
  # @configuration is not used by Deploy, it is only for backwards compat with
44
44
  # chef-deploy or capistrano hooks that might use it to get environment information
45
- @configuration = @new_resource.to_hash
45
+ @configuration = new_resource.to_hash
46
46
  @configuration[:environment] = @configuration[:environment] && @configuration[:environment]["RAILS_ENV"]
47
47
  end
48
48
 
@@ -52,8 +52,8 @@ class Chef
52
52
 
53
53
  def load_current_resource
54
54
  @scm_provider.load_current_resource
55
- @release_path = @new_resource.deploy_to + "/releases/#{release_slug}"
56
- @shared_path = @new_resource.shared_path
55
+ @release_path = new_resource.deploy_to + "/releases/#{release_slug}"
56
+ @shared_path = new_resource.shared_path
57
57
  end
58
58
 
59
59
  def sudo(command, &block)
@@ -62,10 +62,10 @@ class Chef
62
62
 
63
63
  def run(command, &block)
64
64
  exec = execute(command, &block)
65
- exec.user(@new_resource.user) if @new_resource.user
66
- exec.group(@new_resource.group) if @new_resource.group
65
+ exec.user(new_resource.user) if new_resource.user
66
+ exec.group(new_resource.group) if new_resource.group
67
67
  exec.cwd(release_path) unless exec.cwd
68
- exec.environment(@new_resource.environment) unless exec.environment
68
+ exec.environment(new_resource.environment) unless exec.environment
69
69
  converge_by("execute #{command}") do
70
70
  exec
71
71
  end
@@ -78,8 +78,8 @@ class Chef
78
78
  #There is no reason to assume 2 deployments in a single chef run, hence fails in whyrun.
79
79
  end
80
80
 
81
- [ @new_resource.before_migrate, @new_resource.before_symlink,
82
- @new_resource.before_restart, @new_resource.after_restart ].each do |script|
81
+ [ new_resource.before_migrate, new_resource.before_symlink,
82
+ new_resource.before_restart, new_resource.after_restart ].each do |script|
83
83
  requirements.assert(:deploy, :force_deploy) do |a|
84
84
  callback_file = "#{release_path}/#{script}"
85
85
  a.assertion do
@@ -99,7 +99,7 @@ class Chef
99
99
  save_release_state
100
100
  if deployed?(release_path )
101
101
  if current_release?(release_path )
102
- Chef::Log.debug("#{@new_resource} is the latest version")
102
+ Chef::Log.debug("#{new_resource} is the latest version")
103
103
  else
104
104
  rollback_to release_path
105
105
  end
@@ -116,7 +116,7 @@ class Chef
116
116
  converge_by("delete deployed app at #{release_path} prior to force-deploy") do
117
117
  Chef::Log.info("Already deployed app at #{release_path}, forcing.")
118
118
  FileUtils.rm_rf(release_path)
119
- Chef::Log.info("#{@new_resource} forcing deploy of already deployed app at #{release_path}")
119
+ Chef::Log.info("#{new_resource} forcing deploy of already deployed app at #{release_path}")
120
120
  end
121
121
  end
122
122
 
@@ -142,7 +142,7 @@ class Chef
142
142
 
143
143
  releases_to_nuke.each do |i|
144
144
  converge_by("roll back by removing release #{i}") do
145
- Chef::Log.info "#{@new_resource} removing release: #{i}"
145
+ Chef::Log.info "#{new_resource} removing release: #{i}"
146
146
  FileUtils.rm_rf i
147
147
  end
148
148
  release_deleted(i)
@@ -156,21 +156,21 @@ class Chef
156
156
  copy_cached_repo
157
157
  install_gems
158
158
  enforce_ownership
159
- callback(:before_migrate, @new_resource.before_migrate)
159
+ callback(:before_migrate, new_resource.before_migrate)
160
160
  migrate
161
- callback(:before_symlink, @new_resource.before_symlink)
161
+ callback(:before_symlink, new_resource.before_symlink)
162
162
  symlink
163
- callback(:before_restart, @new_resource.before_restart)
163
+ callback(:before_restart, new_resource.before_restart)
164
164
  restart
165
- callback(:after_restart, @new_resource.after_restart)
165
+ callback(:after_restart, new_resource.after_restart)
166
166
  cleanup!
167
- Chef::Log.info "#{@new_resource} deployed to #{@new_resource.deploy_to}"
167
+ Chef::Log.info "#{new_resource} deployed to #{new_resource.deploy_to}"
168
168
  end
169
169
 
170
170
  def rollback
171
- Chef::Log.info "#{@new_resource} rolling back to previous release #{release_path}"
171
+ Chef::Log.info "#{new_resource} rolling back to previous release #{release_path}"
172
172
  symlink
173
- Chef::Log.info "#{@new_resource} restarting with previous release"
173
+ Chef::Log.info "#{new_resource} restarting with previous release"
174
174
  restart
175
175
  end
176
176
 
@@ -178,7 +178,7 @@ class Chef
178
178
  @collection = Chef::ResourceCollection.new
179
179
  case callback_code
180
180
  when Proc
181
- Chef::Log.info "#{@new_resource} running callback #{what}"
181
+ Chef::Log.info "#{new_resource} running callback #{what}"
182
182
  recipe_eval(&callback_code)
183
183
  when String
184
184
  run_callback_from_file("#{release_path}/#{callback_code}")
@@ -190,17 +190,17 @@ class Chef
190
190
  def migrate
191
191
  run_symlinks_before_migrate
192
192
 
193
- if @new_resource.migrate
193
+ if new_resource.migrate
194
194
  enforce_ownership
195
195
 
196
- environment = @new_resource.environment
196
+ environment = new_resource.environment
197
197
  env_info = environment && environment.map do |key_and_val|
198
198
  "#{key_and_val.first}='#{key_and_val.last}'"
199
199
  end.join(" ")
200
200
 
201
- converge_by("execute migration command #{@new_resource.migration_command}") do
202
- Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}"
203
- shell_out!(@new_resource.migration_command, run_options(:cwd => release_path, :log_level => :info))
201
+ converge_by("execute migration command #{new_resource.migration_command}") do
202
+ Chef::Log.info "#{new_resource} migrating #{new_resource.user} with environment #{env_info}"
203
+ shell_out!(new_resource.migration_command, run_options(:cwd => release_path, :log_level => :info))
204
204
  end
205
205
  end
206
206
  end
@@ -209,18 +209,18 @@ class Chef
209
209
  purge_tempfiles_from_current_release
210
210
  link_tempfiles_to_current_release
211
211
  link_current_release_to_production
212
- Chef::Log.info "#{@new_resource} updated symlinks"
212
+ Chef::Log.info "#{new_resource} updated symlinks"
213
213
  end
214
214
 
215
215
  def restart
216
- if restart_cmd = @new_resource.restart_command
216
+ if restart_cmd = new_resource.restart_command
217
217
  if restart_cmd.kind_of?(Proc)
218
- Chef::Log.info("#{@new_resource} restarting app with embedded recipe")
218
+ Chef::Log.info("#{new_resource} restarting app with embedded recipe")
219
219
  recipe_eval(&restart_cmd)
220
220
  else
221
- converge_by("restart app using command #{@new_resource.restart_command}") do
222
- Chef::Log.info("#{@new_resource} restarting app")
223
- shell_out!(@new_resource.restart_command, run_options(:cwd => @new_resource.current_path))
221
+ converge_by("restart app using command #{new_resource.restart_command}") do
222
+ Chef::Log.info("#{new_resource} restarting app")
223
+ shell_out!(new_resource.restart_command, run_options(:cwd => new_resource.current_path))
224
224
  end
225
225
  end
226
226
  end
@@ -231,10 +231,10 @@ class Chef
231
231
  release_created(release_path)
232
232
  end
233
233
 
234
- chop = -1 - @new_resource.keep_releases
234
+ chop = -1 - new_resource.keep_releases
235
235
  all_releases[0..chop].each do |old_release|
236
236
  converge_by("remove old release #{old_release}") do
237
- Chef::Log.info "#{@new_resource} removing old release #{old_release}"
237
+ Chef::Log.info "#{new_resource} removing old release #{old_release}"
238
238
  FileUtils.rm_rf(old_release)
239
239
  end
240
240
  release_deleted(old_release)
@@ -242,11 +242,11 @@ class Chef
242
242
  end
243
243
 
244
244
  def all_releases
245
- Dir.glob(Chef::Util::PathHelper.escape_glob_dir(@new_resource.deploy_to) + "/releases/*").sort
245
+ Dir.glob(Chef::Util::PathHelper.escape_glob_dir(new_resource.deploy_to) + "/releases/*").sort
246
246
  end
247
247
 
248
248
  def update_cached_repo
249
- if @new_resource.svn_force_export
249
+ if new_resource.svn_force_export
250
250
  # TODO assertion, non-recoverable - @scm_provider must be svn if force_export?
251
251
  svn_force_export
252
252
  else
@@ -259,78 +259,78 @@ class Chef
259
259
  end
260
260
 
261
261
  def svn_force_export
262
- Chef::Log.info "#{@new_resource} exporting source repository"
262
+ Chef::Log.info "#{new_resource} exporting source repository"
263
263
  @scm_provider.run_action(:force_export)
264
264
  end
265
265
 
266
266
  def copy_cached_repo
267
- target_dir_path = @new_resource.deploy_to + "/releases"
267
+ target_dir_path = new_resource.deploy_to + "/releases"
268
268
  converge_by("deploy from repo to #{target_dir_path} ") do
269
269
  FileUtils.rm_rf(release_path) if ::File.exist?(release_path)
270
270
  FileUtils.mkdir_p(target_dir_path)
271
- FileUtils.cp_r(::File.join(@new_resource.destination, "."), release_path, :preserve => true)
272
- Chef::Log.info "#{@new_resource} copied the cached checkout to #{release_path}"
271
+ FileUtils.cp_r(::File.join(new_resource.destination, "."), release_path, :preserve => true)
272
+ Chef::Log.info "#{new_resource} copied the cached checkout to #{release_path}"
273
273
  end
274
274
  end
275
275
 
276
276
  def enforce_ownership
277
- converge_by("force ownership of #{@new_resource.deploy_to} to #{@new_resource.group}:#{@new_resource.user}") do
278
- FileUtils.chown_R(@new_resource.user, @new_resource.group, @new_resource.deploy_to, :force => true)
279
- Chef::Log.info("#{@new_resource} set user to #{@new_resource.user}") if @new_resource.user
280
- Chef::Log.info("#{@new_resource} set group to #{@new_resource.group}") if @new_resource.group
277
+ converge_by("force ownership of #{new_resource.deploy_to} to #{new_resource.group}:#{new_resource.user}") do
278
+ FileUtils.chown_R(new_resource.user, new_resource.group, new_resource.deploy_to, :force => true)
279
+ Chef::Log.info("#{new_resource} set user to #{new_resource.user}") if new_resource.user
280
+ Chef::Log.info("#{new_resource} set group to #{new_resource.group}") if new_resource.group
281
281
  end
282
282
  end
283
283
 
284
284
  def verify_directories_exist
285
- create_dir_unless_exists(@new_resource.deploy_to)
286
- create_dir_unless_exists(@new_resource.shared_path)
285
+ create_dir_unless_exists(new_resource.deploy_to)
286
+ create_dir_unless_exists(new_resource.shared_path)
287
287
  end
288
288
 
289
289
  def link_current_release_to_production
290
- converge_by(["remove existing link at #{@new_resource.current_path}",
291
- "link release #{release_path} into production at #{@new_resource.current_path}"]) do
292
- FileUtils.rm_f(@new_resource.current_path)
290
+ converge_by(["remove existing link at #{new_resource.current_path}",
291
+ "link release #{release_path} into production at #{new_resource.current_path}"]) do
292
+ FileUtils.rm_f(new_resource.current_path)
293
293
  begin
294
- FileUtils.ln_sf(release_path, @new_resource.current_path)
294
+ FileUtils.ln_sf(release_path, new_resource.current_path)
295
295
  rescue => e
296
296
  raise Chef::Exceptions::FileNotFound.new("Cannot symlink current release to production: #{e.message}")
297
297
  end
298
- Chef::Log.info "#{@new_resource} linked release #{release_path} into production at #{@new_resource.current_path}"
298
+ Chef::Log.info "#{new_resource} linked release #{release_path} into production at #{new_resource.current_path}"
299
299
  end
300
300
  enforce_ownership
301
301
  end
302
302
 
303
303
  def run_symlinks_before_migrate
304
- links_info = @new_resource.symlink_before_migrate.map { |src, dst| "#{src} => #{dst}" }.join(", ")
304
+ links_info = new_resource.symlink_before_migrate.map { |src, dst| "#{src} => #{dst}" }.join(", ")
305
305
  converge_by("make pre-migration symlinks: #{links_info}") do
306
- @new_resource.symlink_before_migrate.each do |src, dest|
306
+ new_resource.symlink_before_migrate.each do |src, dest|
307
307
  begin
308
- FileUtils.ln_sf(@new_resource.shared_path + "/#{src}", release_path + "/#{dest}")
308
+ FileUtils.ln_sf(new_resource.shared_path + "/#{src}", release_path + "/#{dest}")
309
309
  rescue => e
310
- raise Chef::Exceptions::FileNotFound.new("Cannot symlink #{@new_resource.shared_path}/#{src} to #{release_path}/#{dest} before migrate: #{e.message}")
310
+ raise Chef::Exceptions::FileNotFound.new("Cannot symlink #{new_resource.shared_path}/#{src} to #{release_path}/#{dest} before migrate: #{e.message}")
311
311
  end
312
312
  end
313
- Chef::Log.info "#{@new_resource} made pre-migration symlinks"
313
+ Chef::Log.info "#{new_resource} made pre-migration symlinks"
314
314
  end
315
315
  end
316
316
 
317
317
  def link_tempfiles_to_current_release
318
- dirs_info = @new_resource.create_dirs_before_symlink.join(",")
319
- @new_resource.create_dirs_before_symlink.each do |dir|
318
+ dirs_info = new_resource.create_dirs_before_symlink.join(",")
319
+ new_resource.create_dirs_before_symlink.each do |dir|
320
320
  create_dir_unless_exists(release_path + "/#{dir}")
321
321
  end
322
- Chef::Log.info("#{@new_resource} created directories before symlinking: #{dirs_info}")
322
+ Chef::Log.info("#{new_resource} created directories before symlinking: #{dirs_info}")
323
323
 
324
- links_info = @new_resource.symlinks.map { |src, dst| "#{src} => #{dst}" }.join(", ")
324
+ links_info = new_resource.symlinks.map { |src, dst| "#{src} => #{dst}" }.join(", ")
325
325
  converge_by("link shared paths into current release: #{links_info}") do
326
- @new_resource.symlinks.each do |src, dest|
326
+ new_resource.symlinks.each do |src, dest|
327
327
  begin
328
- FileUtils.ln_sf(::File.join(@new_resource.shared_path, src), ::File.join(release_path, dest))
328
+ FileUtils.ln_sf(::File.join(new_resource.shared_path, src), ::File.join(release_path, dest))
329
329
  rescue => e
330
- raise Chef::Exceptions::FileNotFound.new("Cannot symlink shared data #{::File.join(@new_resource.shared_path, src)} to #{::File.join(release_path, dest)}: #{e.message}")
330
+ raise Chef::Exceptions::FileNotFound.new("Cannot symlink shared data #{::File.join(new_resource.shared_path, src)} to #{::File.join(release_path, dest)}: #{e.message}")
331
331
  end
332
332
  end
333
- Chef::Log.info("#{@new_resource} linked shared paths into current release: #{links_info}")
333
+ Chef::Log.info("#{new_resource} linked shared paths into current release: #{links_info}")
334
334
  end
335
335
  run_symlinks_before_migrate
336
336
  enforce_ownership
@@ -340,10 +340,10 @@ class Chef
340
340
  end
341
341
 
342
342
  def purge_tempfiles_from_current_release
343
- log_info = @new_resource.purge_before_symlink.join(", ")
343
+ log_info = new_resource.purge_before_symlink.join(", ")
344
344
  converge_by("purge directories in checkout #{log_info}") do
345
- @new_resource.purge_before_symlink.each { |dir| FileUtils.rm_rf(release_path + "/#{dir}") }
346
- Chef::Log.info("#{@new_resource} purged directories in checkout #{log_info}")
345
+ new_resource.purge_before_symlink.each { |dir| FileUtils.rm_rf(release_path + "/#{dir}") }
346
+ Chef::Log.info("#{new_resource} purged directories in checkout #{log_info}")
347
347
  end
348
348
  end
349
349
 
@@ -391,10 +391,10 @@ class Chef
391
391
  end
392
392
 
393
393
  def run_options(run_opts = {})
394
- run_opts[:user] = @new_resource.user if @new_resource.user
395
- run_opts[:group] = @new_resource.group if @new_resource.group
396
- run_opts[:environment] = @new_resource.environment if @new_resource.environment
397
- run_opts[:log_tag] = @new_resource.to_s
394
+ run_opts[:user] = new_resource.user if new_resource.user
395
+ run_opts[:group] = new_resource.group if new_resource.group
396
+ run_opts[:environment] = new_resource.environment if new_resource.environment
397
+ run_opts[:log_tag] = new_resource.to_s
398
398
  run_opts[:log_level] ||= :debug
399
399
  if run_opts[:log_level] == :info
400
400
  if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info?
@@ -405,7 +405,7 @@ class Chef
405
405
  end
406
406
 
407
407
  def run_callback_from_file(callback_file)
408
- Chef::Log.info "#{@new_resource} queueing checkdeploy hook #{callback_file}"
408
+ Chef::Log.info "#{new_resource} queueing checkdeploy hook #{callback_file}"
409
409
  recipe_eval do
410
410
  Dir.chdir(release_path) do
411
411
  from_file(callback_file) if ::File.exist?(callback_file)
@@ -415,20 +415,20 @@ class Chef
415
415
 
416
416
  def create_dir_unless_exists(dir)
417
417
  if ::File.directory?(dir)
418
- Chef::Log.debug "#{@new_resource} not creating #{dir} because it already exists"
418
+ Chef::Log.debug "#{new_resource} not creating #{dir} because it already exists"
419
419
  return false
420
420
  end
421
421
  converge_by("create new directory #{dir}") do
422
422
  begin
423
423
  FileUtils.mkdir_p(dir)
424
- Chef::Log.debug "#{@new_resource} created directory #{dir}"
425
- if @new_resource.user
426
- FileUtils.chown(@new_resource.user, nil, dir)
427
- Chef::Log.debug("#{@new_resource} set user to #{@new_resource.user} for #{dir}")
424
+ Chef::Log.debug "#{new_resource} created directory #{dir}"
425
+ if new_resource.user
426
+ FileUtils.chown(new_resource.user, nil, dir)
427
+ Chef::Log.debug("#{new_resource} set user to #{new_resource.user} for #{dir}")
428
428
  end
429
- if @new_resource.group
430
- FileUtils.chown(nil, @new_resource.group, dir)
431
- Chef::Log.debug("#{@new_resource} set group to #{@new_resource.group} for #{dir}")
429
+ if new_resource.group
430
+ FileUtils.chown(nil, new_resource.group, dir)
431
+ Chef::Log.debug("#{new_resource} set group to #{new_resource.group} for #{dir}")
432
432
  end
433
433
  rescue => e
434
434
  raise Chef::Exceptions::FileNotFound.new("Cannot create directory #{dir}: #{e.message}")
@@ -439,7 +439,7 @@ class Chef
439
439
  def with_rollback_on_error
440
440
  yield
441
441
  rescue ::Exception => e
442
- if @new_resource.rollback_on_error
442
+ if new_resource.rollback_on_error
443
443
  Chef::Log.warn "Error on deploying #{release_path}: #{e.message}"
444
444
  failed_release = release_path
445
445
 
@@ -458,8 +458,8 @@ class Chef
458
458
  end
459
459
 
460
460
  def save_release_state
461
- if ::File.exists?(@new_resource.current_path)
462
- release = ::File.readlink(@new_resource.current_path)
461
+ if ::File.exists?(new_resource.current_path)
462
+ release = ::File.readlink(new_resource.current_path)
463
463
  @previous_release_path = release if ::File.exists?(release)
464
464
  end
465
465
  end