breakpoint
Use the breakpoint resource to add breakpoints to recipes. Run the chef-shell in chef-client mode, and then use those breakpoints to debug recipes. Breakpoints are ignored by the chef-client during an actual chef-client run. That said, breakpoints are typically used to debug recipes only when running them in a non-production environment, after which they are removed from those recipes before the parent cookbook is uploaded to the Chef server.
Syntax
A breakpoint resource block creates a breakpoint in a recipe:
breakpoint 'name' do action :break end
where
-
:break
will tell the chef-client to stop running a recipe; can only be used when the chef-client is being run in chef-shell mode
Actions
This resource has the following actions:
:break
- Use to add a breakpoint to a recipe.
:nothing
- Define this resource block to do nothing until notified by another resource to take action. When this resource is notified, this resource block is either run immediately or it is queued up to be run at the end of the chef-client run.
Properties
This resource does not have any properties.
Examples
The following examples demonstrate various approaches for using resources in recipes. If you want to see examples of how Chef uses resources in recipes, take a closer look at the cookbooks that Chef authors and maintains: https://github.com/chef-cookbooks.
A recipe without a breakpoint
yum_key node['yum']['elrepo']['key'] do url node['yum']['elrepo']['key_url'] action :add end yum_repository 'elrepo' do description 'ELRepo.org Community Enterprise Linux Extras Repository' key node['yum']['elrepo']['key'] mirrorlist node['yum']['elrepo']['url'] includepkgs node['yum']['elrepo']['includepkgs'] exclude node['yum']['elrepo']['exclude'] action :create end
The same recipe with breakpoints
breakpoint "before yum_key node['yum']['repo_name']['key']" do action :break end yum_key node['yum']['repo_name']['key'] do url node['yum']['repo_name']['key_url'] action :add end breakpoint "after yum_key node['yum']['repo_name']['key']" do action :break end breakpoint "before yum_repository 'repo_name'" do action :break end yum_repository 'repo_name' do description 'description' key node['yum']['repo_name']['key'] mirrorlist node['yum']['repo_name']['url'] includepkgs node['yum']['repo_name']['includepkgs'] exclude node['yum']['repo_name']['exclude'] action :create end breakpoint "after yum_repository 'repo_name'" do action :break end
where the name of each breakpoint is an arbitrary string. In the previous examples, the names are used to indicate if the breakpoint is before or after a resource, and then also to specify which resource.
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs-archive.chef.io/release/12-13/resource_breakpoint.html