vyos.vyos.vyos_lldp_interfaces module – LLDP interfaces resource module

Note

This module is part of the vyos.vyos collection (version 6.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 vyos.vyos.

To use it in a playbook, specify: vyos.vyos.vyos_lldp_interfaces.

New in vyos.vyos 1.0.0

Synopsis

  • This module manages attributes of lldp interfaces on VyOS network devices.

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of LLDP interfaces configurations.

enable

boolean

Disable LLDP on the interfaces.

Choices:

  • false

  • true ← (default)

location

dictionary

LLDP-MED location data.

coordinate_based

dictionary

Coordinate-based location.

altitude

integer

Altitude in meters.

datum

string

Coordinate datum type.

Choices:

  • "WGS84"

  • "NAD83"

  • "MLLW"

latitude

string / required

Latitude.

longitude

string / required

Longitude.

elin

string

Emergency Call Service ELIN number (between 10-25 numbers).

name

string / required

Name of the LLDP interface.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the VyOS device by executing the command show configuration commands | grep lldp.

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"

  • "rendered"

  • "parsed"

  • "gathered"

Notes

Note

  • Tested against VyOS 1.3.8, 1.4.2, the upcoming 1.5, and the rolling release of spring 2025

  • This module works with connection ansible.netcommon.network_cli. See the VyOS OS Platform Options.

Examples

# Using merged
#
# Before state:
# -------------
#
# vyos@vyos:~$ show configuration  commands | grep lldp
#
- name: Merge provided configuration with device configuration
  vyos.vyos.vyos_lldp_interfaces:
    config:
      - name: eth1
        location:
          elin: 0000000911
      - name: eth2
        location:
          coordinate_based:
            altitude: 2200
            datum: WGS84
            longitude: 222.267255W
            latitude: 33.524449N
    state: merged
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": {}
#
#    "commands": [
#        "set service lldp interface eth1 location elin '0000000911'",
#        "set service lldp interface eth1",
#        "set service lldp interface eth2 location coordinate-based latitude '33.524449N'",
#        "set service lldp interface eth2 location coordinate-based altitude '2200'",
#        "set service lldp interface eth2 location coordinate-based datum 'WGS84'",
#        "set service lldp interface eth2 location coordinate-based longitude '222.267255W'",
#        "set service lldp interface eth2 location coordinate-based latitude '33.524449N'",
#        "set service lldp interface eth2 location coordinate-based altitude '2200'",
#        "set service lldp interface eth2 location coordinate-based datum 'WGS84'",
#        "set service lldp interface eth2 location coordinate-based longitude '222.267255W'",
#        "set service lldp interface eth2"
#    ]
#
# "after": {
#      "location": {
#          "coordinate_based": {
#              "altitude": 2200,
#              "datum": "WGS84",
#              "latitude": "33.524449N",
#              "longitude": "222.267255W"
#          }
#      },
#      "name": "eth2"
#  },
#  {
#      "location": {
#          "elin": "0000000911"
#          }
#      },
#      "name": "eth1"
#  }
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands | grep lldp
# set service lldp interface eth1 location elin '0000000911'
# set service lldp interface eth2 location coordinate-based altitude '2200'
# set service lldp interface eth2 location coordinate-based datum 'WGS84'
# set service lldp interface eth2 location coordinate-based latitude '33.524449N'
# set service lldp interface eth2 location coordinate-based longitude '222.267255W'


# Using replaced
#
# Before state:
# -------------
#
# vyos@vyos:~$ show configuration commands | grep lldp
# set service lldp interface eth1 location elin '0000000911'
# set service lldp interface eth2 location coordinate-based altitude '2200'
# set service lldp interface eth2 location coordinate-based datum 'WGS84'
# set service lldp interface eth2 location coordinate-based latitude '33.524449N'
# set service lldp interface eth2 location coordinate-based longitude '222.267255W'
#
- name: >-
    Replace device configurations of listed LLDP interfaces with provided
    configurations
  vyos.vyos.vyos_lldp_interfaces:
    config:
      - name: eth2
        location:
          elin: 0000000911
      - name: eth1
        location:
          coordinate_based:
            altitude: 2200
            datum: WGS84
            longitude: 222.267255W
            latitude: 33.524449N
    state: replaced
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#    "before": [
#        {
#            "location": {
#                "coordinate_based": {
#                    "altitude": 2200,
#                    "datum": "WGS84",
#                    "latitude": "33.524449N",
#                    "longitude": "222.267255W"
#                }
#            },
#            "name": "eth2"
#        },
#        {
#            "location": {
#                "elin": "0000000911"
#            },
#            "name": "eth1"
#        }
#    ]
#
#    "commands": [
#        "delete service lldp interface eth2 location",
#        "set service lldp interface eth2 'disable'",
#        "set service lldp interface eth2 location elin '0000000911'",
#        "delete service lldp interface eth1 location",
#        "set service lldp interface eth1 'disable'",
#        "set service lldp interface eth1 location coordinate-based latitude '33.524449N'",
#        "set service lldp interface eth1 location coordinate-based altitude '2200'",
#        "set service lldp interface eth1 location coordinate-based datum 'WGS84'",
#        "set service lldp interface eth1 location coordinate-based longitude '222.267255W'"
#    ]
#
#    "after": {
#        "location": {
#            "elin": "0000000911"
#        },
#        "name": "eth2"
#    },
#    {
#        "location": {
#            "coordinate_based": {
#                "altitude": 2200,
#                "datum": "WGS84",
#                "latitude": "33.524449N",
#                "longitude": "222.267255W"
#            }
#        },
#        "name": "eth1"
#    }
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands | grep lldp
# set service lldp interface eth1 'disable'
# set service lldp interface eth1 location coordinate-based altitude '2200'
# set service lldp interface eth1 location coordinate-based datum 'WGS84'
# set service lldp interface eth1 location coordinate-based latitude '33.524449N'
# set service lldp interface eth1 location coordinate-based longitude '222.267255W'
# set service lldp interface eth2 'disable'
# set service lldp interface eth2 location elin '0000000911'


# Using overridden
#
# Before state
# --------------
#
# vyos@vyos:~$ show configuration commands | grep lldp
# set service lldp interface eth1 'disable'
# set service lldp interface eth1 location coordinate-based altitude '2200'
# set service lldp interface eth1 location coordinate-based datum 'WGS84'
# set service lldp interface eth1 location coordinate-based latitude '33.524449N'
# set service lldp interface eth1 location coordinate-based longitude '222.267255W'
# set service lldp interface eth2 'disable'
# set service lldp interface eth2 location elin '0000000911'
#
- name: Overrides all device configuration with provided configuration
  vyos.vyos.vyos_lldp_interfaces:
    config:
      - name: eth2
        location:
          elin: 0000000911

    state: overridden
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# "before": [
#    {
#      "enable": false,
#      "elin": "0000000911",
#      "name": "eth2"
#    },
#    {
#      "enable": false,
#      "location": {
#        "coordinate_based": {
#          "altitude": 2200,
#          "datum": "WGS84",
#          "latitude": "33.524449N",
#          "longitude": "222.267255W"
#        }
#      },
#      "name": "eth1"
#    }
#  ]
#
# "commands": [
#    "delete service lldp interface eth2 location",
#    "delete service lldp interface eth2 disable",
#    "set service lldp interface eth2 location elin 0000000911"
#  ]
#
# "after": [
#    {
#      "location": {
#        "elin": 0000000911
#      },
#      "name": "eth2"
#    }
#  ]
#
#
# After state
# ------------
#
# vyos@vyos# run show configuration commands | grep lldp
# set service lldp interface eth2 location elin '0000000911'


# Using deleted
#
# Before state
# -------------
#
# vyos@vyos# run show configuration commands | grep lldp
# set service lldp interface eth2 location elin '0000000911'
#
- name: Delete LLDP interface attributes of given interfaces.
  vyos.vyos.vyos_lldp_interfaces:
    config:
      - name: eth2
    state: deleted
#
#
# ------------------------
# Module Execution Results
# ------------------------
#
#  "before": [
#       {
#          "location": {
#              "elin": 0000000911
#          },
#          "name": "eth2"
#      }
#  ]
#  "commands": [
#      "delete service lldp interface eth2"
#  ]
#
# "after": []
# After state
# ------------
# vyos@vyos# run show configuration commands | grep lldp
# set service 'lldp'


# Using gathered
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep lldp
# set service lldp interface eth1 location elin '0000000911'
# set service lldp interface eth2 location coordinate-based altitude '2200'
# set service lldp interface eth2 location coordinate-based datum 'WGS84'
# set service lldp interface eth2 location coordinate-based latitude '33.524449N'
# set service lldp interface eth2 location coordinate-based longitude '222.267255W'
#
- name: Gather listed lldp interfaces from running configuration
  vyos.vyos.vyos_lldp_interfaces:
    config:
    state: gathered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#    "gathered": [
#         {
#             "location": {
#                 "coordinate_based": {
#                     "altitude": 2200,
#                     "datum": "WGS84",
#                     "latitude": "33.524449N",
#                     "longitude": "222.267255W"
#                 }
#             },
#             "name": "eth2"
#         },
#         {
#             "location": {
#                 "elin": "0000000911"
#             },
#             "name": "eth1"
#         }
#     ]
#
#
# After state:
# -------------
#
# vyos@192# run show configuration commands | grep lldp
# set service lldp interface eth1 location elin '0000000911'
# set service lldp interface eth2 location coordinate-based altitude '2200'
# set service lldp interface eth2 location coordinate-based datum 'WGS84'
# set service lldp interface eth2 location coordinate-based latitude '33.524449N'
# set service lldp interface eth2 location coordinate-based longitude '222.267255W'


# Using rendered
#
#
- name: Render the commands for provided  configuration
  vyos.vyos.vyos_lldp_interfaces:
    config:
      - name: eth1
        location:
          elin: 0000000911
      - name: eth2
        location:
          coordinate_based:
            altitude: 2200
            datum: WGS84
            longitude: 222.267255W
            latitude: 33.524449N
    state: rendered

#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "rendered": [
#         "set service lldp interface eth1 location elin '0000000911'",
#         "set service lldp interface eth1",
#         "set service lldp interface eth2 location coordinate-based latitude '33.524449N'",
#         "set service lldp interface eth2 location coordinate-based altitude '2200'",
#         "set service lldp interface eth2 location coordinate-based datum 'WGS84'",
#         "set service lldp interface eth2 location coordinate-based longitude '222.267255W'",
#         "set service lldp interface eth2"
#     ]


# Using parsed
#
#
- name: Parsed the commands to provide structured configuration.
  vyos.vyos.vyos_lldp_interfaces:
    running_config:
      "set service lldp interface eth1 location elin '0000000911'
       set service lldp interface eth2 location coordinate-based altitude '2200'
       set service lldp interface eth2 location coordinate-based datum 'WGS84'
       set service lldp interface eth2 location coordinate-based latitude '33.524449N'
       set service lldp interface eth2 location coordinate-based longitude '222.267255W'"
    state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed": [
#         {
#             "location": {
#                 "coordinate_based": {
#                     "altitude": 2200,
#                     "datum": "WGS84",
#                     "latitude": "33.524449N",
#                     "longitude": "222.267255W"
#                 }
#             },
#             "name": "eth2"
#         },
#         {
#             "location": {
#                 "elin": "0000000911"
#             },
#             "name": "eth1"
#         }
#     ]

Return Values

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

Key

Description

after

list / elements=string

The configuration as structured data after module completion.

Returned: when changed

Sample: ["The configuration returned will always be in the same format of the parameters above.\n"]

before

list / elements=string

The configuration as structured data prior to module invocation.

Returned: always

Sample: ["The configuration returned will always be in the same format of the parameters above.\n"]

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

Sample: ["set service lldp interface eth2 'disable'", "delete service lldp interface eth1 location"]

Authors

  • Rohit Thakur (@rohitthakur2590)