
Current implementation of loopback preparation has quite significant overhead, as we are calling exact same roles multiple times in order to provision all required loopback devices. Moreover, we duplicate code and logic needed for their provisionment, despite we have pretty much 2 usecase - either add sparse file as LVM or format and directly mount with systemd. Proposed patch unifies approach by generating a variable with required keys/parameters to create all required devices at once. This should reduce overhead caused by multiple role imports/includes. as each time role tries to install packages and verifies dependencies. Change-Id: I419fdcfa2cfac5b636f817b1d6bdd82b7198e6be Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
193 lines
8.7 KiB
YAML
193 lines
8.7 KiB
YAML
---
|
|
# Copyright 2017, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
bootstrap_host_scenarios: "{{ (bootstrap_host_scenario.split('_') | reject('equalto', '')) | list }}"
|
|
|
|
_lxc_container_backing_store: |-
|
|
{% if 'zfs' in bootstrap_host_scenarios %}
|
|
{% set store = 'zfs' %}
|
|
{% elif 'btrfs' in bootstrap_host_scenarios %}
|
|
{% set store = 'btrfs' %}
|
|
{% elif 'dir' in bootstrap_host_scenarios %}
|
|
{% set store = 'dir' %}
|
|
{% elif 'lvm' in bootstrap_host_scenarios %}
|
|
{% set store = 'lvm' %}
|
|
{% elif 'overlayfs' in bootstrap_host_scenarios %}
|
|
{% set store = 'overlayfs' %}
|
|
{% else %}
|
|
{% set store = 'dir' %}
|
|
{% endif %}
|
|
{{ store }}
|
|
|
|
# Expand the scenario list to include specific services that are being deployed
|
|
# as part of the scenario
|
|
bootstrap_host_scenarios_expanded: |-
|
|
{# Keystone is included in every scenario #}
|
|
{% set scenario_list = bootstrap_host_scenarios + ['keystone', 'haproxy'] %}
|
|
{% if ['aio', 'translations'] | intersect(bootstrap_host_scenarios) | length > 0 %}
|
|
{# Base services deployed with aio and translations scenarios #}
|
|
{% set _ = scenario_list.extend(['cinder', 'glance', 'neutron', 'nova', 'placement', 'horizon']) %}
|
|
{% endif %}
|
|
{# Service additions based on scenario presence #}
|
|
{% if 'cloudkitty' in bootstrap_host_scenarios %}
|
|
{% set _ = scenario_list.extend(['ceilometer', 'gnocchi']) %}
|
|
{% endif %}
|
|
{% if 'designate' in bootstrap_host_scenarios or
|
|
('validate' in bootstrap_host_scenarios and ('integrated' in bootstrap_host_scenarios or 'plugins' in bootstrap_host_scenarios)) %}
|
|
{% set _ = scenario_list.extend(['zookeeper']) %}
|
|
{% endif %}
|
|
{% if 'ironic' in bootstrap_host_scenarios %}
|
|
{% set _ = scenario_list.extend(['swift']) %}
|
|
{% endif %}
|
|
{% if ('magnum' in bootstrap_host_scenarios) %}
|
|
{% set _ = scenario_list.extend(['heat']) %}
|
|
{% endif %}
|
|
{% if 'manila' in bootstrap_host_scenarios %}
|
|
{% set _ = scenario_list.extend(['ceph']) %}
|
|
{% endif %}
|
|
{% if ['telemetry', 'aodh', 'ceilometer', 'gnocchi'] | intersect(bootstrap_host_scenarios) | length > 0 %}
|
|
{% set _ = scenario_list.extend(['aodh', 'ceilometer', 'gnocchi']) %}
|
|
{% endif %}
|
|
{% if 'translations' in bootstrap_host_scenarios %}
|
|
{% set _ = scenario_list.extend(['designate', 'heat', 'magnum', 'swift', 'trove']) %}
|
|
{% endif %}
|
|
{{ (scenario_list | unique) | sort }}
|
|
|
|
_neutron_plugin_driver: |-
|
|
{% if 'ovs' in bootstrap_host_scenarios_expanded %}
|
|
{% set plugin = 'ml2.ovs' %}
|
|
{% else %}
|
|
{% set plugin = 'ml2.ovn' %}
|
|
{% endif %}
|
|
{{ plugin }}
|
|
|
|
_loopback_device_data: |-
|
|
{% set data = {'sparse': [], 'fs': [], 'mounts': [], 'services': [], 'lvm': []} %}
|
|
{% if bootstrap_host_loopback_nova | bool %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_nova_size, 'path': '/openstack/nova.img'}) %}
|
|
{% set _ = data['fs'].append({'fstype': 'xfs', 'opts': bootstrap_host_format_options['xfs'], 'path': '/openstack/nova.img'}) %}
|
|
{% set _ = data['mounts'].append({
|
|
'what': '/openstack/nova.img',
|
|
'where': '/var/lib/nova/instances',
|
|
'type': 'xfs',
|
|
'options': 'loop,' ~ bootstrap_host_data_mount_options['xfs'],
|
|
'enabled': true,
|
|
'state': 'started',
|
|
}) %}
|
|
{% endif %}
|
|
{% if bootstrap_host_loopback_cinder | bool %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_cinder_size, 'path': '/openstack/cinder.img'}) %}
|
|
{% set _ = data['services'].append({
|
|
'name': 'loop-cinder',
|
|
'execstarts': [
|
|
'/bin/bash -c "/sbin/losetup /dev/loop6 /openstack/cinder.img"',
|
|
'/sbin/pvscan'
|
|
],
|
|
'execstops': ['/bin/bash -c "losetup -d /dev/loop6"'],
|
|
}) %}
|
|
{% set _ = data['lvm'].append({
|
|
'vg': 'cinder-volumes',
|
|
'pvs': '/dev/loop6',
|
|
}) %}
|
|
{% endif %}
|
|
{% if bootstrap_host_loopback_manila | bool %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_manila_size, 'path': '/openstack/manila.img'}) %}
|
|
{% set _ = data['services'].append({
|
|
'name': 'loop-manila',
|
|
'execstarts': [
|
|
'/bin/bash -c "/sbin/losetup /dev/loop7 /openstack/manila.img"',
|
|
'/sbin/pvscan'
|
|
],
|
|
'execstops': ['/bin/bash -c "losetup -d /dev/loop7"'],
|
|
}) %}
|
|
{% set _ = data['lvm'].append({
|
|
'vg': 'manila-shares',
|
|
'pvs': '/dev/loop7',
|
|
}) %}
|
|
{% endif %}
|
|
{% if bootstrap_host_ceph | bool %}
|
|
{% for image in ceph_osd_images %}
|
|
{% set device = '/dev/loop' ~ (10 + loop.index) %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_ceph_size, 'path': '/openstack/' ~ image ~ '.img'}) %}
|
|
{% set _ = data['services'].append({
|
|
'name': 'loop-' ~ image,
|
|
'execstarts': [
|
|
'/bin/bash -c "/sbin/losetup '~ device ~' /openstack/' ~ image ~ '.img"',
|
|
'/sbin/pvscan'
|
|
],
|
|
'execstops': ['/bin/bash -c "losetup -d ' ~ device ~ '"']
|
|
}) %}
|
|
{% set _ = data['lvm'].append({
|
|
'lv': 'lv-' ~ image,
|
|
'vg': 'vg-' ~ image,
|
|
'pvs': device,
|
|
}) %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if bootstrap_host_loopback_swift | bool %}
|
|
{% for image in ['swift1', 'swift2', 'swift3'] %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_swift_size, 'path': '/openstack/' ~ image ~ '.img'}) %}
|
|
{% set _ = data['fs'].append({'fstype': 'xfs', 'opts': bootstrap_host_format_options['xfs'], 'path': '/openstack/' ~ image ~ '.img'}) %}
|
|
{% set _ = data['mounts'].append({
|
|
'what': '/openstack/' ~ image ~ '.img',
|
|
'where': '/srv/' ~ image ~ '.img',
|
|
'type': 'xfs',
|
|
'options': 'loop,' ~ bootstrap_host_data_mount_options['xfs'],
|
|
'enabled': true,
|
|
'state': 'started',
|
|
}) %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if bootstrap_host_loopback_btrfs | bool and bootstrap_host_data_disk_device == None and _lxc_container_backing_store == 'btrfs'%}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_btrfs_size, 'path': '/openstack/lxc-btrfs.img'}) %}
|
|
{% set _ = data['fs'].append({'fstype': 'btrfs', 'opts': bootstrap_host_format_options['btrfs'], 'path': '/openstack/lxc-btrfs.img'}) %}
|
|
{% set _ = data['mounts'].append({
|
|
'what': '/openstack/lxc-btrfs.img',
|
|
'where': '/var/lib/lxc',
|
|
'type': 'btrfs',
|
|
'options': 'loop,' ~ bootstrap_host_data_mount_options['btrfs'],
|
|
'enabled': true,
|
|
'state': 'started',
|
|
}) %}
|
|
{% endif %}
|
|
{% if bootstrap_host_loopback_btrfs | bool and bootstrap_host_data_disk_device == None and _lxc_container_backing_store == 'zfs'%}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_zfs_size, 'path': '/openstack/lxc-zfs.img'}) %}
|
|
{% endif %}
|
|
{% if bootstrap_host_nfs | bool %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_nfs_size, 'path': '/openstack/nfs.img'}) %}
|
|
{% set _ = data['fs'].append({'fstype': 'xfs', 'opts': bootstrap_host_format_options['xfs'], 'path': '/openstack/nfs.img'}) %}
|
|
{% set _ = data['mounts'].append({
|
|
'what': '/openstack/nfs.img',
|
|
'where': '/srv/nfs',
|
|
'type': 'xfs',
|
|
'options': 'loop,' ~ bootstrap_host_data_mount_options['xfs'],
|
|
'enabled': true,
|
|
'state': 'started',
|
|
}) %}
|
|
{% endif %}
|
|
{% if bootstrap_host_loopback_swap | bool and ansible_facts['swaptotal_mb'] < 1 %}
|
|
{% set _ = data['sparse'].append({'size': bootstrap_host_loopback_swap_size, 'path': '/openstack/swap.img'}) %}
|
|
{% set _ = data['fs'].append({'fstype': 'swap', 'path': '/openstack/swap.img'}) %}
|
|
{% set _ = data['mounts'].append({
|
|
'what': '/openstack/swap.img',
|
|
'priority': 0,
|
|
'type': 'swap',
|
|
'options': bootstrap_host_data_mount_options['swap'],
|
|
'enabled': true,
|
|
'state': 'started',
|
|
}) %}
|
|
{% endif %}
|
|
{{ data }}
|