I have the following playbook working in Ansible 1.9, where in i like to include a play at run time based on variable passed either as command line argument or declared under ‘vars’.
- name: include another play
vars:
var_name_1: var_value_1
var_name_2: var_value_2
include: "code/folder/{{ var_name_1 }}.yml"
The playbook included the play inside the file ‘code/folder/var_value_1.yml’ successfully. However the same play book throws the following error in Ansible 2.0
ERROR! the file_name ‘code/folder/{{ var_name_1 }}.yml’ does not exist, or is not readable
As i understand, Ansible 2.0 is not able to interpolate filenames with variables.
The same issue exists for ‘vars_files’ also, for which i used the ‘include_vars’ under ‘tasks’ as a workaround to include var files at runtime.
Questions:
-
Why was this feature removed or excluded, assuming my code is valid for 2.0?
-
What are the options for including a play at runtime in Ansible 2.0?
posted from http://stackoverflow.com/questions/33623050/ansible-2-0-interpolate-filenames-with-variables