From 83f64a7ff93305c9ab287aaec2c5300a238897aa Mon Sep 17 00:00:00 2001 From: jhchong92 Date: Fri, 10 Sep 2021 01:04:11 +0800 Subject: [PATCH] Bugfix/cinder csi cloud config template (#7955) * Fix invalid condition for username and password inclusion * Use length filter to test variable conditions --- .../templates/cinder-csi-cloud-config.j2 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2 b/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2 index e992fe173..1c0ef28bb 100644 --- a/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2 +++ b/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2 @@ -1,31 +1,31 @@ [Global] auth-url="{{ cinder_auth_url }}" -{% if cinder_application_credential_id is not defined and cinder_application_credential_name is not defined %} +{% if cinder_application_credential_id|length == 0 and cinder_application_credential_name|length == 0 %} username="{{ cinder_username }}" password="{{ cinder_password }}" {% endif %} -{% if cinder_application_credential_id is defined and cinder_application_credential_id != "" %} +{% if cinder_application_credential_id|length > 0 %} application-credential-id={{ cinder_application_credential_id }} {% endif %} -{% if cinder_application_credential_name is defined and cinder_application_credential_name != "" %} +{% if cinder_application_credential_name|length > 0 %} application-credential-name={{ cinder_application_credential_name }} {% endif %} -{% if cinder_application_credential_secret is defined and cinder_application_credential_secret != "" %} +{% if cinder_application_credential_secret|length > 0 %} application-credential-secret={{ cinder_application_credential_secret }} {% endif %} region="{{ cinder_region }}" -{% if cinder_tenant_id is defined and cinder_tenant_id != "" %} +{% if cinder_tenant_id|length > 0 %} tenant-id="{{ cinder_tenant_id }}" {% endif %} -{% if cinder_tenant_name is defined and cinder_tenant_name != "" %} +{% if cinder_tenant_name|length > 0 %} tenant-name="{{ cinder_tenant_name }}" {% endif %} -{% if cinder_domain_name is defined and cinder_domain_name != "" %} +{% if cinder_domain_name|length > 0 %} domain-name="{{ cinder_domain_name }}" -{% elif cinder_domain_id is defined and cinder_domain_id != "" %} +{% elif cinder_domain_id|length > 0 %} domain-id ="{{ cinder_domain_id }}" {% endif %} -{% if cinder_cacert is defined and cinder_cacert != "" %} +{% if cinder_cacert|length > 0 %} ca-file="{{ kube_config_dir }}/cinder-cacert.pem" {% endif %}