-
-
Save aalmenar/9a15a997bce4fd9c1506c4f3074cf951 to your computer and use it in GitHub Desktop.
Figure if a resource exists or not in Chef before notifying it
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
resource_not_found = {} | |
begin | |
resources('ruby_block[my-resource-supposed-to-exist]') | |
rescue Chef::Exceptions::ResourceNotFound | |
resource_not_found['ruby_block[my-resource-supposed-to-exist]'] = true | |
end | |
template '/etc/my/template.conf' do | |
source 'template.conf.erb' | |
mode '640' | |
notifies :run, 'ruby_block[my-resource-supposed-to-exist]' unless resource_not_found['ruby_block[my-resource-supposed-to-exist]'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment