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_03.yml
│ └── iocage_04.yml
├── iocage.ini
├── pb-loader.yml
└── pb-network.yml
Synopsis¶
Configure
/boot/loader.confConfigure bridges.
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_03 ansible_host=10.1.0.17
iocage_04 ansible_host=10.1.0.29
[iocage]
iocage_03
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_03.yml¶
fn_cloned_interfaces:
- {interface: bridge0, state: value_present}
fn_interfaces:
- {interface: bridge0, options: inet 10.1.0.17/24, create: addm em0}
- {interface: em0, options: up -tso -vlanhwtso}
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]
ok: [iocage_03]
TASK [vbotka.freebsd.postinstall : Loader: Backup orig /boot/loader.conf] ******
ok: [iocage_04]
ok: [iocage_03]
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'})
changed: [iocage_03] => (item={'name': 'net.link.bridge.pfil_member', 'value': '0'})
changed: [iocage_03] => (item={'name': 'net.link.bridge.pfil_bridge', 'value': '0'})
changed: [iocage_03] => (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'})
changed: [iocage_03] => (item={'name': 'if_bridge', 'value': 'YES'})
TASK [vbotka.freebsd.postinstall : Loader: Get sysctls settable via loader.] ***
ok: [iocage_04]
ok: [iocage_03]
RUNNING HANDLER [vbotka.freebsd.postinstall : Loader message reboot] ***********
ok: [iocage_03] =>
msg: '[MESSAGE] Reboot to activate configuration in /boot/loader.conf'
PLAY RECAP *********************************************************************
iocage_03 : ok=6 changed=2 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
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]
ok: [iocage_03]
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'})
ok: [iocage_03] => (item={'interface': 'bridge0', 'options': 'inet 10.1.0.17/24', 'create': 'addm em0'})
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'})
ok: [iocage_03] => (item={'interface': 'bridge0', 'options': 'inet 10.1.0.17/24', 'create': 'addm em0'})
ok: [iocage_03] => (item={'interface': 'em0', 'options': 'up -tso -vlanhwtso'})
TASK [vbotka.freebsd.network : Cloned-interfaces: Configure cloned_interfaces in /etc/rc.conf] ***
ok: [iocage_04]
ok: [iocage_03]
TASK [vbotka.freebsd.network : Routing: Set defaultrouter in /etc/rc.conf] *****
ok: [iocage_04]
ok: [iocage_03]
TASK [vbotka.freebsd.network : Routing: Set gateway_enable=YES in /etc/rc.conf] ***
ok: [iocage_04]
ok: [iocage_03]
TASK [vbotka.freebsd.network : Routing: Remove list of static routes from /etc/rc.conf] ***
ok: [iocage_04]
ok: [iocage_03]
PLAY RECAP *********************************************************************
iocage_03 : ok=7 changed=0 unreachable=0 failed=0 skipped=19 rescued=0 ignored=0
iocage_04 : ok=7 changed=0 unreachable=0 failed=0 skipped=19 rescued=0 ignored=0
Result¶
MACs are sanitized.
(env) > ssh admin@10.1.0.17 ifconfig bridge0
bridge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=0
ether 11:22:33:44:55:66
inet 10.1.0.17 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
member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 1 priority 128 path cost 2000000
groups: bridge
nd6 options=9<PERFORMNUD,IFDISABLED>
(env) > ssh admin@10.1.0.29 ifconfig bridge0
bridge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=0
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
member: vnet0.145 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 18 priority 128 path cost 2000
member: vnet0.144 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 14 priority 128 path cost 2000
member: vnet0.143 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 10 priority 128 path cost 2000
member: igb0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 1 priority 128 path cost 2000000
groups: bridge
nd6 options=9<PERFORMNUD,IFDISABLED>