How can I skip a resource and jump to rest of the recipe?


I have used a bash resource with if… else loop
If “if” loop is getting executed, I want recipe to continue as written (next step is include_recipe )
which is happening now.

But if it goes to “else” loop I don’t want to execute next step of include_recipe. Want to skip that step and move to the next resource execution

how can I achieve that?


bash ‘Host registration with server’ do
cwd node[‘local’][‘download_dir’]
sensitive true
user "root"
code <<-EOH
# Login to server
<<<< steps to login to to server and check IP address >>

if [ $? != 0 ]
	<<< check if host IP is not present then do registration>>


no action … need to skip next step of include_recipe 'gde_client"

# Logout from server
./vmssc logout server	


Invoke addGPtoHost recipe if guard point exists

if node[‘guardPointsList’].strip != ""
include_recipe 'gde_client::addGPtoHost’

( This recipe need to be executed only for “if” loop in bash resource or else skip and move to next part of execution)

How can I achieve that?


The following properties can be used to define a guard that is evaluated during the execution phase of the chef-client run:
Prevent a resource from executing when the condition returns true.
Allow a resource to execute only if the condition returns true.