I have this role (roles/dummy/tasks/main.yml) :
and this playbook (test.yml) :
---
- hosts: localhost
vars:
name: "{{ foo_name | default('boom') }}"
tasks:
- debug: var=name
roles:
- { role: dummy, dum_name: "{{ name }}" }
If I define a variable "foo_name=bar" in the inventory file for localhost , I get this output :
TASK: [dummy | debug var=dum_name] ********************************************
ok: [localhost] => {
"var": {
"dum_name": "boom"
}
}
TASK: [debug var=name] ********************************************************
ok: [localhost] => {
"var": {
"name": "bar"
}
}
In the dummy task, I expected : "dum_name": "bar" .
In a real application, I need to use several times a same role with different parameters. A simple way to get the same thing is :
...
roles:
- { role: dummy, dum_name: "{{ foo_name | default('boom') }}" }
but the problem is the same : I get "boom" in the result instead of "bar" .
What is the solution/workaround ?
Regards,
Fabien