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 e992fe173337d93f5a0902907d562b1e73960ee3..1c0ef28bb0def8d015ac38c814da230384cee40b 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 %}