devstack-gate/playbooks/roles/ovs_vxlan_bridge_primary/tasks/main.yaml

57 lines
2.0 KiB
YAML

- name: Create bridge
openvswitch_bridge:
bridge: "{{ bridge_name }}"
- when: ovs_bridge_mtu is not defined
block:
- name: Determine bridge mtu
shell: |
# Find all interfaces with a permanent mac address type.
# Permanent mac addrs imply "real" hardware and not interfaces we have
# created through this system. This makes our MTU determination mostly
# idempotent allowing us to create multiple overlays without
# perpetually smaller MTUs.
SMALLEST_MTU=""
for X in $(ls /sys/class/net) ; do
MAC_TYPE=$(cat "/sys/class/net/${X}/addr_assign_type")
if [ "$MAC_TYPE" -ne "0" ] ; then
# Type 0 is a permanent address implying a "real"
# interface. We ignore other interfaces as that is what we
# create here
continue
fi
MTU=$(cat "/sys/class/net/${X}/mtu")
if [ -z "$SMALLEST_MTU" ] || [ "$SMALLEST_MTU" -gt "$MTU" ] ; then
SMALLEST_MTU=$MTU
fi
done
# 50 byte overhead for vxlan
echo $(( SMALLEST_MTU - 50 ))
args:
executable: /bin/bash
environment:
PATH: '{{ ansible_env.PATH }}:/bin:/sbin:/usr/sbin'
register: mtu_output
- name: Set ovs_bridge_mtu
set_fact:
ovs_bridge_mtu: "{{ mtu_output.stdout }}"
- name: Set bridge MTU
command: ip link set mtu {{ ovs_bridge_mtu }} dev {{ bridge_name }}
- when: set_ips
block:
- name: Verify if the bridge address is set
shell: ip addr show dev {{ bridge_name }} | grep -q {{ pub_addr_prefix }}.{{ ovs_starting_offset }}/{{ pub_addr_mask }}
register: ip_addr_var
failed_when: False
changed_when: False
- name: Set the bridge address
command: ip addr add {{ pub_addr_prefix }}.{{ ovs_starting_offset }}/{{ pub_addr_mask }} dev {{ bridge_name }}
become: yes
when: ip_addr_var.rc == 1
- name: Bring bridge interface up
command: ip link set dev {{ bridge_name }} up