64 lines
1.8 KiB
YAML
64 lines
1.8 KiB
YAML
---
|
|
- name: Set bridge interface name
|
|
set_fact:
|
|
br_if: "br_{{ gateway_config.lab_name }}"
|
|
vxlan_if: "vxlan{{ gateway_config.vni }}"
|
|
lab_if: "{{ gateway_config.lab_if }}"
|
|
|
|
- name: Remove existing bridge configuration
|
|
shell: |
|
|
uci delete network.{{ br_if }} 2>/dev/null || true
|
|
uci delete network.{{ br_if }}_dev 2>/dev/null || true
|
|
uci commit network
|
|
changed_when: true
|
|
|
|
- name: Create bridge device
|
|
shell: |
|
|
uci set network.{{ br_if }}_dev='device'
|
|
uci set network.{{ br_if }}_dev.name='{{ br_if }}'
|
|
uci set network.{{ br_if }}_dev.type='bridge'
|
|
uci set network.{{ br_if }}_dev.stp='0'
|
|
uci add_list network.{{ br_if }}_dev.ports='{{ vxlan_if }}'
|
|
uci add_list network.{{ br_if }}_dev.ports='{{ lab_if }}'
|
|
uci commit network
|
|
changed_when: true
|
|
|
|
- name: Create bridge interface
|
|
shell: |
|
|
uci set network.{{ br_if }}='interface'
|
|
uci set network.{{ br_if }}.proto='static'
|
|
uci set network.{{ br_if }}.device='{{ br_if }}'
|
|
uci set network.{{ br_if }}.ipaddr='{{ gateway_config.subnet | ipaddr("1") | ipaddr("address") }}'
|
|
uci set network.{{ br_if }}.netmask='{{ gateway_config.subnet | ipaddr("netmask") }}'
|
|
uci commit network
|
|
changed_when: true
|
|
|
|
- name: Reload network configuration
|
|
shell: /etc/init.d/network reload
|
|
changed_when: true
|
|
|
|
- name: Wait for bridge to come up
|
|
shell: ip link show {{ br_if }}
|
|
register: bridge_check
|
|
retries: 10
|
|
delay: 2
|
|
until: bridge_check.rc == 0
|
|
changed_when: false
|
|
|
|
- name: Verify bridge configuration
|
|
shell: |
|
|
echo "=== Bridge Interface ==="
|
|
ip link show {{ br_if }}
|
|
echo ""
|
|
echo "=== Bridge Members ==="
|
|
bridge link show | grep {{ br_if }}
|
|
echo ""
|
|
echo "=== IP Address ==="
|
|
ip addr show {{ br_if }}
|
|
register: bridge_status
|
|
changed_when: false
|
|
|
|
- name: Display bridge status
|
|
debug:
|
|
var: bridge_status.stdout_lines
|