-
Notifications
You must be signed in to change notification settings - Fork 63
Description
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 :
clusters:
- name: "{{ cdp_cluster_name }}"
type: base
services: "{{ cdp_services }}"
databases: "{{ cdp_databases }}"
configs: "{{ fresh_install_configs }}"
host_templates: "{{ cdp_host_templates }}"
...
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 here
Solution :
Use include_vars
instead of lookup(file...)