Can conditional "OR" operator be syntactically indented similar to the "AND" operator?

23 views
Skip to first unread message

burn...@umn.edu

unread,
Nov 21, 2016, 1:20:02 PM11/21/16
to Ansible Project
Hello -

Can the conditional "OR" operator be syntactically indented similar to the "AND" operator?

"AND" can be written in either of these ways: 
Source
when: django_migration_result|changed and ('Applying auth.0001_initial... OK' in django_migration_result.stdout)
or
when:
- django_migration_result | changed 
 - 'Applying auth.0001_initial... OK' in django_migration_result.stdout 

"OR" can be written as:
  failed_when: expect_output.stdout | search("(ORA|SP2)-[0-9]+") or expect_output.stdout | search("Usage")
but I can't get the below attempt to work.
  failed_when: 
    - expect_output.stdout | search("(ORA|SP2)-[0-9]+") or
    - expect_output.stdout | search("Usage")


Thoughts? 

Brian Coca

unread,
Nov 22, 2016, 10:13:24 AM11/22/16
to ansible...@googlegroups.com
Not that way but you can use YAML multiline

failed_when: >
   expect_output.stdout | search("(ORA|SP2)-[0-9]+") or
   expect_output.stdout | search("Usage")


​The lis​t notation is just that, a list of conditionals which all must be true , which ends up being an implicit AND.


----------
Brian Coca
Message has been deleted

burn...@umn.edu

unread,
Nov 22, 2016, 12:51:34 PM11/22/16
to Ansible Project
Thanks Brian! That YAML multiline notation worked out wonderfully for this. Thanks for educating me!
Reply all
Reply to author
Forward
0 new messages