community.network.exos_l2_interfaces 模块 – 管理 Extreme Networks EXOS 设备上的 L2 接口。

注意

此模块是 community.network 集合 (版本 5.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.network

要在 playbook 中使用它,请指定:community.network.exos_l2_interfaces

注意

community.network 集合已被弃用,并将从 Ansible 12 中删除。有关更多信息,请参阅 讨论主题

community.network 0.2.0 中的新增功能

已弃用

在以下版本中移除:

版本 6.0.0

原因:

此集合及其中的所有内容均未维护且已弃用。

替代方案:

未知。

摘要

  • 此模块提供对 Extreme Networks EXOS 网络设备上 L2 接口的声明式管理。

别名:network.exos.exos_l2_interfaces

参数

参数

注释

config

列表 / 元素=字典

L2 接口选项的字典

access

字典

Switchport mode access 命令,用于将接口配置为第 2 层访问接口。

vlan

整数

在访问端口中配置给定的 VLAN。用作访问 VLAN ID。

name

字符串 / 必需

接口名称

trunk

字典

Switchport mode trunk 命令,用于将接口配置为第 2 层 trunk 接口。

native_vlan

整数

要在 trunk 端口中配置的本机 VLAN。用作 trunk 本机 VLAN ID。

trunk_allowed_vlans

列表 / 元素=字符串

给定 trunk 端口中允许的 VLAN 列表。这些是将在 trunk 上配置的唯一 VLAN。

state

字符串

配置应保留的状态

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

备注

注意

  • 针对 EXOS 30.2.1.8 进行了测试

  • 此模块与连接 httpapi 配合使用。请参阅 EXOS 平台选项

示例

# Using deleted

# Before state:
# -------------
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 1,
#               "trunk-vlans": [
#                 10
#               ]
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 10,
#               "trunk-vlans": [
#                 20,
#                 30
#               ]
#             }
#           }
#         }
#       }
#     ]
#   }
# }

- name: Delete L2 interface configuration for the given arguments
  community.network.exos_l2_interfaces:
    config:
      - name: '3'
    state: deleted

# Module Execution Results:
# -------------------------
#
# "before": [
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "2",
#         "trunk": {
#             "native_vlan": 1,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     },
#     {
#         "access": null,
#         "name": "3",
#         "trunk": {
#             "native_vlan": 10,
#             "trunk_allowed_vlans": [
#                 20,
#                 30
#             ]
#         }
#     }
# ],
#
# "requests": [
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 1,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=3/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     }
# ],
#
# "after": [
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "2",
#         "trunk": {
#             "native_vlan": 1,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     },
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "3",
#         "trunk": null
#     }
# ]
#
# After state:
# -------------
#
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 1,
#               "trunk-vlans": [
#                 10
#               ]
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             }
#           }
#         }
#       }
#     ]
#   }
# }


# Using deleted without any config passed
#"(NOTE: This will delete all of configured resource module attributes from each configured interface)"

# Before state:
# -------------
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 1,
#               "trunk-vlans": [
#                 10
#               ]
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 10,
#               "trunk-vlans": [
#                 20,
#                 30
#               ]
#             }
#           }
#         }
#       }
#     ]
#   }
# }

- name: Delete L2 interface configuration for the given arguments
  community.network.exos_l2_interfaces:
    state: deleted

# Module Execution Results:
# -------------------------
#
# "before": [
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "2",
#         "trunk": {
#             "native_vlan": 1,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     },
#     {
#         "access": null,
#         "name": "3",
#         "trunk": {
#             "native_vlan": 10,
#             "trunk_allowed_vlans": [
#                 20,
#                 30
#             ]
#         }
#     }
# ],
#
# "requests": [
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 1,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=1/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 1,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=2/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 1,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=3/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     }
# ],
#
# "after": [
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "2",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "3",
#         "trunk": null
#     }
# ]
#
# After state:
# -------------
#
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             }
#           }
#         }
#       }
#     ]
#   }
# }


# Using merged

# Before state:
# -------------
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#     "openconfig-if-ethernet:ethernet": {
#       "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             },
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             },
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             },
#           }
#         }
#       },
#     ]
#   }
# }

- name: Merge provided configuration with device configuration
  community.network.exos_l2_interfaces:
    config:
      - access:
          vlan: 10
        name: '1'
      - name: '2'
        trunk:
          trunk_allowed_vlans: 10
      - name: '3'
        trunk:
          native_vlan: 10
          trunk_allowed_vlans: 20
    state: merged

# Module Execution Results:
# -------------------------
#
# "before": [
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "2",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "3",
#         "trunk": null
#     }
# ],
#
# "requests": [
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 10,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=1/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "trunk-vlans": [10],
#            "interface-mode": "TRUNK"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=2/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "native-vlan": 10,
#        "trunk-vlans": [20],
#            "interface-mode": "TRUNK"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=3/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     }
# ],
#
# "after": [
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "2",
#         "trunk": {
#             "native_vlan": 1,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     },
#     {
#         "access": null,
#         "name": "3",
#         "trunk": {
#             "native_vlan": 10,
#             "trunk_allowed_vlans": [
#                 20
#             ]
#         }
#     }
# ]
#
# After state:
# -------------
#
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#     "openconfig-if-ethernet:ethernet": {
#       "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#           "native-vlan": 1,
#               "trunk-vlans": [
#                 10
#               ]
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#           "native-vlan": 10,
#               "trunk-vlans": [
#             20
#               ]
#             }
#           }
#         }
#       },
#     ]
#   }
# }


