Adjust the network rings are syncd on
Swift nodes don't have to be able to talk to each other on the ansible_ssh_host, but will always have to talk on the storage_network specified. This will allow us to let remote or local hosts, that can't connect to each other on the ansible_ssh_host address to still be able to sync their rings. In order to achieve this we set a swift_storage_address fact which then simplifies the "ring_contents" file, to avoid performing the same logic twice. Change-Id: Ic1f2a915244101ad4fbbe52496dd2b991915d01d Partially-Implements: blueprint multi-region-swift
This commit is contained in:
parent
7d2a0231d8
commit
66ccc1a260
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
- include: swift_rings_md5sum.yml
|
- include: swift_rings_md5sum.yml
|
||||||
|
|
||||||
|
- include: swift_storage_address.yml
|
||||||
|
|
||||||
- include: swift_rings_check.yml
|
- include: swift_rings_check.yml
|
||||||
when: >
|
when: >
|
||||||
inventory_hostname == groups['swift_hosts'][0]
|
inventory_hostname == groups['swift_hosts'][0]
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
shell: |
|
shell: |
|
||||||
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
|
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
|
||||||
-avz \
|
-avz \
|
||||||
{{ swift_system_user_name }}@{{ hostvars[groups['swift_hosts'][0]]['ansible_ssh_host'] }}:/etc/swift/ring_build_files/ \
|
{{ swift_system_user_name }}@{{ hostvars[groups['swift_hosts'][0]]['swift_storage_address'] }}:/etc/swift/ring_build_files/ \
|
||||||
/etc/swift/
|
/etc/swift/
|
||||||
sudo: yes
|
sudo: yes
|
||||||
sudo_user: "{{ swift_system_user_name }}"
|
sudo_user: "{{ swift_system_user_name }}"
|
||||||
@ -30,7 +30,7 @@
|
|||||||
shell: |
|
shell: |
|
||||||
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
|
rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
|
||||||
-avz \
|
-avz \
|
||||||
{{ swift_system_user_name }}@{{ hostvars[groups['swift_hosts'][0]]['ansible_ssh_host'] }}:/etc/swift/ring_build_files/ \
|
{{ swift_system_user_name }}@{{ hostvars[groups['swift_hosts'][0]]['swift_storage_address'] }}:/etc/swift/ring_build_files/ \
|
||||||
/etc/swift/ring_build_files/
|
/etc/swift/ring_build_files/
|
||||||
sudo: yes
|
sudo: yes
|
||||||
sudo_user: "{{ swift_system_user_name }}"
|
sudo_user: "{{ swift_system_user_name }}"
|
||||||
|
37
playbooks/roles/os_swift/tasks/swift_storage_address.yml
Normal file
37
playbooks/roles/os_swift/tasks/swift_storage_address.yml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2014, 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.
|
||||||
|
|
||||||
|
# We need the storage network for replication of the ring
|
||||||
|
# We find the IP on the "storage_bridge" network for storage hosts
|
||||||
|
- name: Register a fact for the default storage IP swift hosts
|
||||||
|
set_fact:
|
||||||
|
swift_storage_address: "{{ hostvars[inventory_hostname]['swift_vars']['storage_ip'] | default(hostvars[inventory_hostname]['ansible_' + swift.storage_network|replace('-','_')]['ipv4']['address'] | default(hostvars[inventory_hostname]['ansible_ssh_host'])) }}"
|
||||||
|
when: inventory_hostname in groups['swift_hosts'] and
|
||||||
|
swift.storage_network is defined
|
||||||
|
|
||||||
|
# For proxy servers this is mapped to an interface that isn't the bridge
|
||||||
|
- name: Register a fact for the default storage IP on proxy servers
|
||||||
|
set_fact:
|
||||||
|
swift_storage_address: "{{ item.value.address }}"
|
||||||
|
with_dict: container_networks
|
||||||
|
when: inventory_hostname in groups['swift_proxy'] and
|
||||||
|
swift.storage_network is defined and
|
||||||
|
item.value.bridge == swift.storage_network
|
||||||
|
|
||||||
|
# A catchall, and for remote hosts the IP is just the ansible_ssh_host IP
|
||||||
|
- name: Register a fact for the default storage IP when no storage-network is defined or for remote hosts
|
||||||
|
set_fact:
|
||||||
|
swift_storage_address: "{{ hostvars[inventory_hostname]['ansible_ssh_host'] }}"
|
||||||
|
when: swift.storage_network is not defined
|
@ -47,11 +47,7 @@
|
|||||||
{### Loop through the swift_hosts #}
|
{### Loop through the swift_hosts #}
|
||||||
{% for host in groups['swift_hosts'] %}
|
{% for host in groups['swift_hosts'] %}
|
||||||
{### Set the default storage_ip #}
|
{### Set the default storage_ip #}
|
||||||
{% set def_storage_ip = hostvars[host]['ansible_ssh_host'] %}
|
{% set def_storage_ip = hostvars[host]['swift_storage_address'] %}
|
||||||
{% 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 the default replication_ip #}
|
||||||
{% set def_repl_ip = def_storage_ip %}
|
{% set def_repl_ip = def_storage_ip %}
|
||||||
{% if swift.replication_network is defined %}
|
{% if swift.replication_network is defined %}
|
||||||
@ -80,7 +76,7 @@
|
|||||||
{% set zone = drive.zone | default(swift_vars.zone | default(swift.zone | default(swift_default_host_zone))) %}
|
{% 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_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 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_ip = drive.storage_ip | default(def_storage_ip) %}
|
||||||
{% set storage_port = drive.storage_port | default(swift_vars.storage_port | default(port)) %}
|
{% set storage_port = drive.storage_port | default(swift_vars.storage_port | default(port)) %}
|
||||||
{### Update the device with the appropriate values #}
|
{### Update the device with the appropriate values #}
|
||||||
{% set _update = device.update({'device':drive.name}) %}
|
{% set _update = device.update({'device':drive.name}) %}
|
||||||
|
Loading…
Reference in New Issue
Block a user