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?

Snippet:

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 ]
then
  
	<<< check if host IP is not present then do registration>>

else

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

fi
	
# Logout from server
./vmssc logout server	

EOH
end

Invoke addGPtoHost recipe if guard point exists

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

( 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?

https://docs.chef.io/resource_common.html

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