Add support for Arista switches
Support for invoking Ansible EOS network modules for Arista switches. Change-Id: I3a570adf43e1addce5eeab88e29ae4ded44669f0
This commit is contained in:
parent
45b4961de1
commit
c6263dbfd4
22
ansible/group_vars/all/switches/arista
Normal file
22
ansible/group_vars/all/switches/arista
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
# Switch configuration.
|
||||
|
||||
###############################################################################
|
||||
# Authentication configuration.
|
||||
|
||||
# For Arista switches, this defines a 'provider' argument to the eos_*
|
||||
# modules.
|
||||
switch_arista_provider:
|
||||
host: "{{ ansible_host }}"
|
||||
username: "{{ ansible_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
transport: cli
|
||||
authorize: yes
|
||||
auth_pass: "{{ switch_auth_pass }}"
|
||||
timeout: "{{ switch_arista_timeout }}"
|
||||
|
||||
###############################################################################
|
||||
# Timeout in seconds for completion of the switch config as a transaction
|
||||
switch_arista_timeout: 60
|
||||
|
||||
...
|
@ -24,6 +24,7 @@
|
||||
physical_network_display: False
|
||||
# List of supported values for the 'switch_type' variable.
|
||||
supported_switch_types:
|
||||
- arista
|
||||
- dellos6
|
||||
- dellos9
|
||||
- dell-powerconnect
|
||||
@ -94,6 +95,18 @@
|
||||
debug:
|
||||
var: switch_interface_config
|
||||
|
||||
- name: Ensure Arista physical switches are configured
|
||||
hosts: switches_of_type_arista:&switches_in_display_mode_False
|
||||
gather_facts: no
|
||||
roles:
|
||||
- role: ssh-known-host
|
||||
|
||||
- role: arista-switch
|
||||
arista_switch_type: "{{ switch_type }}"
|
||||
arista_switch_provider: "{{ switch_arista_provider }}"
|
||||
arista_switch_config: "{{ switch_config }}"
|
||||
arista_switch_interface_config: "{{ switch_interface_config }}"
|
||||
|
||||
- name: Ensure DellOS physical switches are configured
|
||||
hosts: switches_of_type_dellos6:switches_of_type_dellos9:&switches_in_display_mode_False
|
||||
gather_facts: no
|
||||
|
81
ansible/roles/arista-switch/README.md
Normal file
81
ansible/roles/arista-switch/README.md
Normal file
@ -0,0 +1,81 @@
|
||||
Arista Switch
|
||||
=============
|
||||
|
||||
This role configures Arista switches using the `eos` Ansible
|
||||
modules. It provides a fairly minimal abstraction of the configuration
|
||||
interface provided by the `eos` modules, allowing for application of
|
||||
arbitrary switch configuration options.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
The Ansible network modules for Arista require EOS 4.15 or later.
|
||||
|
||||
The switches should be configured to allow SSH access.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
`arista_switch_provider` is authentication provider information passed as the
|
||||
`provider` argument to the `eos` modules.
|
||||
|
||||
`arista_switch_config` is a list of configuration lines to apply to the switch,
|
||||
and defaults to an empty list.
|
||||
|
||||
`arista_switch_interface_config` contains interface configuration. It is a dict
|
||||
mapping switch interface names to configuration dicts. Each dict may contain
|
||||
the following items:
|
||||
|
||||
- `description` - a description to apply to the interface.
|
||||
- `config` - a list of per-interface configuration.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
None
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
The following playbook configures hosts in the `arista-switches` group.
|
||||
It assumes host variables for each switch holding the host, username and
|
||||
passwords. It applies global configuration for LLDP, and enables two
|
||||
10G ethernet interfaces as switchports.
|
||||
|
||||
---
|
||||
- name: Ensure Arista switches are configured
|
||||
hosts: arista-switches
|
||||
gather_facts: no
|
||||
roles:
|
||||
- role: arista-switch
|
||||
arista_switch_provider:
|
||||
host: "{{ switch_host }}"
|
||||
username: "{{ switch_user }}"
|
||||
password: "{{ switch_password }}"
|
||||
transport: cli
|
||||
authorize: yes
|
||||
auth_pass: "{{ switch_auth_pass }}"
|
||||
timeout: 60
|
||||
arista_switch_config:
|
||||
- "lldp run"
|
||||
- "lldp tlv-select system-name"
|
||||
- "lldp tlv-select management-address"
|
||||
- "lldp tlv-select port-description"
|
||||
arista_switch_interface_config:
|
||||
Et4/5:
|
||||
description: server-1
|
||||
config:
|
||||
- "no shutdown"
|
||||
- "switchport"
|
||||
Et4/7:
|
||||
description: server-2
|
||||
config:
|
||||
- "no shutdown"
|
||||
- "switchport"
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
- Stig Telfer (<stig@stackhpc.com>)
|
||||
|
||||
Based on the dell-switch role by Mark Goddard (<mark@stackhpc.com>)
|
11
ansible/roles/arista-switch/defaults/main.yml
Normal file
11
ansible/roles/arista-switch/defaults/main.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
# Authentication provider information.
|
||||
arista_switch_provider:
|
||||
|
||||
# List of configuration lines to apply to the switch.
|
||||
arista_switch_config: []
|
||||
|
||||
# Interface configuration. Dict mapping switch interface names to configuration
|
||||
# dicts. Each dict contains a 'description' item and a 'config' item which
|
||||
# should contain a list of per-interface configuration.
|
||||
arista_switch_interface_config: {}
|
6
ansible/roles/arista-switch/tasks/main.yml
Normal file
6
ansible/roles/arista-switch/tasks/main.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Ensure Arista switches are configured
|
||||
local_action:
|
||||
module: eos_config
|
||||
provider: "{{ arista_switch_provider }}"
|
||||
src: arista-config.j2
|
17
ansible/roles/arista-switch/templates/arista-config.j2
Normal file
17
ansible/roles/arista-switch/templates/arista-config.j2
Normal file
@ -0,0 +1,17 @@
|
||||
#jinja2: trim_blocks: True,lstrip_blocks: True
|
||||
|
||||
{% for line in arista_switch_config %}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
|
||||
{% for interface, config in
|
||||
arista_switch_interface_config.items() %}
|
||||
interface {{ interface }}
|
||||
{% if config.description is defined %}
|
||||
description {{ config.description }}
|
||||
{% endif %}
|
||||
{% for line in config.config %}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
exit
|
||||
{% endfor %}
|
6
releasenotes/notes/arista-switch-aedc46148506c56e.yaml
Normal file
6
releasenotes/notes/arista-switch-aedc46148506c56e.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds support for configuration of Arista switches running EOS 4.15 or
|
||||
later. This is integrated with the `kayobe physical network configure`
|
||||
command.
|
Loading…
Reference in New Issue
Block a user