From 7ee5018dfc8efd533fa7f2180fed8811b3744622 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 8 Mar 2024 18:36:39 +0100 Subject: [PATCH] Add variable to configure storage options With addition of storage v2 versions and v2 API it's now less trivial to rely on overrides for storage configuration, which most likely will be needed regardless, since v1 storages are incompatible with /v2 API, and latter one gets disabled whenever v1 storage is in use. With that there's no dummy storage in /v2 for testing purposes, so we are not able to have any reasonable default out of the box. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/920058 Change-Id: Ic0d055c98ee6e35fb28b26de8cf3d20e7e79ad87 --- defaults/main.yml | 14 ++++++++++++++ ...cloudkitty_storage_config-48e154cc2b549238.yaml | 5 +++++ templates/cloudkitty.conf.j2 | 11 +++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/cloudkitty_storage_config-48e154cc2b549238.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 3758e51..1422761 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -117,6 +117,20 @@ cloudkitty_output_backend: cloudkitty.backend.file.FileBackend cloudkitty_output_pipeline: osrf cloudkitty_output_basepath: /var/cloudkitty/reports +# Please define a storage for CloudKitty data in as a nested dictionary. +# Keys `backend` and `version` are required. `config` contains extra +# configuration for the storage backend when applicable. +# For example: +# cloudkitty_storage: +# backend: opensearch +# version: 2 +# config: +# host = http://localhost:9200 +# index_name = cloudkitty +cloudkitty_storage: + backend: sqlalchemy + version: 1 + cloudkitty_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" cloudkitty_db_setup_python_interpreter: >- {{ diff --git a/releasenotes/notes/cloudkitty_storage_config-48e154cc2b549238.yaml b/releasenotes/notes/cloudkitty_storage_config-48e154cc2b549238.yaml new file mode 100644 index 0000000..c9ad1f3 --- /dev/null +++ b/releasenotes/notes/cloudkitty_storage_config-48e154cc2b549238.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added a variable ``cloudkitty_storage`` that allows to easily define + storage configuration options for Cloudkitty. diff --git a/templates/cloudkitty.conf.j2 b/templates/cloudkitty.conf.j2 index acfadc5..6544ce7 100644 --- a/templates/cloudkitty.conf.j2 +++ b/templates/cloudkitty.conf.j2 @@ -77,5 +77,12 @@ backend = {{ cloudkitty_output_backend }} [state] [storage] -backend = sqlalchemy -version = 1 +backend = {{ cloudkitty_storage['backend'] }} +version = {{ cloudkitty_storage['version'] }} + +{% if 'config' in cloudkitty_storage %} +[storage_{{ cloudkitty_storage['backend'] }}] +{% for item, value in cloudkitty_storage['config'].items() %} +{{ item }} = {{ value }} +{% endfor %} +{% endif %}