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

**URL:** <https://discourse.chef.io/t/how-can-i-skip-a-resource-and-jump-to-rest-of-the-recipe/10995>\
**Category:** Chef Infra (archive)\
**Created:** [June 12, 2017, 7:46am UTC](https://discourse.chef.io/t/how-can-i-skip-a-resource-and-jump-to-rest-of-the-recipe/10995 "2017-06-12T07:46:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChefLearner](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@ChefLearner](https://discourse.chef.io/u/ChefLearner)\
**Post date:** [June 12, 2017, 7:46am UTC](https://discourse.chef.io/t/how-can-i-skip-a-resource-and-jump-to-rest-of-the-recipe/10995/1 "2017-06-12T07:46:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nic\_chef](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@nic\_chef](https://discourse.chef.io/u/nic_chef)\
**Post date:** [June 21, 2017, 1:24pm UTC](https://discourse.chef.io/t/how-can-i-skip-a-resource-and-jump-to-rest-of-the-recipe/10995/2 "2017-06-21T13:24:55Z")

</div>

[https://docs.chef.io/resource\_common.html](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.
