This change implements the blueprint to convert all roles and plays into a more generic setup, following upstream ansible best practices. Items Changed: * All tasks have tags. * All roles use namespaced variables. * All redundant tasks within a given play and role have been removed. * All of the repetitive plays have been removed in-favor of a more simplistic approach. This change duplicates code within the roles but ensures that the roles only ever run within their own scope. * All roles have been built using an ansible galaxy syntax. * The `*requirement.txt` files have been reformatted follow upstream Openstack practices. * Dynamically generated inventory is now more organized, this should assist anyone who may want or need to dive into the JSON blob that is created. In the inventory a properties field is used for items that customize containers within the inventory. * The environment map has been modified to support additional host groups to enable the seperation of infrastructure pieces. While the old infra_hosts group will still work this change allows for groups to be divided up into seperate chunks; eg: deployment of a swift only stack. * The LXC logic now exists within the plays. * etc/openstack_deploy/user_variables.yml has all password/token variables extracted into the separate file etc/openstack_deploy/user_secrets.yml in order to allow seperate security settings on that file. Items Excised: * All of the roles have had the LXC logic removed from within them which should allow roles to be consumed outside of the `os-ansible-deployment` reference architecture. Note: * the directory rpc_deployment still exists and is presently pointed at plays containing a deprecation warning instructing the user to move to the standard playbooks directory. * While all of the rackspace specific components and variables have been removed and or were refactored the repository still relies on an upstream mirror of Openstack built python files and container images. This upstream mirror is hosted at rackspace at "http://rpc-repo.rackspace.com" though this is not locked to and or tied to rackspace specific installations. This repository contains all of the needed code to create and/or clone your own mirror. DocImpact Co-Authored-By: Jesse Pretorius <jesse.pretorius@rackspace.co.uk> Closes-Bug: #1403676 Implements: blueprint galaxy-roles Change-Id: I03df3328b7655f0cc9e43ba83b02623d038d214e
97 lines
5.1 KiB
Django/Jinja
97 lines
5.1 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) %}
|
|
{% set repl_number = item.repl_number | default(swift.repl_number | default(swift_default_replication_number)) %}
|
|
{### 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 }}
|