From ef0a6f9594a4ee417961b631afbe2650597c0cce Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Thu, 28 Mar 2024 12:47:50 +0100 Subject: [PATCH] Add support for Cumulus NVUE switches Change-Id: I900e3000e492b4eb668815ee6789c9d6e3637c68 --- ansible/physical-network.yml | 11 +++ ansible/roles/nvue-switch/README.md | 75 +++++++++++++++++++ ansible/roles/nvue-switch/defaults/main.yml | 9 +++ ansible/roles/nvue-switch/tasks/main.yml | 5 ++ .../nvue-switch/templates/nclu-config.j2 | 13 ++++ .../reference/physical-network.rst | 15 +++- .../cumulus-nvue-switch-9f52d701f6c49712.yaml | 7 ++ 7 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/nvue-switch/README.md create mode 100644 ansible/roles/nvue-switch/defaults/main.yml create mode 100644 ansible/roles/nvue-switch/tasks/main.yml create mode 100644 ansible/roles/nvue-switch/templates/nclu-config.j2 create mode 100644 releasenotes/notes/cumulus-nvue-switch-9f52d701f6c49712.yaml diff --git a/ansible/physical-network.yml b/ansible/physical-network.yml index 1be7bbb3c..90445d5cf 100644 --- a/ansible/physical-network.yml +++ b/ansible/physical-network.yml @@ -32,6 +32,7 @@ - junos - mellanox - nclu + - nvue - openvswitch tasks: - name: Fail if both interface name and description limits are specified @@ -170,3 +171,13 @@ - role: nclu-switch nclu_switch_config: "{{ switch_config }}" nclu_switch_interface_config: "{{ switch_interface_config }}" + +- name: Ensure Cumulus physical switches are configured with NVUE + hosts: switches_of_type_nvue:&switches_in_display_mode_False + gather_facts: no + roles: + - role: ssh-known-host + + - role: nvue-switch + nclu_switch_config: "{{ switch_config }}" + nclu_switch_interface_config: "{{ switch_interface_config }}" diff --git a/ansible/roles/nvue-switch/README.md b/ansible/roles/nvue-switch/README.md new file mode 100644 index 000000000..f7f612743 --- /dev/null +++ b/ansible/roles/nvue-switch/README.md @@ -0,0 +1,75 @@ +NVUE Switch +=========== + +This role configures Cumulus switches using the `nvue` Ansible module. It +provides a fairly minimal abstraction of the configuration interface provided +by the `nvue` module, allowing for application of arbitrary switch +configuration options. + +Requirements +------------ + +The switches should be configured to allow SSH access. + +Role Variables +-------------- + +`nvue_switch_config` is a list of NCLU commands to apply to the switch, and +defaults to an empty list. Commands must be formatted without the `nv` prefix, +which is added by the `nvue` module before execution on the switch. + +`nvue_switch_interface_config` contains interface configuration. It is a dict +mapping switch interface names to configuration dicts. Interfaces can be switch +physical interfaces, but also special interfaces such as bridges or bonds. Each +dict may contain the following items: + +- `description` - a description to apply to the interface. +- `config` - a list of per-interface configuration, each applied with a `net + add ` prefix. +- `type` - type of interface, e.g. `bond` or `bridge`. If this field is absent, + the `interface` keyword is used. + +Dependencies +------------ + +None + +Example Playbook +---------------- + +The following playbook configures hosts in the `nvue-switches` group. It +applies global configuration to configure a BGP AS and add two EBGP neighbors +using BGP Unnumbered, enables two host interfaces with jumbo frames, and +attaches them to a traditional bridge called `bridge1` configured with an IP +address. + + --- + - name: Ensure Cumulus switches are configured with NVUE + hosts: nvue-switches + gather_facts: no + roles: + - role: nvue-switch + nvue_switch_config: + - "set router bgp autonomous-system 65000" + - "set router bgp neighbor swp51 interface remote-as external" + - "set router bgp neighbor swp52 interface remote-as external" + nvue_switch_interface_config: + swp1: + description: server1 + config: + - "mtu 9000" + swp2: + description: server2 + config: + - "mtu 9000" + bridge1: + type: bridge + config: + - "ip address 10.100.100.1/24" + - "ports swp1" + - "ports swp2" + +Author Information +------------------ + +- Michal Nasiadka () diff --git a/ansible/roles/nvue-switch/defaults/main.yml b/ansible/roles/nvue-switch/defaults/main.yml new file mode 100644 index 000000000..afd05cfda --- /dev/null +++ b/ansible/roles/nvue-switch/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# List of configuration lines to apply to the switch. +nvue_switch_config: [] + +# Interface configuration. Dict mapping switch interface names to configuration +# dicts. Each dict contains a 'description' item, an optional 'type' item +# (default is 'interface'), and a 'config' item which should contain a list of +# per-interface configuration. +nvue_switch_interface_config: {} diff --git a/ansible/roles/nvue-switch/tasks/main.yml b/ansible/roles/nvue-switch/tasks/main.yml new file mode 100644 index 000000000..02037a06d --- /dev/null +++ b/ansible/roles/nvue-switch/tasks/main.yml @@ -0,0 +1,5 @@ +--- +- name: Ensure Cumulus switches are configured with NVUE + nvidia.nvue.command: + template: "{{ lookup('template', 'nvue-config.j2') }}" + atomic: true diff --git a/ansible/roles/nvue-switch/templates/nclu-config.j2 b/ansible/roles/nvue-switch/templates/nclu-config.j2 new file mode 100644 index 000000000..96d1bdc06 --- /dev/null +++ b/ansible/roles/nvue-switch/templates/nclu-config.j2 @@ -0,0 +1,13 @@ +#jinja2: trim_blocks: True,lstrip_blocks: True +{% for line in nclu_switch_config %} +{{ line }} +{% endfor %} + +{% for interface, config in nclu_switch_interface_config.items() %} +{% for line in config.config %} +add {{ config.type | default("interface") }} {{ interface }} {{ line }} +{% endfor %} +{% if config.description is defined %} +add {{ config.type | default("interface") }} {{ interface }} alias {{ config.description }} +{% endif %} +{% endfor %} diff --git a/doc/source/configuration/reference/physical-network.rst b/doc/source/configuration/reference/physical-network.rst index 6ee5cb8ec..803b626f0 100644 --- a/doc/source/configuration/reference/physical-network.rst +++ b/doc/source/configuration/reference/physical-network.rst @@ -17,6 +17,8 @@ The following switch operating systems are currently supported: * Arista EOS * Cumulus Linux (via `Network Command Line Utility (NCLU) `__) +* Cumulus Linux (via `NVIDIA User Experience command line utility (NVUE) + `__) * Dell OS 6 * Dell OS 9 * Dell OS 10 @@ -211,11 +213,20 @@ Configuration for these devices is applied using the ``nclu`` Ansible module. ``switch_type`` should be set to ``nclu``. +Cumulus Linux (with NVUE) +------------------------- + +Configuration for these devices is applied using the ``nvidia.nvue.command`` +Ansible module. + +``switch_type`` should be set to ``nvue``. + SSH configuration ^^^^^^^^^^^^^^^^^ -As with any non-switch host in the inventory, the ``nclu`` module relies on the -default connection parameters used by Ansible: +As with any non-switch host in the inventory, the ``nclu`` and +``nvidia.nvue.command`` modules rely on the default connection parameters used +by Ansible: * ``ansible_host`` is the hostname or IP address. Optional. diff --git a/releasenotes/notes/cumulus-nvue-switch-9f52d701f6c49712.yaml b/releasenotes/notes/cumulus-nvue-switch-9f52d701f6c49712.yaml new file mode 100644 index 000000000..6a481c903 --- /dev/null +++ b/releasenotes/notes/cumulus-nvue-switch-9f52d701f6c49712.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adds support for configuring Cumulus switches using the `NVIDIA User + Experience command line utility (NVUE) + `__. + This is integrated with the ``kayobe physical network configure`` command.