Make glance_additional_stores work nicely with multi-store
While we assume that glance_additional_stores can be list of mappings for multistore glance support, bunch of other logic in role still treats it as simple list and make verifications against it. So in case one dares to override variable according to our suggestion, they also need to override bunch of other things. We change defaults for `glance_available_stores` variable and always define it as a multistore list of mappings. Then we introduce a variable `glance_available_store_types` that is a list of types for each of configured storage. Logic of how storages are defined in glance config is also changed now. Storages won't be defined if there's no "default" record for them in glance_available_stores. For each new store that deployer wants to provision, they now can pass `config` key for glance stores, rather then use config overrides. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/901041 Change-Id: I1416e0f6e3ed79abd10f468b52fc712d35a61bd2
This commit is contained in:
parent
ff895d3bad
commit
aa69a6fe5c
@ -78,18 +78,26 @@ glance_system_user_home: "/var/lib/{{ glance_system_user_name }}"
|
||||
# glance_system_user_uid: <UID>
|
||||
# glance_system_group_gid: <GID>
|
||||
|
||||
# Variable can be either a string or a mapping. Valid keys are:
|
||||
# name, type, config
|
||||
glance_default_store: file
|
||||
# For support of multiple backends provide `glance_additional_stores` in the format:
|
||||
# glance_additional_stores:
|
||||
# - name: private_store
|
||||
# type: http
|
||||
# type: file
|
||||
# config:
|
||||
# filesystem_store_datadir: /private
|
||||
glance_additional_stores:
|
||||
- http
|
||||
- cinder
|
||||
glance_available_stores: "{{ [glance_default_store] + glance_additional_stores }}"
|
||||
glance_flavor: "{% if glance_default_store == 'rbd' %}keystone{% else %}keystone+cachemanagement{% endif %}"
|
||||
glance_show_image_direct_url: "{{ glance_default_store == 'rbd' }}"
|
||||
glance_show_multiple_locations: "{{ glance_default_store == 'rbd' }}"
|
||||
- name: http
|
||||
type: http
|
||||
- name: cinder
|
||||
type: cinder
|
||||
glance_available_stores: "{{ _glance_available_stores }}"
|
||||
glance_available_store_types: "{{ glance_available_stores | map(attribute='type') | list | unique }}"
|
||||
|
||||
glance_flavor: "{% if 'rbd' in glance_available_store_types %}keystone{% else %}keystone+cachemanagement{% endif %}"
|
||||
glance_show_image_direct_url: "{{ 'rbd' in glance_available_store_types }}"
|
||||
glance_show_multiple_locations: "{{ 'rbd' in glance_available_store_types }}"
|
||||
|
||||
glance_memcached_servers: "{{ memcached_servers }}"
|
||||
|
||||
@ -283,7 +291,7 @@ glance_pip_packages:
|
||||
- python-swiftclient
|
||||
- systemd-python
|
||||
- warlock
|
||||
- "{{ ('s3' in glance_available_stores) | ternary('boto3', '') }}"
|
||||
- "{{ ('s3' in glance_available_store_types) | ternary('boto3', '') }}"
|
||||
|
||||
# Specific pip packages provided by the user
|
||||
glance_user_pip_packages: []
|
||||
@ -296,7 +304,7 @@ glance_api_init_overrides: {}
|
||||
# With enabled uwsgi glance has broken functionality of
|
||||
# the interoperable import feature (and maybe smth else)
|
||||
# We don't use uwsgi if ceph is used to prevent chunking issues
|
||||
glance_use_uwsgi: "{{ ('ceph' not in glance_available_stores) }}"
|
||||
glance_use_uwsgi: "{{ ('rbd' not in glance_available_store_types) }}"
|
||||
|
||||
## Service Names
|
||||
glance_services:
|
||||
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
upgrade:
|
||||
- |
|
||||
Default value of ``glance_available_stores`` has changed. Now it is
|
||||
always should be represented as a list of mappings, where each item
|
||||
has following keys:
|
||||
|
||||
* name (required)
|
||||
* type (required)
|
||||
* config (optional)
|
@ -181,7 +181,7 @@
|
||||
openstack_service_venv_bin: "{{ (glance_install_method == 'source') | ternary(glance_bin, '') }}"
|
||||
when:
|
||||
- "glance_services['glance-api']['group'] in group_names"
|
||||
- "'rbd' in glance_available_stores"
|
||||
- "'rbd' in glance_available_store_types"
|
||||
tags:
|
||||
- ceph
|
||||
|
||||
|
@ -28,7 +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 }}
|
||||
|
||||
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 %}{{ backend['name'] }}:{{ backend['type'] }}{% if not loop.last %},{% endif %}{% endfor %}
|
||||
|
||||
|
||||
[task]
|
||||
@ -86,14 +86,14 @@ transport_url = {{ glance_oslomsg_notify_transport }}://{% for host in glance_os
|
||||
flavor = {{ glance_flavor }}
|
||||
|
||||
[glance_store]
|
||||
default_backend = {{ glance_default_store }}
|
||||
default_backend = {{ (glance_default_store is string) | ternary(glance_default_store, glance_default_store['name']) }}
|
||||
|
||||
{% if 'file' in glance_available_stores %}
|
||||
{% for backend in glance_available_stores %}
|
||||
{% if backend['name'] == 'file' and backend['type'] == 'file' and 'config' not in backend %}
|
||||
[file]
|
||||
filesystem_store_datadir = {{ glance_system_user_home }}/{{ glance_images_local_directory }}/
|
||||
{% endif %}
|
||||
|
||||
{% if 'swift' in glance_available_stores %}
|
||||
{% elif backend['name'] == 'swift' and backend['type'] == 'swift' and 'config' not in backend %}
|
||||
[swift]
|
||||
swift_store_config_file = {{ glance_etc_dir }}/glance-swift-store.conf
|
||||
default_swift_reference = swift1
|
||||
@ -105,15 +105,22 @@ swift_store_large_object_size = {{ glance_swift_store_large_object_size }}
|
||||
swift_store_large_object_chunk_size = {{ glance_swift_store_large_object_chunk_size }}
|
||||
swift_store_retry_get_count = 5
|
||||
swift_store_endpoint_type = {{ glance_swift_store_endpoint_type }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'rbd' in glance_available_stores %}
|
||||
{% elif backend['name'] == 'rbd' and backend['type'] == 'rbd' and 'config' not in backend %}
|
||||
[rbd]
|
||||
rbd_store_pool = {{ glance_rbd_store_pool }}
|
||||
rbd_store_user = {{ glance_rbd_store_user }}
|
||||
rbd_store_ceph_conf = /etc/ceph/ceph.conf
|
||||
rbd_store_chunk_size = {{ glance_rbd_store_chunk_size }}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
[{{ backend['name'] }}]
|
||||
{% for key, value in backend.get('config', {}) %}
|
||||
{{ key }} = {{ value }}
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
[profiler]
|
||||
enabled = {{ glance_profiler_enabled }}
|
||||
|
@ -95,3 +95,14 @@ glance_core_files:
|
||||
owner: "root"
|
||||
group: "{{ glance_system_group_name }}"
|
||||
mode: "0640"
|
||||
|
||||
_glance_available_stores: |-
|
||||
{% set stores = [] %}
|
||||
{% for store in ([glance_default_store] + glance_additional_stores) | unique %}
|
||||
{% if store is string %}
|
||||
{% set _ = stores.append({'name': store, 'type': store}) %}
|
||||
{% else %}
|
||||
{% set _ = stores.append(store) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ stores }}
|
||||
|
Loading…
Reference in New Issue
Block a user