Skip to content

Commit

Permalink
examples: Add bridge by description
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Llorente <[email protected]>
  • Loading branch information
qinqon committed Oct 10, 2022
1 parent 2a7d564 commit d619f00
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ It uses the `description` field to filter between primary and secondary NIC.
## Turn LLDP to true at interfaces active interfaces

{% include_relative examples/example.md example="all-ethernet-up" %}

## Create a linux-bridge with all the interfaces matching description

{% include_relative examples/example.md example="bridge-interfaces-by-description" %}
22 changes: 22 additions & 0 deletions docs/examples/bridge-interfaces-by-description/captured.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
primary-nic:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth0
description: primary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
secondary-nic:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth1
description: secondary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:02
11 changes: 11 additions & 0 deletions docs/examples/bridge-interfaces-by-description/current.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
interfaces:
- name: eth0
description: primary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
- name: eth1
description: secondary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:02
15 changes: 15 additions & 0 deletions docs/examples/bridge-interfaces-by-description/generated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interfaces:
- bridge:
options:
stp:
enabled: false
port:
- name: eth0
- name: eth1
ipv4:
dhcp: true
enabled: true
mac-address: 00:00:5E:00:00:01
name: br1
state: up
type: linux-bridge
21 changes: 21 additions & 0 deletions docs/examples/bridge-interfaces-by-description/policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% raw %}
capture:
primary-nic: interfaces.description == "primary"
secondary-nic: interfaces.description == "secondary"
desiredState:
interfaces:
- name: br1
type: linux-bridge
state: up
mac-address: "{{ capture.primary-nic.interfaces.0.mac-address }}"
ipv4:
dhcp: true
enabled: true
bridge:
options:
stp:
enabled: false
port:
- name: "{{ capture.primary-nic.interfaces.0.name }}"
- name: "{{ capture.secondary-nic.interfaces.0.name }}"
{% endraw %}

0 comments on commit d619f00

Please sign in to comment.