[WARNING]: It is unnecessary to use '{{' in conditionals, leave variables in loop expressions bare.
I'm using with_items for conditions in the fail module and it seems that I can't use bare expressions. I have a playbook that with actions that can only run if a number of pre-conditions have been met. Instead of defining N tasks to grep in a file I'm stashing the contents of the file and using multiple search conditions.
Is there a different/better way to do this type of testing?
Is there some way to do this without dereferenceing
---
- hosts: 127.0.0.1
vars:
truthy_string: This message contains the truth
connection: local
tasks:
- name: test
fail:
msg: "{{ item.msg }}"
with_items:
- { test: True != True, msg: The truth is still truthy }
- { test: True != False, msg: The truth is out there }
# Indicative of the actual statements I'm using
- { test: truthy_string | search('the truth') == False, msg: It is true}
# Dereferenced variables work but present a warning
when: "{{ item.test }}"
# Bare variables fail every time
#when: item.test
--
Shawn