Reputation: 11
What I am trying to achieve is something like following
vars_files: - "{{ 'vars/vars.yml' if condition==True else 'vars/vars1.yml' }}"
Can someone help me with the correct syntax?
Upvotes: 1
Views: 3097
Reputation: 394
You can do something like this:
vars_files:
- vars/{{ 'vars' if condition==True else 'vars1' }}.yml
Upvotes: 1
Reputation: 68034
vars_files is a playbook keyword. The conditions can't be applied to keywords. Instead, an option would be using include_vars which is a task. For example
- hosts: all
tasks:
- include_vars: vars/vars1.yml
when: condition|bool
Notes
Upvotes: 4