Ansible 1.9.2 version.
Does Ansible supports variable expansion within a variable while evaluating it.
I have a task to download 3 zip files from Artifactory
It does.
You can use
set_fact:
variable: '{{ vars['my_' + variablename + '_variable'] }}'
the only downside of this approach so far is, it won't dynamically expand variables that get the value of another variable. an example:
roles/xxx/defaults/main.yml:
var1: foo
var2: '{{ var1 }}'
This, unfortunately will not work when trying to use the resolved value in var2. Hence,
- debug: msg='{{ vars["var2"] }}'
will output {{ var1 }} instead of foo.
In your vars declaration, instead of using var2: {{ var1 }}, use var2: '{{ vars["var1"] }}'. That way, it will work.