Created
December 5, 2013 19:35
-
-
Save imlucas/7812280 to your computer and use it in GitHub Desktop.
How to use converge_by in Chef LWRP's. This is from an app cookbook I forked from the main opscode application cookbook but stripped way down.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action :deploy do | |
before_compile | |
before_deploy | |
run_deploy | |
new_resource.updated_by_last_action(true) | |
end | |
protected | |
def install_packages | |
converge_by("install app packages (#{new_resource.packages.length})") do | |
new_resource.packages.each do |pkg| | |
Chef::Log.warn "Install #{pkg}" | |
package pkg do | |
action :install | |
end | |
end | |
end | |
end | |
def before_compile | |
install_packages | |
new_resource.app_provider self | |
if new_resource.before_compile | |
ruby_block "#{new_resource.name} before_compile" do | |
block do | |
callback(:before_compile, new_resource.before_deploy) | |
end | |
end | |
end | |
converge_by("run subresource before_compile hooks (#{new_resource.sub_resources.length})") do | |
new_resource.sub_resources.each do |resource| | |
resource.app_provider self | |
resource.run_action :before_compile | |
end | |
end | |
end | |
def before_deploy | |
verify_directories_exist | |
if new_resource.before_deploy | |
ruby_block "#{new_resource.name} before_deploy" do | |
block do | |
callback(:before_deploy, new_resource.before_deploy) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you sure you need
converge_by
blocks here?