stackhpc.ansible-role-mellanox-switch
Mellanox Switch
This guide helps you set up Mellanox switches that use MLNX-OS with Ansible's expect module.
This role will install the Python expect
package on your local machine.
Requirements
The switches need to be set up for SSH access.
Role Variables
mellanox_switch_provider
is the information needed to log in, similar to the provider
argument in the dellos
modules. It should be a dictionary with these fields:
host
: the hostname or IP address of the switch.username
: the username for SSH access to the switch.auth_pass
: the password for logging in.
mellanox_switch_config
is a list of commands to apply to the switch. It starts off as an empty list.
mellanox_switch_interface_config
holds settings for interfaces. It is a dictionary that matches switch interface names to their configuration. Each entry can include:
description
: a description for the interface.config
: a list of specific settings for that interface.
Dependencies
None
Example Playbook
Here is an example playbook that sets up switches in the mellanox-switches
group. It assumes that each switch has host variables for the host, username, and passwords. The playbook applies a global setting for VLAN 42 and enables two Ethernet interfaces as access ports.
---
- 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.ansible-role-mellanox-switch