|
22 | 22 | require 'chef/mixin/language'
|
23 | 23 | include Chef::Mixin::ShellOut
|
24 | 24 |
|
| 25 | +def whyrun_supported? |
| 26 | + true |
| 27 | +end |
| 28 | + |
25 | 29 | # the logic in all action methods mirror that of
|
26 | 30 | # the Chef::Provider::Package which will make
|
27 | 31 | # refactoring into core chef easy
|
|
42 | 46 | end
|
43 | 47 |
|
44 | 48 | if install_version
|
45 |
| - Chef::Log.info("Installing #{@new_resource} version #{install_version}") |
46 |
| - status = install_package(@new_resource.package_name, install_version, timeout) |
47 |
| - if status |
48 |
| - @new_resource.updated_by_last_action(true) |
| 49 | + description = "install package #{@new_resource} version #{install_version}" |
| 50 | + converge_by(description) do |
| 51 | + Chef::Log.info("Installing #{@new_resource} version #{install_version}") |
| 52 | + status = install_package(@new_resource.package_name, install_version, timeout) |
49 | 53 | end
|
50 | 54 | end
|
51 | 55 | end
|
|
59 | 63 |
|
60 | 64 | if @current_resource.version != candidate_version
|
61 | 65 | orig_version = @current_resource.version || "uninstalled"
|
62 |
| - Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}") |
63 |
| - status = upgrade_package(@new_resource.package_name, candidate_version, timeout) |
64 |
| - if status |
65 |
| - @new_resource.updated_by_last_action(true) |
| 66 | + description = "upgrade #{@current_resource} version from #{@current_resource.version} to #{candidate_version}" |
| 67 | + converge_by(description) do |
| 68 | + Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}") |
| 69 | + status = upgrade_package(@new_resource.package_name, candidate_version, timeout) |
66 | 70 | end
|
67 | 71 | end
|
68 | 72 | end
|
|
75 | 79 | end
|
76 | 80 |
|
77 | 81 | if removing_package?
|
78 |
| - Chef::Log.info("Removing #{@new_resource}") |
79 |
| - remove_package(@current_resource.package_name, @new_resource.version, timeout) |
80 |
| - @new_resource.updated_by_last_action(true) |
| 82 | + description = "remove package #{@new_resource}" |
| 83 | + converge_by(description) do |
| 84 | + Chef::Log.info("Removing #{@new_resource}") |
| 85 | + remove_package(@current_resource.package_name, @new_resource.version, timeout) |
| 86 | + end |
81 | 87 | else
|
82 | 88 | end
|
83 | 89 | end
|
|
0 commit comments