# Need assistance in using 'OR' condition with  regex\_findall

**URL:** <https://forum.ansible.com/t/need-assistance-in-using-or-condition-with-regex-findall/34959>\
**Category:** Ansible Project\
**Created:** [April 11, 2021, 1:31pm UTC](https://forum.ansible.com/t/need-assistance-in-using-or-condition-with-regex-findall/34959 "2021-04-11T13:31:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [April 11, 2021, 1:31pm UTC](https://forum.ansible.com/t/need-assistance-in-using-or-condition-with-regex-findall/34959/1 "2021-04-11T13:31:53Z")

</div>

Hi,

Below condition in statement 1 and 2 checks the number of boot statement set in switch matches with number of member switches available to ensure that correct boot statement is set for every member switch. Both statement 1 and 2 work when i give them individually.  
But they fail when i use to it in assert statement as ‘OR’ conditional. How should i modify the syntax to make it work?

Statament 1:  
show\_boot\_new.stdout[0] | regex\_findall(‘BOOT variable = flash:packages.conf’) | length == show\_switch.stdout[0] | regex\_findall(‘Ready’) | length

Statement 2:  
show\_boot\_new.stdout[0] | regex\_findall(‘BOOT variable = flash:cat3k\_caa-universalk9.16.09.06.SPA.conf’) | length == show\_switch.stdout[0] | regex\_findall(‘Ready’) | length

- assert:  
that:
- show\_boot\_new.stdout[0] | regex\_findall(‘BOOT variable = flash:packages.conf’) | length == show\_switch.stdout[0] | regex\_findall(‘Ready’) | length **or**  
show\_boot\_new.stdout[0] | regex\_findall(‘BOOT variable = flash:cat3k\_caa-universalk9.16.09.06.SPA.conf’) | length == show\_switch.stdout[0] | regex\_findall(‘Ready’) | length  
fail\_msg: “BOOT STATEMENT IS NOT SET FOR ALL MEMBERS SWITCHES. PLAYBOOK IS ENDING FOR HOST.”  
success\_msg: “BOOT STATEMENT IS SET FOR ALL MEMBER SWITCHES”

Thanks,  
Vikram

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [April 11, 2021, 1:42pm UTC](https://forum.ansible.com/t/need-assistance-in-using-or-condition-with-regex-findall/34959/2 "2021-04-11T13:42:12Z")

</div>

1 more update:

i tried the ‘OR’ conditional in several different formats as given in ansible documentation but nothing works. Let me know if you know of a syntax that can make OR condition to work withj regex\_findall as given above.

Thanks,  
Vikram
