From 091f33c8da9e355898cd4ffb8e2569481b7d65ab Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 24 Dec 2021 11:23:14 +0200 Subject: [PATCH] Define _glance_available_stores in variables Glance available stores is usefull outsie of the template as well, so we move defining variable from Jinja template only to ansible variables. Depends-On: https://review.opendev.org/c/openstack/ansible-role-python_venv_build/+/822998 Change-Id: I312fdede3c3bffa0c897588d33fcc5d5d6988ccd --- tasks/main.yml | 2 +- templates/glance-api.conf.j2 | 9 ++++----- vars/main.yml | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index d37447af..b50bff57 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -139,7 +139,7 @@ openstack_service_venv_bin: "{{ (glance_install_method == 'source') | ternary(glance_bin, '') }}" when: - "glance_services['glance-api']['group'] in group_names" - - "'rbd' in ([glance_default_store] + glance_additional_stores)" + - "'rbd' in _glance_available_stores" tags: - ceph diff --git a/templates/glance-api.conf.j2 b/templates/glance-api.conf.j2 index d89f7281..4235eec1 100644 --- a/templates/glance-api.conf.j2 +++ b/templates/glance-api.conf.j2 @@ -28,8 +28,7 @@ image_cache_max_size = {{ glance_image_cache_max_size }} show_image_direct_url = {{ glance_show_image_direct_url }} show_multiple_locations = {{ glance_show_multiple_locations }} -{% set glance_available_stores = [ glance_default_store ] + glance_additional_stores %} -enabled_backends = {% for backend in glance_available_stores %}{{ ('name' in backend) | ternary(backend['name'], backend) }}:{{ ('type' in backend) | ternary(backend['type'], backend) }}{% if not loop.last %},{% endif %}{% endfor %} +enabled_backends = {% for backend in _glance_available_stores %}{{ ('name' in backend) | ternary(backend['name'], backend) }}:{{ ('type' in backend) | ternary(backend['type'], backend) }}{% if not loop.last %},{% endif %}{% endfor %} [task] @@ -78,12 +77,12 @@ flavor = {{ glance_flavor }} [glance_store] default_backend = {{ glance_default_store }} -{% if 'file' in glance_available_stores %} +{% if 'file' in _glance_available_stores %} [file] filesystem_store_datadir = {{ glance_system_user_home }}/{{ glance_nfs_local_directory }}/ {% endif %} -{% if 'swift' in glance_available_stores %} +{% if 'swift' in _glance_available_stores %} [swift] swift_store_config_file = {{ glance_etc_dir }}/glance-swift-store.conf default_swift_reference = swift1 @@ -97,7 +96,7 @@ swift_store_retry_get_count = 5 swift_store_endpoint_type = {{ glance_swift_store_endpoint_type }} {% endif %} -{% if 'rbd' in glance_available_stores %} +{% if 'rbd' in _glance_available_stores %} [rbd] rbd_store_pool = {{ glance_rbd_store_pool }} rbd_store_user = {{ glance_rbd_store_user }} diff --git a/vars/main.yml b/vars/main.yml index 7dc44247..47564313 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +_glance_available_stores: "{{ [ glance_default_store ] + glance_additional_stores }}" _glance_is_first_play_host: "{{ (glance_services['glance-api']['group'] in group_names and inventory_hostname == (groups[glance_services['glance-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" #