Skip to content

Commit

Permalink
Create the br-lbaas network automatically (#27)
Browse files Browse the repository at this point in the history
This will create the bridge network, set up the veth pairs,
and use the values to configure a subsequent os-octavia run
  • Loading branch information
xgerman authored Apr 6, 2018
1 parent 3cc2f7b commit 64c064e
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 156 deletions.
17 changes: 0 additions & 17 deletions playbooks/files/aio/octavia_interfaces.cfg

This file was deleted.

108 changes: 0 additions & 108 deletions playbooks/files/aio/openstack_user_config.yml.j2

This file was deleted.

27 changes: 22 additions & 5 deletions playbooks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
tags:
- always

- include: rpc-octavia-aio.yml
when: lookup('env', 'DEPLOY_AIO') == "yes"
tags:
- octavia-setup

- include: rpc-octavia-generate-certs.yml
tags:
- octavia-setup
Expand Down Expand Up @@ -69,3 +64,25 @@
- octavia-setup
- skip_ansible_lint

- include: rpc-octavia-configure-network.yml
tags:
- octavia-network-configuration
when: configure_network|bool == True

- name: Setup Octavia network
hosts: octavia-infra_hosts
user: root
tasks:
- name: Gather variables
include_vars: "{{ item }}"
with_items:
- 'vars/main.yml'
- 'group_vars/octavia_all.yml'
- 'group_vars/all/octavia.yml'
tags:
- always
- include: rpc-setup-network.yml
when: setup_network|bool == True
tags:
- octavia-network-setup

35 changes: 16 additions & 19 deletions playbooks/rpc-octavia-aio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Copy Octavia conf.d file
template:
src: 'templates/octavia.yml.aio.j2'
dest: '/etc/openstack_deploy/conf.d/octavia.yml'
- name: Setup Octavia install
hosts: localhost
user: root
tasks:
- name: Gather variables
include_vars: "{{ item }}"
with_items:
- 'vars/main.yml'
- 'group_vars/octavia_all.yml'
- 'group_vars/all/octavia.yml'
tags:
- always

# Create our own bridge
- name: Copy Octavia interface file
copy:
src: 'files/aio/octavia_interfaces.cfg'
dest: '/etc/network/interfaces.d/octavia_interfaces.cfg'

# Template and overwrite -- this is AIO so no need to be overly careful
- name: Overwrite openstack_user_config.yml
template:
src: 'files/aio/openstack_user_config.yml.j2'
dest: '/etc/openstack_deploy/openstack_user_config.yml'

# Start the bridge
- name: Start the br-lbaas bridge
command: "ifup br-lbaas"
- name: Copy Octavia conf.d file
template:
src: 'templates/octavia.yml.aio.j2'
dest: '/etc/openstack_deploy/conf.d/octavia.yml'


60 changes: 60 additions & 0 deletions playbooks/rpc-octavia-configure-network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

---
# 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.

- name: Load openstack_user_config.yml and create network entry
set_fact:
octavia_net: "{{ lookup('file', '/etc/openstack_deploy/openstack_user_config.yml')|from_yaml }}"
network:
network:
container_bridge: br-lbaas
container_type: veth
container_interface: eth14
host_bind_override: eth14
ip_from_q: lbaas
type: raw
net_name: lbaas
group_binds:
- octavia-worker
- octavia-housekeeping
- octavia-health-manager

- name: Prepare lbaas cidr, used-ips, and provider networks
set_fact:
cidr_networks: "{{ octavia_net.cidr_networks|combine({'lbaas': br_lbaas_prefix+'.0/22'}) }}"
used_ips: "{{ octavia_net.used_ips + [br_lbaas_prefix+'.1,'+br_lbaas_prefix+'.50', br_lbaas_prefix+'.100'] }}"
provider_networks: '{{ octavia_net.global_overrides.provider_networks + [network] }}'

- name: Combine cidr_networks
set_fact:
octavia_net: "{{ octavia_net|combine({'cidr_networks':cidr_networks}) }}"

- name: Combine used_ips
set_fact:
octavia_net: "{{ octavia_net|combine({'used_ips':used_ips}) }}"

- name: Combine provider_network
set_fact:
global_overrides: "{{ octavia_net.global_overrides|combine({'provider_networks':provider_networks}) }}"

- name: Combine global_overrides
set_fact:
octavia_net: "{{ octavia_net|combine({'global_overrides':global_overrides}) }}"

- name: Write massaged network definiton back to openstack_user_config
copy:
dest: /etc/openstack_deploy/openstack_user_config.yml
backup: yes
content: "---\n{{ octavia_net | to_nice_yaml }}"
18 changes: 18 additions & 0 deletions playbooks/rpc-octavia-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@
octavia_enable_anti_affinity: {{ lookup('env', 'DEPLOY_AIO') != "yes" }}
# make TRUE to gain SSH access to the amphora
octavia_ssh_enabled: False # Chnage to true if ssh debugging is needed
{% if configure_network %}
# Name of the Octavia management network in Neutron
octavia_neutron_management_network_name: lbaas-mgmt
# Name of the provider net in the system
octavia_provider_network_name: vlan
octavia_provider_segmentation_id: "{{ vlan_id }}"
# this is the name used in openstack_user_config.yml with '_address' added
octavia_container_network_name: lbaas_address
# Network type
octavia_provider_network_type: vlan
# Network CIDR
octavia_management_net_subnet_cidr: {{ br_lbaas_prefix }}.0/22
{% endif %}
40 changes: 40 additions & 0 deletions playbooks/rpc-setup-network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

---
# 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.

- name: Write bridge definition
copy:
dest: /etc/network/interfaces.d/br-lbaas.cfg
content: |
auto br-lbaas
iface br-lbaas inet static
post-up /usr/local/bin/configure_br-lbaas_veth.sh
bridge_stp off
bridge_waitport 0
bridge_fd 0
bridge_ports none
address {{ br_lbaas_prefix }}.100
netmask 255.255.252.0
offload-sg off
- name: Create post-up script
template:
src: 'templates/configure_br-lbaas_veth.sh.j2'
dest: '/usr/local/bin/configure_br-lbaas_veth.sh'
mode: '0775'

- name: Bring up interface
command: "ifup br-lbaas"

11 changes: 11 additions & 0 deletions playbooks/templates/configure_br-lbaas_veth.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
VLAN_ID={{ vlan_id }}

# This sets up the link
ip link add v-br-vlan type veth peer name v-br-lbaas
ip link add link v-br-lbaas name v-br-lbaas.{{ vlan_id }} type vlan id {{ vlan_id }}
ip link set v-br-vlan up
ip link set v-br-lbaas up
ip link set v-br-lbaas.{{ vlan_id }} up
brctl addif br-lbaas v-br-lbaas.{{ vlan_id }}
brctl addif br-vlan v-br-vlan
8 changes: 8 additions & 0 deletions playbooks/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ octavia_num_secgroups: "{{ octavia_num_instances }}"
octavia_num_ports: "{{ octavia_num_instances*10 }}" # at least instances * 10
octavia_num_security_group_rules: 100

# network
setup_network: True
configure_network: True
vlan_id: 111
br_lbaas_prefix: 10.0.252 #first three number blocks




11 changes: 4 additions & 7 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@ set -o pipefail
export BASE_DIR=${BASE_DIR:-"/opt/rpc-openstack"}
source ${BASE_DIR}/scripts/functions.sh

#install octavoa file into conf.d
if [[ "${DEPLOY_AIO}" == "yes" ]]; then
run_ansible /opt/rpc-octavia/playbooks/rpc-octavia-aio.yml
fi
# setup Octavia
run_ansible /opt/rpc-octavia/playbooks/main.yml -e "download_artefact=${AMP_DOWNLOAD:-True}"

cd /opt/rpc-openstack/openstack-ansible/playbooks/

#rebuild neutron-agent container networking if deploying AIO
if [[ "${DEPLOY_AIO}" == "yes" ]]; then
run_ansible lxc-containers-create.yml -e 'lxc_container_allow_restarts=false' --limit neutron_agents_container
# wire up network
run_ansible os-neutron-install.yml
fi

# build container
run_ansible lxc-containers-create.yml -e 'lxc_container_allow_restarts=false' --limit 'octavia_all,octavia-infra_all'

Expand Down

0 comments on commit 64c064e

Please sign in to comment.