360 Configure bridge

Use case

Use the role vbotka.freebsd.network to configure bridges.

Tree

shell> tree .
.
├── ansible.cfg
├── group_vars
│   └── all
│       └── iocage.yml
├── host_vars
│   └── iocage_04.yml
├── iocage.ini
├── pb-loader.yml
└── pb-network.yml

Synopsis

  • Configure /boot/loader.conf

  • Configure bridge.

Requirements

  • root privilege in the managed nodes.

Notes

TBD

Note

vbotka.freebsd.network is the role network in the collection vbotka.freebsd.
vbotka.freebsd_network is the role freebsd_network in the namespace vbotka.
Please make sure the versions are the same before you switch between them.

ansible.cfg

[defaults]
gathering = explicit
callback_result_format = yaml
display_skipped_hosts = false

[connection]
pipelining = true

Inventory iocage.ini

iocage_04 ansible_host=10.1.0.29

[iocage]
iocage_04

[iocage:vars]
ansible_user=admin
ansible_become=true
ansible_python_interpreter=auto_silent

group_vars

group_vars/all/iocage.yml
fn_gateway_enable: true
fn_defaultrouter: 10.1.0.10

fp_loader_conf_template: ''
fp_loader_conf:
  - {name: net.link.bridge.pfil_member, value: "0"}
  - {name: net.link.bridge.pfil_bridge, value: "0"}
  - {name: net.link.bridge.inherit_mac, value: "1"}
fp_loader_conf_modules:
  - {name: if_bridge, value: "YES" }

host_vars

host_vars/iocage_04.yml
fn_cloned_interfaces:
  - {interface: bridge0, state: value_present}
fn_interfaces:
  - {interface: bridge0, options: inet 10.1.0.29/24, create: addm igb0}
  - {interface: igb0, options: up -tso -vlanhwtso}

Playbook pb-loader.yml

- name: Configure loader.conf
  hosts: iocage
  gather_facts: true

  tasks:

    - name: Configure /boot/loader.conf
      ansible.builtin.import_role:
        name: vbotka.freebsd.postinstall
        tasks_from: loader

Playbook output - Configure loader.conf

(env) > ansible-playbook pb-loader.yml -i iocage.ini
PLAY [Configure loader.conf] ***************************************************

TASK [Gathering Facts] *********************************************************
ok: [iocage_04]

TASK [vbotka.freebsd.postinstall : Loader: Backup orig /boot/loader.conf] ******
ok: [iocage_04]

TASK [vbotka.freebsd.postinstall : Loader: Configure by sysctl /boot/loader.conf] ***
ok: [iocage_04] => (item={'name': 'net.link.bridge.pfil_member', 'value': '0'})
ok: [iocage_04] => (item={'name': 'net.link.bridge.pfil_bridge', 'value': '0'})
ok: [iocage_04] => (item={'name': 'net.link.bridge.inherit_mac', 'value': '1'})

TASK [vbotka.freebsd.postinstall : Loader: Configure modules by sysctl /boot/loader.conf] ***
ok: [iocage_04] => (item={'name': 'if_bridge', 'value': 'YES'})

TASK [vbotka.freebsd.postinstall : Loader: Get sysctls settable via loader.] ***
ok: [iocage_04]

PLAY RECAP *********************************************************************
iocage_04                  : ok=5    changed=0    unreachable=0    failed=0    skipped=4    rescued=0    ignored=0   

Playbook pb-network.yml

- name: Configure network.
  hosts: iocage
  gather_facts: true

  roles:
    - vbotka.freebsd.network

Playbook output - Configure network

(env) > ansible-playbook pb-network.yml -i iocage.ini
PLAY [Configure network.] ******************************************************

TASK [Gathering Facts] *********************************************************
ok: [iocage_04]

TASK [vbotka.freebsd.network : Interfaces: Configure interfaces create_args in /etc/rc.conf] ***
ok: [iocage_04] => (item={'interface': 'bridge0', 'options': 'inet 10.1.0.29/24', 'create': 'addm igb0'})

TASK [vbotka.freebsd.network : Interfaces: Configure interfaces options in /etc/rc.conf] ***
ok: [iocage_04] => (item={'interface': 'bridge0', 'options': 'inet 10.1.0.29/24', 'create': 'addm igb0'})
ok: [iocage_04] => (item={'interface': 'igb0', 'options': 'up -tso -vlanhwtso'})

TASK [vbotka.freebsd.network : Cloned-interfaces: Configure cloned_interfaces in /etc/rc.conf] ***
ok: [iocage_04] => (item={'interface': 'bridge0', 'state': 'value_present'})

TASK [vbotka.freebsd.network : Routing: Set defaultrouter in /etc/rc.conf] *****
ok: [iocage_04]

TASK [vbotka.freebsd.network : Routing: Set gateway_enable=YES in /etc/rc.conf] ***
ok: [iocage_04]

TASK [vbotka.freebsd.network : Routing: Remove list of static routes from /etc/rc.conf] ***
ok: [iocage_04]

PLAY RECAP *********************************************************************
iocage_04                  : ok=7    changed=0    unreachable=0    failed=0    skipped=16   rescued=0    ignored=0   

Result

MACs are sanitized.

(env) > ssh admin@10.1.0.29 ifconfig bridge0
bridge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
	options=10<VLAN_HWTAGGING>
	ether 11:22:33:44:55:66
	inet 10.1.0.29 netmask 0xffffff00 broadcast 10.1.0.255
	id 11:22:33:44:55:66 priority 32768 hellotime 2 fwddelay 15
	maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
	root id 11:22:33:44:55:66 priority 32768 ifcost 0 port 0
	bridge flags=0<>
	member: igb0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
	        port 1 priority 128 path cost 2000000 vlan protocol 802.1q
	groups: bridge
	nd6 options=9<PERFORMNUD,IFDISABLED>