Parts of a template filename is not replaced by the variable:
- action: template src=templates/$product_settings.j2 dest=
$reg_settings_data
fatal: [10.101.1.147] => {'msg': "[Errno 2] No such file or directory:
u'templates/$product_settings.j2'", 'failed': True}
Hi,
Sorry, can’t help you with this unless we see enough of the playbook and enough of the inventory file to see where this is being set.
There are no known issues with basic variable substitution.
The Var is just set before:
vars:
product: myproduct
Problem is the template filename really is only a part:
$product_settings.j2
to:
myproduct_settings.j2
Similar thing is with an include statement using the var within the
filename:
# config
- include: tasks/$product.yml
You need to do this then, since it is part of another string:
${product}_settings.j2 … OR (jinja2 syntax)
{{ product }}_settings.j2
Yes, that ${product}_settings.j2 works with the template
Thanks !