cloudera-labs / cloudera-deploy

A general purpose framework for automating Cloudera Products
Apache License 2.0
63 stars 61 forks source link

Improve definition file loading #94

Closed anisf closed 1 year ago

anisf commented 1 year ago

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...)

Chaffelson commented 1 year ago

Fixed in #95