de8b857668
Add the swift-remote host group and environment file. Add an os_swift_sync role which will sync the swift ring and ssh keys for swift hosts (remote and not-remote). Which has the following: * Moves the key and ring tasks out of os_swift role to os_swift_sync. * This adds the use of the "-r" flag that was added to the swift_rings.py and swift_rings_check.py. * Adds a ring.builder vs contents file consistency check. * Adjusts the rsync process to use the built-in synchronize module * Ensure services have started post ring/ssh key sync. Adds environment file and sample configuration file for swift-remote hosts (conf.d). Move appropriate default vars to the os_swift_sync role, and remove them from the os_swift role. Rename the "os-swift-install.yml" playbook to "os-swift-setup.yml" as this handles only the setup, and add a playbook to for both os-swift-sync.yml and an overarching playbook (os-swift-install.yml) that will call both the os-swift-sync.yml and os-swift-setup.yml playbooks. This means the funcitonality of "os-swift-install.yml" remains unchanged. Adjust the run-playbooks.sh so that it calls the new overarching swift playbook. Change-Id: Ie2d8041b4bc46f092a96882fe3ca430be92195ed Partially-Implements: blueprint multi-region-swift
101 lines
5.3 KiB
Django/Jinja
101 lines
5.3 KiB
Django/Jinja
{### Check if this is an object storage policy #}
|
|
{% if item[1] is defined %}
|
|
{% set port = item[1]['port'] %}
|
|
{% set type = item[1]['type'] %}
|
|
{% set item = item[0]['policy'] %}
|
|
{### If the index is 0 then it needs to be object without index #}
|
|
{% if item.index == 0 %}
|
|
{% set builder_file = type %}
|
|
{% else %}
|
|
{% set builder_file = type + '-' + item.index|string %}
|
|
{% endif %}
|
|
{% set name = item.name %}
|
|
{### Otherwise this should be account or container rings #}
|
|
{### Make the port/type/item/builder_file/name vals uniform across rings #}
|
|
{% elif item.port is defined %}
|
|
{% set port = item.port %}
|
|
{% set type = item.type %}
|
|
{% set item = item.item %}
|
|
{% set builder_file = type %}
|
|
{% set name = type %}
|
|
{% endif %}
|
|
{### Lets get the min_part_hours, part_power and repl_number vals #}
|
|
{% set min_part_hours = item.min_part_hours | default(swift.min_part_hours | default(swift_default_min_part_hours)) %}
|
|
{% set part_power = item.part_power | default(swift.part_power) %}
|
|
{% if (item.policy_type is defined) and (item.policy_type == "erasure_coding") %}
|
|
{% set repl_number = item.ec_num_data_fragments + item.ec_num_parity_fragments %}
|
|
{% else %}
|
|
{% set repl_number = item.repl_number | default(swift.repl_number | default(swift_default_replication_number)) %}
|
|
{% endif %}
|
|
{### Create the builder dict #}
|
|
{% set builder = {} %}
|
|
{### This is a hacky way of updating the builder dict #}
|
|
{% set _update = builder.update({'min_part_hours':min_part_hours}) %}
|
|
{% set _update = builder.update({'repl_number':repl_number}) %}
|
|
{% set _update = builder.update({'part_power':part_power}) %}
|
|
{% set _update = builder.update({'builder_file':builder_file}) %}
|
|
{### Now we need to add the drives #}
|
|
{### Create an update the builder dict to have drives as an empty list #}
|
|
{% set _update = builder.update({'drives':[]}) %}
|
|
{### Lets get the default groups for drives and find the default storage_policy #}
|
|
{% set def_groups = [ 'account', 'container' ] %}
|
|
{% for policy in swift.storage_policies %}
|
|
{% if policy.policy.default is defined and policy.policy.default == True %}
|
|
{% set _update = def_groups.append(policy.policy.name) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{### Loop through the swift_hosts #}
|
|
{% for host in groups['swift_hosts'] %}
|
|
{### Set the default storage_ip #}
|
|
{% set def_storage_ip = hostvars[host]['ansible_ssh_host'] %}
|
|
{% if swift.storage_network is defined %}
|
|
{% set storage_bridge = 'ansible_' + swift.storage_network|replace('-', '_') %}
|
|
{% set def_storage_ip = hostvars[host][storage_bridge]['ipv4']['address'] | default(hostvars[host]['ansible_ssh_host']) %}
|
|
{% endif %}
|
|
{### Set the default replication_ip #}
|
|
{% set def_repl_ip = def_storage_ip %}
|
|
{% if swift.replication_network is defined %}
|
|
{% set repl_bridge = 'ansible_' + swift.replication_network|replace('-', '_') %}
|
|
{% set def_repl_ip = hostvars[host][repl_bridge]['ipv4']['address'] | default(def_storage_ip) %}
|
|
{% endif %}
|
|
{### Default swift_vars to an empty dict if not defined #}
|
|
{### swift_vars needs to exist for swift_vars[setting] checks to wrok #}
|
|
{% if hostvars[host]['swift_vars'] is defined %}
|
|
{% set swift_vars = hostvars[host]['swift_vars'] %}
|
|
{% else %}
|
|
{% set swift_vars = {} %}
|
|
{% endif %}
|
|
{### Get the drives use swift global as default #}
|
|
{% set drives = swift_vars.drives | default(swift.drives | default([])) %}
|
|
{### Loop through the drives #}
|
|
{% for drive in drives %}
|
|
{### Check if groups is defined per host or drive #}
|
|
{% set groups = drive.groups | default(swift_vars.groups | default(swift.groups | default(def_groups))) %}
|
|
{### Only build the device if it is part of the group we're building the ring for #}
|
|
{% if name in groups %}
|
|
{### Build an empty device which we'll update with the appropriate details #}
|
|
{% set device = {} %}
|
|
{% set weight = drive.weight | default(swift_vars.weight | default(swift.weight | default(swift_default_drive_weight))) %}
|
|
{% set region = drive.region | default(swift_vars.region | default(swift.region | default(swift_default_host_region))) %}
|
|
{% set zone = drive.zone | default(swift_vars.zone | default(swift.zone | default(swift_default_host_zone))) %}
|
|
{% set repl_ip = drive.repl_ip | default(swift_vars.repl_ip | default(def_repl_ip)) %}
|
|
{% set repl_port = drive.repl_port | default(swift_vars.repl_port | default(port)) %}
|
|
{% set storage_ip = drive.storage_ip | default(swift_vars.storage_ip | default(def_storage_ip)) %}
|
|
{% set storage_port = drive.storage_port | default(swift_vars.storage_port | default(port)) %}
|
|
{### Update the device with the appropriate values #}
|
|
{% set _update = device.update({'device':drive.name}) %}
|
|
{% set _update = device.update({'weight': weight}) %}
|
|
{% set _update = device.update({'region': region}) %}
|
|
{% set _update = device.update({'zone': zone}) %}
|
|
{% set _update = device.update({'repl_ip': repl_ip}) %}
|
|
{% set _update = device.update({'repl_port': repl_port|int}) %}
|
|
{% set _update = device.update({'ip': storage_ip}) %}
|
|
{% set _update = device.update({'port': storage_port|int}) %}
|
|
{### Append the device to the drives list of the builder dict #}
|
|
{% set _update = builder.drives.append(device) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{### Output the builder file #}
|
|
{{ builder | to_nice_json }}
|