Information Technology Reference
In-Depth Information
action :nothing
end
end
Then add the notifies attribute as follows. The notifies attribute takes three parameters:
an action, the name of the resource to notify, and a timer indicating when the action should
be perform. As shown in the following code block, we want to perform the :run action on
the execute[reconfigure-chef-server] resource, and we want the action performed
:immediately . For more information on notifies parameters, refer to the Chef documenta-
tion :
package package_name ddo
source package_local_path
provider Chef : :Provider :: Package : :Rpm
notifies :run , 'execute[reconfigure-chef-server]' , :immediately
end
end
Example 9-4 shows what the final version of our idempotent code looks like.
Example 9-4. chefdk/chef-repo/cookbooks/enterprise-chef/recipes/default.rb
# Cookbook Name:: enterprise-chef
# Recipe:: default
#
# Copyright (C) 2014
#
#
#
package_url = node [ 'enterprise-chef' ][ 'url' ]
package_name = :: File . basename ( package_url )
package_local_path = " #{ Chef : :Config [ :file_cache_path ] } / #{ package_name } "
# omnibus_package is remote (i.e., a URL) let's download it
remote_file package_local_path ddo
source package_url
end
end
package package_name ddo
source package_local_path
provider Chef : :Provider :: Package : :Rpm
notifies :run , 'execute[reconfigure-chef-server]' , :immediately
end
end
Search WWH ::




Custom Search