Set manila_backends to empty dict by default

This simplifies logic across the role and not verify if variable is
defined each time we're attempting to use it.

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/787341
Change-Id: I6db4ad6e6389b1ff63dc52a1e48c477a97905d17
This commit is contained in:
Dmitriy Rabotyagov 2021-04-21 14:24:26 +03:00 committed by Dmitriy Rabotyagov
parent 91b53f2b6c
commit 286414c2a6
4 changed files with 7 additions and 8 deletions

View File

@ -191,6 +191,7 @@ manila_quota_share_networks: 10
# driver_handles_share_servers: False
# lvm_share_volume_group: manila_shares
# lvm_share_export_ips: <server-ip>
manila_backends: {}
manila_enabled_share_protocols:
- NFS
@ -201,9 +202,9 @@ manila_default_share_type: "{{ _manila_default_share_type | default('') }}"
manila_share_name_template: share-%s
# manila_backend_lvm_inuse: True if current host has an lvm backend
manila_backend_lvm_inuse: "{{ (manila_backends | default('') | to_json).find('lvm') != -1 }}"
manila_backend_lvm_inuse: "{{ (manila_backends | to_json).find('lvm') != -1 }}"
# manila_backend_rbd_inuse: True if the current host has an rbd backend
manila_backend_rbd_inuse: "{{ (manila_backends | default('')|to_json).find('manila.share.drivers.cephfs') != -1 }}"
manila_backend_rbd_inuse: "{{ (manila_backends |to_json).find('manila.share.drivers.cephfs') != -1 }}"
## Policy vars
# Provide a list of access controls to update the default policy.json with. These changes will be merged

View File

@ -182,7 +182,7 @@
- name: Create singular manila_backends variable for all hosts
set_fact:
_manila_backends: "{{ (_manila_backends | default(manila_backends | default({}))) | combine(hostvars[item]['manila_backends'] | default({})) }}"
_manila_backends: "{{ (_manila_backends | default(manila_backends)) | combine(hostvars[item]['manila_backends'] | default({})) }}"
with_items: "{{ groups[manila_services['manila-share']['group']] }}"
tags:
- manila-config

View File

@ -35,18 +35,16 @@ storage_availability_zone = {{ manila_storage_availability_zone }}
enabled_share_protocols={{ manila_enabled_share_protocols | join(',') }}
{% endif %}
{% if manila_backends is defined %}
enabled_share_backends={% for backend in manila_backends | dictsort %}{{ backend.0 }}{% if not loop.last %},{% endif %}{% endfor %}
# All given backend(s)
{% for backend_section in manila_backends | dictsort %}
[{{ backend_section.0 }}]
{% for key, value in (backend_section.1 | dictsort) if key not in ['extra_share_types', 'shares'] %}
{% for key, value in (backend_section.1 | dictsort) if key not in ['extra_share_types', 'shares'] %}
{{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
[database]
connection = mysql+pymysql://{{ manila_galera_user }}:{{ manila_container_mysql_password }}@{{ manila_galera_address }}/{{ manila_galera_database }}?charset=utf8{% if manila_galera_use_ssl | bool %}&ssl_ca={{ manila_galera_ssl_ca_cert }}{% endif %}

View File

@ -16,7 +16,7 @@
_manila_is_first_play_host: "{{ (manila_services['manila-api']['group'] in group_names and inventory_hostname == (groups[manila_services['manila-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
_manila_share_is_first_play_host: "{{ (manila_services['manila-share']['group'] in group_names and inventory_hostname == (groups[manila_services['manila-share']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
_manila_default_share_type_list: "{{ (manila_backends | default({})).keys() | list }}"
_manila_default_share_type_list: "{{ manila_backends.keys() | list }}"
_manila_default_share_type: "{{ ((_manila_default_share_type_list | length) > 0) | ternary(_manila_default_share_type_list[0], '') }}"
#