I began to have a huge unreadable definition file, so i wanted to use ansible variables.
I discovered that the definition file was loaded as a simple file, parsed as-is, in yaml. That means variables won't be interpreted (i.e. host_templates: "{{ cdp_host_templates }}" will be interpred as string : "{{ cdp_host_templates }}")
Using variables in the defintion file raises an error due to a check done on the host_templates here
The error message is : Unable to host template {{ host_template }} in the cluster definition
This check is trying to find a host template named 'xxx' in : host_templates: "{{ host_templates }}" and fails because it is interpreted as a string...
The tasks reponsible for this is here
Context :
I began to have a huge unreadable definition file, so i wanted to use ansible variables. I discovered that the definition file was loaded as a simple file, parsed as-is, in yaml. That means variables won't be interpreted (i.e.
host_templates: "{{ cdp_host_templates }}"
will be interpred as string :"{{ cdp_host_templates }}"
)My definition file looks like this :
Issue :
Using variables in the defintion file raises an error due to a check done on the host_templates here
The error message is :
Unable to host template {{ host_template }} in the cluster definition
This check is trying to find a host template named 'xxx' in :
host_templates: "{{ host_templates }}"
and fails because it is interpreted as a string... The tasks reponsible for this is hereSolution :
Use
include_vars
instead oflookup(file...)