diff --git a/docs/examples.md b/docs/examples.md index ef188fa..61a6a69 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -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" %} diff --git a/docs/examples/bridge-interfaces-by-description/captured.yaml b/docs/examples/bridge-interfaces-by-description/captured.yaml new file mode 100644 index 0000000..19d2e80 --- /dev/null +++ b/docs/examples/bridge-interfaces-by-description/captured.yaml @@ -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 diff --git a/docs/examples/bridge-interfaces-by-description/current.yaml b/docs/examples/bridge-interfaces-by-description/current.yaml new file mode 100644 index 0000000..8984aed --- /dev/null +++ b/docs/examples/bridge-interfaces-by-description/current.yaml @@ -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 diff --git a/docs/examples/bridge-interfaces-by-description/generated.yaml b/docs/examples/bridge-interfaces-by-description/generated.yaml new file mode 100644 index 0000000..681de3d --- /dev/null +++ b/docs/examples/bridge-interfaces-by-description/generated.yaml @@ -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 diff --git a/docs/examples/bridge-interfaces-by-description/policy.md b/docs/examples/bridge-interfaces-by-description/policy.md new file mode 100644 index 0000000..6d4b22e --- /dev/null +++ b/docs/examples/bridge-interfaces-by-description/policy.md @@ -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 %}