# Break up long conditional statement?

**URL:** <https://forum.ansible.com/t/break-up-long-conditional-statement/27974>\
**Category:** Ansible Developer\
**Created:** [July 6, 2018, 5:29pm UTC](https://forum.ansible.com/t/break-up-long-conditional-statement/27974 "2018-07-06T17:29:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![burvilwork2](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@burvilwork2](https://forum.ansible.com/u/burvilwork2)\
**Post date:** [July 6, 2018, 5:29pm UTC](https://forum.ansible.com/t/break-up-long-conditional-statement/27974/1 "2018-07-06T17:29:31Z")

</div>

I currently have this in a playbook:

- block:  
&nbsp;&nbsp;- name: checking values  
&nbsp;&nbsp;&nbsp;&nbsp;fail: msg="failure here"  
&nbsp;&nbsp;&nbsp;&nbsp;when: ( ( application is not defined) or ( application == "") or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( component is not defined) or ( component == "") or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( env is not defined) or ( env == "") or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( owner is not defined) or (owner == "") or (owner\_check == "") )

and a colleague mentioned that it would be better from a performance perspective to break it up into smaller tasks. Is that true? Is there a rule of thumb, e.g. depending on how long the conditional statement is, on whether to break it up or not?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 6, 2018, 7:13pm UTC](https://forum.ansible.com/t/break-up-long-conditional-statement/27974/2 "2018-07-06T19:13:59Z")

</div>

Not sure if faster, but this looks a bit cleaner:

&nbsp;&nbsp;&nbsp;&nbsp;when: application|default(False) or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;component\>default(False) or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;env\>default(False) or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner\>default(False) or  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"" in (application, component, env, owner, owner\_check)