# Using overridden

# Before state:
# -------------
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 1,
#               "trunk-vlans": [
#                 10
#               ]
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 10,
#               "trunk-vlans": [
#                 20,
#             30
#               ]
#             }
#           }
#         }
#       }
#     ]
#   }
# }

- name: Overrride device configuration of all L2 interfaces with provided configuration
  community.network.exos_l2_interfaces:
    config:
      - access:
          vlan: 10
        name: '2'
    state: overridden

# Module Execution Results:
# -------------------------
#
# "before": [
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "2",
#         "trunk": {
#             "native_vlan": 1,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     },
#     {
#         "access": null,
#         "name": "3",
#         "trunk": {
#             "native_vlan": 10,
#             "trunk_allowed_vlans": [
#                 20,
#                 30
#             ]
#         }
#     }
# ],
#
# "requests": [
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 1,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=1/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 10,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=2/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     }
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 1,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=3/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     }
# ],
#
# "after": [
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "2",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 1
#         },
#         "name": "3",
#         "trunk": null
#     }
# ]
#
# After state:
# -------------
#
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 1
#             }
#           }
#         }
#       }
#     ]
#   }
# }


# Using replaced

# Before state:
# -------------
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 10
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 20
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 1,
#           "trunk-vlans": [
#             10
#           ]
#             }
#           }
#         }
#       }
#     ]
#   }
# }

- name: Replace device configuration of listed L2 interfaces with provided configuration
  community.network.exos_l2_interfaces:
    config:
      - access:
          vlan: 20
        name: '1'
      - name: '2'
        trunk:
          trunk_allowed_vlans: 10
      - name: '3'
        trunk:
          native_vlan: 10
          trunk_allowed_vlan: 20,30
    state: replaced

# Module Execution Results:
# -------------------------
#
# "before": [
#     {
#         "access": {
#             "vlan": 10
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": {
#             "vlan": 20
#         },
#         "name": "2",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "3",
#         "trunk": {
#             "native_vlan": 1,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     }
# ],
#
# "requests": [
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "access-vlan": 20,
#            "interface-mode": "ACCESS"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=1/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "trunk-vlans": [10],
#            "interface-mode": "TRUNK"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=2/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     },
#     {
#        "data": {
#          "openconfig-vlan:config": {
#            "native-vlan": 10,
#            "trunk-vlans": [20, 30]
#            "interface-mode": "TRUNK"
#          }
#        }
#        "method": "PATCH",
#        "path": "rest/restconf/data/openconfig-interfaces:interfaces/interface=3/openconfig-if-ethernet:ethernet/openconfig-vlan:switched-vlan/config"
#     }
# ],
#
# "after": [
#     {
#         "access": {
#             "vlan": 20
#         },
#         "name": "1",
#         "trunk": null
#     },
#     {
#         "access": null,
#         "name": "2",
#         "trunk": {
#             "native_vlan": null,
#             "trunk_allowed_vlans": [
#                 10
#             ]
#         }
#     },
#     {
#         "access": null,
#         "name": "3",
#         "trunk": {
#             "native_vlan": 10,
#             "trunk_allowed_vlans": [
#                 20,
#                 30
#             ]
#         }
#     }
# ]
#
# After state:
# -------------
#
# path: /rest/restconf/data/openconfig-interfaces:interfaces/
# method: GET
# data:
# {
#   "openconfig-interfaces:interfaces": {
#     "interface": [
#       {
#         "name": "1",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "ACCESS",
#               "access-vlan": 20
#             }
#           }
#         }
#       },
#       {
#         "name": "2",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "trunk-vlans": [
#             10
#           ]
#             }
#           }
#         }
#       },
#       {
#         "name": "3",
#         "openconfig-if-ethernet:ethernet": {
#           "openconfig-vlan:switched-vlan": {
#             "config": {
#               "interface-mode": "TRUNK",
#               "native-vlan": 10,
#               "trunk-vlans": [
#             20,
#             30
#           ]
#             }
#           }
#         }
#       }
#     ]
#   }
# }

返回值

常见的返回值已在此处记录 此处,以下是此模块特有的字段

描述

after

列表 / 元素=字符串

生成的配置模型调用。

返回:已更改时

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

before

列表 / 元素=字符串

模型调用之前的配置。

返回:始终

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

requests

列表 / 元素=字符串

推送到远程设备的请求集。

返回:始终

示例: [{"data": "...", "method": "...", "path": "..."}, {"data": "...", "method": "...", "path": "..."}, {"data": "...", "method": "...", "path": "..."}]

状态

  • 此模块将在 6.0.0 版本中删除。 *[已弃用]*

  • 有关更多信息,请参阅 已弃用

作者

  • Jayalakshmi Viswanathan (@jayalakshmiV)