W3cubDocs

/Ansible 2.11

arista.eos.eos_interfaces – Interfaces resource module

Note

This plugin is part of the arista.eos collection (version 1.3.0).

To install it use: ansible-galaxy collection install arista.eos.

To use it in a playbook, specify: arista.eos.eos_interfaces.

New in version 1.0.0: of arista.eos

Synopsis

  • This module manages the interface attributes of Arista EOS interfaces.

Note

This module has a corresponding action plugin.

Parameters

Parameter Choices/Defaults Comments
config
list / elements=dictionary
The provided configuration
description
string
Interface description
duplex
string
Interface link status. Applicable for Ethernet interfaces only.
Values other than auto must also set speed.
Ignored when speed is set above 1000.
enabled
boolean
    Choices:
  • no
  • yes
Administrative state of the interface.
Set the value to true to administratively enable the interface or false to disable it.
mode
string
    Choices:
  • layer2
  • layer3
Manage Layer2 or Layer3 state of the interface. Applicable for Ethernet and port channel interfaces only.
mtu
integer
MTU for a specific interface. Must be an even number between 576 and 9216. Applicable for Ethernet interfaces only.
name
string / required
Full name of the interface, e.g. GigabitEthernet1.
speed
string
Interface link speed. Applicable for Ethernet interfaces only.
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the EOS device by executing the command show running-config | section ^interface.
The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the parsed key within the result.
state
string
    Choices:
  • merged
  • replaced
  • overridden
  • deleted
  • parsed
  • rendered
  • gathered
The state of the configuration after module completion.

Notes

Note

  • Tested against Arista EOS 4.20.10M
  • This module works with connection network_cli. See the EOS Platform Options.

Examples

# Using merged

# Before state:
# -------------
#
# veos#show running-config | section interface
# interface Ethernet1
#    description "Interface 1"
# !
# interface Ethernet2
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

- name: Merge provided configuration with device configuration
  arista.eos.eos_interfaces:
    config:
    - name: Ethernet1
      enabled: true
      mode: layer3
    - name: Ethernet2
      description: Configured by Ansible
      enabled: false
    state: merged

# After state:
# ------------
#
# veos#show running-config | section interface
# interface Ethernet1
#    description "Interface 1"
#    no switchport
# !
# interface Ethernet2
#    description "Configured by Ansible"
#    shutdown
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

# Using replaced

# Before state:
# -------------
#
# veos#show running-config | section interface
# interface Ethernet1
#    description "Interface 1"
# !
# interface Ethernet2
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

- name: Replaces device configuration of listed interfaces with provided configuration
  arista.eos.eos_interfaces:
    config:
    - name: Ethernet1
      enabled: true
    - name: Ethernet2
      description: Configured by Ansible
      enabled: false
    state: replaced

# After state:
# ------------
#
# veos#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description "Configured by Ansible"
#    shutdown
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

# Using overridden

# Before state:
# -------------
#
# veos#show running-config | section interface
# interface Ethernet1
#    description "Interface 1"
# !
# interface Ethernet2
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

- name: Overrides all device configuration with provided configuration
  arista.eos.eos_interfaces:
    config:
    - name: Ethernet1
      enabled: true
    - name: Ethernet2
      description: Configured by Ansible
      enabled: false
    state: overridden

# After state:
# ------------
#
# veos#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description "Configured by Ansible"
#    shutdown
# !
# interface Management1
#    ip address dhcp
# !

# Using deleted

# Before state:
# -------------
#
# veos#show running-config | section interface
# interface Ethernet1
#    description "Interface 1"
#    no switchport
# !
# interface Ethernet2
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

- name: Delete or return interface parameters to default settings
  arista.eos.eos_interfaces:
    config:
    - name: Ethernet1
    state: deleted

# After state:
# ------------
#
# veos#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# !
# interface Management1
#    description "Management interface"
#    ip address dhcp
# !

# Using rendered

- name: Use Rendered to convert the structured data to native config
  arista.eos.eos_interfaces:
    config:
    - name: Ethernet1
      enabled: true
      mode: layer3
    - name: Ethernet2
      description: Configured by Ansible
      enabled: false
    state: merged

# Output:
# ------------

# - "interface Ethernet1"
# - "description "Interface 1""
# - "no swithcport"
# - "interface Ethernet2"
# - "description "Configured by Ansible""
# - "shutdown"
# - "interface Management1"
# - "description "Management interface""
# - "ip address dhcp"

# Using parsed
# parsed.cfg

# interface Ethernet1
#    description "Interface 1"
# !
# interface Ethernet2
#    description "Configured by Ansible"
#    shutdown
# !

- name: Use parsed to convert native configs to structured data
  arista.eos.interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Output
# parsed:
#     - name: Ethernet1
#       enabled: True
#       mode: layer2
#     - name: Ethernet2
#       description: 'Configured by Ansible'
#       enabled: False
#       mode: layer2

# Using gathered:

# Existing config on the device
# -----------------------------
# interface Ethernet1
#    description "Interface 1"
# !
# interface Ethernet2
#    description "Configured by Ansible"
#    shutdown
# !

- name: Gather interfaces facts from the device
  arista.eos.interfaces:
    state: gathered

# output
# gathered:
#      - name: Ethernet1
#        enabled: True
#        mode: layer2
#      - name: Ethernet2
#        description: 'Configured by Ansible'
#        enabled: False
#        mode: layer2

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
after
dictionary
when changed
The configuration as structured data after module completion.

Sample:
The configuration returned will always be in the same format of the parameters above.
before
dictionary
always
The configuration as structured data prior to module invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
commands
list / elements=string
always
The set of commands pushed to the remote device.

Sample:
['interface Ethernet2', 'shutdown', 'speed 10full']


Authors

  • Nathaniel Case (@qalthos)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/arista/eos/eos_interfaces_module.html