Reputation: 5146
I have an Ansible task in which I am using variables - window
and total_files
. And I am passing these two variable values from the command line:
- name: Check all files
find: paths=/var/lib/goldy/jobs/processdata/workspace/files
file_type=file
age=-{{ window }}m
age_stamp=mtime
register: files
failed_when: files.matched < total_files
Here is how I am running:
ansible-playbook -e 'host_key_checking=False' -e 'total_files=6' -e 'window=10' abc.yml
But somehow my total_files
variable is not working at all with failed_when
module. I tried all the combinations I can think of but if I use "{{ total_files }}"
like this then I am getting warning so that's why I started using total_files
like this but still it doesn't work. Any thoughts on what I am doing wrong?
[WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: files.matched < "{{ total_files }}"
Upvotes: 0
Views: 1484
Reputation: 68459
And I am passing these two variable value from the command line
So you are passing strings, hence you compare files.matched
to a string value.
Change to:
failed_when: files.matched < total_files | int
The warning you posted is irrelevant to the root problem.
Upvotes: 1