# skip role if condition are not meet

**URL:** <https://forum.ansible.com/t/skip-role-if-condition-are-not-meet/33639>\
**Category:** Ansible Project\
**Created:** [August 19, 2020, 10:39am UTC](https://forum.ansible.com/t/skip-role-if-condition-are-not-meet/33639 "2020-08-19T10:39:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![morten\_hoffmann](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@morten\_hoffmann](https://forum.ansible.com/u/morten_hoffmann)\
**Post date:** [August 19, 2020, 10:39am UTC](https://forum.ansible.com/t/skip-role-if-condition-are-not-meet/33639/1 "2020-08-19T10:39:53Z")

</div>

hi  
I need to skip a role in my playbook if a server doesn’t exist inside hosts file  
hosts file:

[webserver]  
server1.domain  
server2.domain

[machine01]  
server1.domain

[machine02]  
server2.domain

play:

- name: Scaling out the cluster  
hosts: webserver  
tags: scaleout  
roles:
- scalingout

role:

# tasks file for scalingoutcluster

- name: Checking if there exist a cluster. If not, skip this tasks

# when: scale\_cluster == true

# when: ‘inventory\_secondary\_node|string in group\_names’

# when: inventory\_hostname == machine02

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [August 24, 2020, 6:11am UTC](https://forum.ansible.com/t/skip-role-if-condition-are-not-meet/33639/2 "2020-08-24T06:11:19Z")

</div>

Can you try this?

&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;- name: Test1  
&nbsp;&nbsp;&nbsp;&nbsp;include\_role:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: scaling\_out  
&nbsp;&nbsp;&nbsp;&nbsp;when: some condition
