Merge "Add support for Octavia AZs for Edge deployments" into stable/wallaby
This commit is contained in:
commit
1e12521e0a
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
- hosts: undercloud
|
||||
gather_facts: no
|
||||
environment:
|
||||
OS_CLOUD: "{{ stack }}"
|
||||
roles:
|
||||
- octavia_overcloud_dcn_config
|
||||
|
||||
- hosts: octavia_health_manager,octavia_worker,octavia_housekeeping
|
||||
gather_facts: no
|
||||
vars:
|
||||
# Get variables defined for the undercloud in the inventory
|
||||
username: "{{ hostvars['undercloud'].username }}"
|
||||
project_name: "{{ hostvars['undercloud'].project_name }}"
|
||||
overcloud_admin_password: "{{ hostvars['undercloud'].overcloud_admin_password }}"
|
||||
overcloud_keystone_url: "{{ hostvars['undercloud'].overcloud_keystone_url }}"
|
||||
|
||||
environment:
|
||||
OS_CLOUD: "{{ stack }}"
|
||||
roles:
|
||||
- octavia_controller_dcn_config
|
|
@ -0,0 +1,2 @@
|
|||
lb_mgmt_prefix: "lb-mgmt"
|
||||
lb_health_mgr_sec_grp_name: "lb-health-mgr-sec-grp"
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
galaxy_info:
|
||||
namespace: openstack
|
||||
author: OpenStack
|
||||
description: TripleO OpenStack Role -- octavia_controller_dcn_config
|
||||
company: Red Hat
|
||||
license: Apache-2.0
|
||||
min_ansible_version: 2.7
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
platforms:
|
||||
- name: CentOS
|
||||
versions:
|
||||
- 7
|
||||
- 8
|
||||
|
||||
galaxy_tags:
|
||||
- tripleo
|
||||
|
||||
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
dependencies:
|
||||
- octavia_common
|
|
@ -0,0 +1,46 @@
|
|||
- name: Get controller network fixed IPs
|
||||
shell: |
|
||||
openstack port show -c fixed_ips -f json \
|
||||
octavia-health-manager-{{ canonical_hostname }}-listen-port
|
||||
delegate_to: undercloud
|
||||
changed_when: false
|
||||
register: port_fixed_ips
|
||||
|
||||
- name: Get router interfaces
|
||||
shell: |
|
||||
openstack router show -c interfaces_info -f json {{ lb_mgmt_prefix }}-router
|
||||
delegate_to: undercloud
|
||||
changed_when: false
|
||||
run_once: yes
|
||||
register: router_interfaces
|
||||
|
||||
- name: Set facts for router gateway
|
||||
set_fact:
|
||||
gateway: "{{ router_interfaces.stdout | from_json | json_query(query) | first }}"
|
||||
vars:
|
||||
query: "interfaces_info[?subnet_id=='{{ port_subnet_id }}'].ip_address"
|
||||
port_subnet_id: "{{ port_fixed_ips.stdout | from_json | json_query('fixed_ips[0].subnet_id') }}"
|
||||
|
||||
- name: Get subnets CIDRs
|
||||
shell: |
|
||||
openstack subnet show -c cidr -f value {{ lb_mgmt_prefix }}-{{ item }}-subnet
|
||||
delegate_to: undercloud
|
||||
changed_when: false
|
||||
run_once: yes
|
||||
register: cidrs
|
||||
loop: "{{ octavia_availability_zones | difference([octavia_controller_availability_zone]) }}"
|
||||
|
||||
- name: Create route file for o-hm0
|
||||
copy:
|
||||
dest: /etc/sysconfig/network-scripts/route-o-hm0
|
||||
content: |
|
||||
{% for cidr in cidrs.results %}
|
||||
{{ cidr.stdout }} via {{ gateway }}
|
||||
{% endfor %}
|
||||
become: yes
|
||||
|
||||
- name: Set o-hm0 up
|
||||
shell: |
|
||||
ifdown o-hm0
|
||||
ifup o-hm0
|
||||
become: yes
|
|
@ -0,0 +1 @@
|
|||
lb_mgmt_prefix: "lb-mgmt"
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
galaxy_info:
|
||||
namespace: openstack
|
||||
author: OpenStack
|
||||
description: TripleO OpenStack Role -- octavia_overcloud_dcn_config
|
||||
company: Red Hat
|
||||
license: Apache-2.0
|
||||
min_ansible_version: 2.7
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
platforms:
|
||||
- name: CentOS
|
||||
versions:
|
||||
- 7
|
||||
- 8
|
||||
|
||||
galaxy_tags:
|
||||
- tripleo
|
||||
|
||||
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
dependencies:
|
||||
- octavia_common
|
|
@ -0,0 +1,137 @@
|
|||
- name: Ensure octavia_availability_zones variable is correctly defined
|
||||
fail:
|
||||
msg: "octavia_availability_zones parameter should contain at least one element (is '{{ octavia_availability_zones | default(None) }}')"
|
||||
when:
|
||||
- octavia_availability_zones is not defined or (octavia_availability_zones | default([]) | length) == 0
|
||||
|
||||
- name: Ensure octavia_controller_availability_zone variable is correctly defined
|
||||
fail:
|
||||
msg: "octavia_controller_availability_zone parameter should contain at least one element (is '{{ octavia_controller_availability_zone | default(None) }}')"
|
||||
when:
|
||||
- octavia_controller_availability_zone is not defined or (octavia_controller_availability_zone | length) == 0
|
||||
|
||||
- name: Create lb-mgmt networks
|
||||
shell: |
|
||||
if ! openstack network show {{ network_name }} > /dev/null 2>&1; then
|
||||
openstack network create {{ network_name }}
|
||||
fi
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
network_name: "{{ lb_mgmt_prefix }}{{ network_item }}-net"
|
||||
register: result
|
||||
changed_when: "'created_at' in result.stdout"
|
||||
loop: "{{ ['backbone'] | union(octavia_availability_zones | list) }}"
|
||||
|
||||
- name: Create lb-mgmt subnets
|
||||
shell: |
|
||||
if ! openstack subnet show {{ subnet_name }} > /dev/null 2>&1; then
|
||||
openstack subnet create --network {{ network_name }} \
|
||||
--ip-version 4 \
|
||||
--subnet-range {{ subnet_cidr }} \
|
||||
{{ subnet_name }}
|
||||
fi
|
||||
vars:
|
||||
subnet_cidr: "{{ octavia_availability_zones[item]['lb_mgmt_subnet_cidr'] | default(default_subnet_cidr) }}"
|
||||
default_subnet_cidr: "{% if item == 'backbone' %}{{ octavia_backbone_tenant_cidr | default(None) }}{% else %}None{% endif %}"
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
network_name: "{{ lb_mgmt_prefix }}{{ network_item }}-net"
|
||||
subnet_name: "{{ lb_mgmt_prefix }}{{ network_item }}-subnet"
|
||||
register: result
|
||||
changed_when: "'created_at' in result.stdout"
|
||||
loop: "{{ ['backbone'] | union(octavia_availability_zones | list) }}"
|
||||
|
||||
- name: Create lb-mgmt routers
|
||||
shell: |
|
||||
if ! openstack router show {{ router_name }} > /dev/null 2>&1; then
|
||||
openstack router create \
|
||||
--availability-zone-hint {{ item }} \
|
||||
{{ router_name }}
|
||||
fi
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
router_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router"
|
||||
register: result
|
||||
changed_when: "'created_at' in result.stdout"
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
||||
|
||||
- name: Add subnets to lb-mgmt routers
|
||||
shell: |
|
||||
subnet_id=$(openstack subnet show -f value -c id {{ subnet_name }})
|
||||
if ! openstack router show {{ router_name }} -f json -c interfaces_info | \
|
||||
jq -r ".interfaces_info[].subnet_id" | grep -q $subnet_id; then
|
||||
openstack router add subnet \
|
||||
{{ router_name }} \
|
||||
{{ subnet_name }}
|
||||
echo "subnet added"
|
||||
fi
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
router_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router"
|
||||
subnet_name: "{{ lb_mgmt_prefix }}{{ network_item }}-subnet"
|
||||
register: result
|
||||
changed_when: "'subnet added' in result.stdout"
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
||||
|
||||
- name: Create lb-mgmt ports
|
||||
shell: |
|
||||
if ! openstack port show {{ port_name }} > /dev/null 2>&1; then
|
||||
openstack port create \
|
||||
--network {{ lb_mgmt_prefix }}-backbone-net \
|
||||
{{ port_name }}
|
||||
fi
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
port_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router-port"
|
||||
register: result
|
||||
changed_when: "'created_at' in result.stdout"
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
||||
|
||||
- name: Add ports to lb-mgmt routers
|
||||
shell: |
|
||||
port_id=$(openstack port show {{ port_name }} -f value -c id)
|
||||
if ! openstack router show {{ router_name }} -f json -c interfaces_info | \
|
||||
jq -r ".interfaces_info[].port_id" | grep -q $port_id; then
|
||||
openstack router add port \
|
||||
{{ router_name }} \
|
||||
{{ port_name }}
|
||||
echo "port added"
|
||||
fi
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
port_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router-port"
|
||||
router_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router"
|
||||
register: result
|
||||
changed_when: "'port added' in result.stdout"
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
||||
|
||||
- name: Get addresses of lb-mgmt ports
|
||||
shell: |
|
||||
openstack port show {{ port_name }} -c fixed_ips -f json | \
|
||||
jq -r .fixed_ips[0].ip_address
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
port_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router-port"
|
||||
register: port_addresses
|
||||
changed_when: false
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
||||
|
||||
- name: Get CIDRs of lb-mgmt subnets
|
||||
shell: |
|
||||
openstack subnet show {{ subnet_name }} -c cidr -f value
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
subnet_name: "{{ lb_mgmt_prefix }}{{ network_item }}-subnet"
|
||||
register: subnet_cidrs
|
||||
changed_when: false
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
||||
|
||||
- name: Add routes to lb-mgmt routers
|
||||
shell: |
|
||||
openstack router set \
|
||||
--no-route \
|
||||
{% for address in port_addresses.results %}{% if item != address.item %}--route destination={% for cidr in subnet_cidrs.results %}{% if address.item == cidr.item %}{{ cidr.stdout }}{% endif %}{% endfor %},gateway={{ address.stdout }} {% endif %}{% endfor %} \
|
||||
{{ router_name }}
|
||||
vars:
|
||||
network_item: "{% if item != octavia_controller_availability_zone %}-{{ item }}{% endif %}"
|
||||
router_name: "{{ lb_mgmt_prefix }}{{ network_item }}-router"
|
||||
loop: "{{ octavia_availability_zones | list }}"
|
Loading…
Reference in New Issue