From 99526e05e693f6df2fdc827d530f3a2cdf591f9a Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 9 Feb 2022 08:03:37 +0000 Subject: [PATCH] Rejig template parts It is not uncommon for a service to need to reference external connection strings in configuration files sections other than the standard [identity], [database] etc. This change makes the connection strings referencable without the section heading. --- .../shared_code/templates/parts/database-connection | 3 +++ .../shared_code/templates/parts/identity-connection | 10 ++++++++++ .../shared_code/templates/parts/section-database | 6 +----- .../shared_code/templates/parts/section-identity | 11 +---------- 4 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 ops-sunbeam/shared_code/templates/parts/database-connection create mode 100644 ops-sunbeam/shared_code/templates/parts/identity-connection diff --git a/ops-sunbeam/shared_code/templates/parts/database-connection b/ops-sunbeam/shared_code/templates/parts/database-connection new file mode 100644 index 00000000..d88c10b2 --- /dev/null +++ b/ops-sunbeam/shared_code/templates/parts/database-connection @@ -0,0 +1,3 @@ +{% if shared_db.database_host -%} +connection = {{ shared_db.database_type }}://{{ shared_db.database_user }}:{{ shared_db.database_password }}@{{ shared_db.database_host }}/{{ shared_db.database }}{% if shared_db.database_ssl_ca %}?ssl_ca={{ shared_db.database_ssl_ca }}{% if shared_db.database_ssl_cert %}&ssl_cert={{ shared_db.database_ssl_cert }}&ssl_key={{ shared_db.database_ssl_key }}{% endif %}{% endif %} +{% endif -%} diff --git a/ops-sunbeam/shared_code/templates/parts/identity-connection b/ops-sunbeam/shared_code/templates/parts/identity-connection new file mode 100644 index 00000000..4b4af021 --- /dev/null +++ b/ops-sunbeam/shared_code/templates/parts/identity-connection @@ -0,0 +1,10 @@ +{% if identity_service.internal_host -%} +www_authenticate_uri = {{ identity_service.internal_protocol }}://{{ identity_service.internal_host }}:{{ identity_service.internal_port }} +auth_url = {{ identity_service.internal_protocol }}://{{ identity_service.internal_host }}:{{ identity_service.internal_port }} +auth_type = password +project_domain_name = {{ identity_service.service_domain_name }} +user_domain_name = {{ identity_service.service_domain_name }} +project_name = {{ identity_service.service_project_name }} +username = {{ identity_service.service_user_name }} +password = {{ identity_service.service_password }} +{% endif -%} diff --git a/ops-sunbeam/shared_code/templates/parts/section-database b/ops-sunbeam/shared_code/templates/parts/section-database index e9062346..986d9b10 100644 --- a/ops-sunbeam/shared_code/templates/parts/section-database +++ b/ops-sunbeam/shared_code/templates/parts/section-database @@ -1,7 +1,3 @@ [database] -{% if shared_db.database_host -%} -connection = {{ shared_db.database_type }}://{{ shared_db.database_user }}:{{ shared_db.database_password }}@{{ shared_db.database_host }}/{{ shared_db.database }}{% if shared_db.database_ssl_ca %}?ssl_ca={{ shared_db.database_ssl_ca }}{% if shared_db.database_ssl_cert %}&ssl_cert={{ shared_db.database_ssl_cert }}&ssl_key={{ shared_db.database_ssl_key }}{% endif %}{% endif %} -{% else -%} -connection = sqlite:////var/lib/cinder/cinder.db -{% endif -%} +{% include "parts/database-connection" %} connection_recycle_time = 200 diff --git a/ops-sunbeam/shared_code/templates/parts/section-identity b/ops-sunbeam/shared_code/templates/parts/section-identity index cda360f7..ad591939 100644 --- a/ops-sunbeam/shared_code/templates/parts/section-identity +++ b/ops-sunbeam/shared_code/templates/parts/section-identity @@ -1,11 +1,2 @@ [keystone_authtoken] -{% if identity_service.internal_host -%} -www_authenticate_uri = {{ identity_service.internal_protocol }}://{{ identity_service.internal_host }}:{{ identity_service.internal_port }} -auth_url = {{ identity_service.internal_protocol }}://{{ identity_service.internal_host }}:{{ identity_service.internal_port }} -auth_type = password -project_domain_name = {{ identity_service.service_domain_name }} -user_domain_name = {{ identity_service.service_domain_name }} -project_name = {{ identity_service.service_project_name }} -username = {{ identity_service.service_user_name }} -password = {{ identity_service.service_password }} -{% endif -%} +{% include "parts/identity-connection" %}