stackhpc.mellanox-switch
Mellanox Switch
This guide explains how to set up Mellanox switches using Ansible's expect module.
This setup will also install the Python expect
package on your local machine.
Requirements
Make sure the switches are set up to allow SSH access.
Role Variables
mellanox_switch_provider
contains information for logging in, similar to the provider
used in dellos
modules. It should include:
host
: the IP address or hostname of the switch.username
: the SSH username for accessing the switch.auth_pass
: the password for login.
mellanox_switch_config
is a list of commands to run on the switch. It starts as an empty list.
mellanox_switch_interface_config
holds settings for each interface. It's a dictionary linking interface names to their configurations. Each entry can have:
description
: a label for the interface.config
: a list of settings for that interface.
Dependencies
None
Example Playbook
This playbook configures switches in the mellanox-switches
group. It expects variables that contain each switch's host, username, and password. It sets up global settings for VLAN 42 and enables two Ethernet ports in access mode.
---
- name: Ensure Mellanox switches are configured
hosts: mellanox-switches
gather_facts: no
roles:
- role: stackhpc.mellanox-switch
mellanox_switch_provider:
host: "{{ switch_host }}"
username: "{{ switch_user }}"
auth_pass: "{{ switch_auth_pass }}"
mellanox_switch_config:
- "vlan 42"
- "exit"
mellanox_switch_interface_config:
ethernet 1/1:
description: server-1
config:
- "no shutdown"
- "switchport mode access"
ethernet 1/2:
description: server-2
config:
- "no shutdown"
- "switchport mode access"
Author Information
- Mark Goddard (mark@stackhpc.com)
Role to configure Mellanox switches runnning MLNX-OS
ansible-galaxy install stackhpc.mellanox-switch