arista.eos.eos_interfaces module – Interfaces resource module

Note

This module is part of the arista.eos collection (version 9.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

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

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

New in arista.eos 1.0.0

Synopsis

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

Aliases: interfaces

Parameters

Parameter

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

Administrative state of the interface.

Set the value to true to administratively enable the interface or false to disable it.

Choices:

  • false

  • true ← (default)

mode

string

Manage Layer2 or Layer3 state of the interface. Applicable for Ethernet and port channel interfaces only.

Choices:

  • "layer2"

  • "layer3"

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

The state of the configuration after module completion.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "parsed"

  • "rendered"

  • "gathered"

Notes

Note

Examples

# Using merged

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

- 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

# Task Output
# -----------
#
# before:
# - enabled: true
#   name: Ethernet1
# - enabled: true
#   name: Ethernet2
# - enabled: true
#   name: Management1
# commands:
# - interface Ethernet1
# - no switchport
# - interface Ethernet2
# - shutdown
# - description Configured by Ansible
# after:
# - enabled: true
#   mode: layer3
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
#    no switchport
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using replaced

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
#    no switchport
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

- 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

# Task Output
# -----------
#
# before:
# - enabled: true
#   mode: layer3
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1
# commands:
# - interface Ethernet1
# - switchport
# after:
# - enabled: true
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using overridden

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

- 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

# Task Output
# -----------
#
# before:
# - enabled: true
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1
# commands:
# - interface Management1
# - no shutdown
# after:
# - enabled: true
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using deleted

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

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

# Task Output
# -----------
#
# before:
# - enabled: true
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1
# commands:
# - interface Ethernet1
# - no shutdown
# after:
# - enabled: true
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using rendered

- name: Render the provided configuration into platform specific configuration lines
  arista.eos.eos_interfaces:
    config:
      - name: Ethernet1
        enabled: true
        mode: layer3
      - name: Ethernet2
        description: Configured by Ansible
        enabled: false
    state: rendered

# Module Execution Result:
# ------------------------
#
# rendered:
# - interface Ethernet1
# - no shutdown
# - no switchport
# - interface Ethernet2
# - shutdown
# - description Configured by Ansible

# Using Parsed

# File: parsed.cfg
# ----------------
#
# interface Ethernet1
#    description "Interface 1"
# !
# interface Ethernet2
#    description "Configured by Ansible"
#    shutdown
# !

- name: Parse the commands for provided configuration
  arista.eos.interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

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

# Using Gathered

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

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

# Module Execution Result:
# ------------------------
#
# gathered:
# - enabled: true
#   name: Ethernet1
# - description: Configured by Ansible
#   enabled: false
#   name: Ethernet2
# - enabled: true
#   name: Management1

Return Values

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

Key

Description

after

dictionary

The resulting configuration after module execution.

Returned: when changed

Sample: "This output will always be in the same format as the module argspec.\n"

before

dictionary

The configuration prior to the module execution.

Returned: when state is merged, replaced, overridden, deleted or purged

Sample: "This output will always be in the same format as the module argspec.\n"

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: when state is merged, replaced, overridden, deleted or purged

Sample: ["interface Ethernet1", "no shutdown", "no switchport"]

gathered

list / elements=string

Facts about the network resource gathered from the remote device as structured data.

Returned: when state is gathered

Sample: ["This output will always be in the same format as the module argspec.\n"]

parsed

list / elements=string

The device native config provided in running_config option parsed into structured data as per module argspec.

Returned: when state is parsed

Sample: ["This output will always be in the same format as the module argspec.\n"]

rendered

list / elements=string

The provided configuration in the task rendered in device-native format (offline).

Returned: when state is rendered

Sample: ["interface Ethernet1", "no shutdown", "no switchport"]

Authors

  • Nathaniel Case (@Qalthos)