arista.eos.eos_prefix_lists 模块 – 管理前缀列表资源模块

注意

此模块是 arista.eos 集合 (版本 10.0.1) 的一部分。

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

要安装它,请使用: ansible-galaxy collection install arista.eos

要在 playbook 中使用它,请指定: arista.eos.eos_prefix_lists

arista.eos 2.2.0 中的新增功能

概要

  • 此模块配置和管理 Arista EOS 平台上前缀列表的属性。

参数

参数

注释

config

列表 / 元素=字典

前缀列表选项的字典列表

afi

字符串 / 必填

前缀列表的地址族指示器 (AFI)。

选项

  • "ipv4"

  • "ipv6"

prefix_lists

列表 / 元素=字典

前缀列表列表。

entries

列表 / 元素=字典

前缀列表列表

action

字符串

对指定路径执行的操作

选项

  • "deny"

  • "permit"

address

字符串

前缀掩码或地址掩码长度格式的 IPv4/v6 地址

match

字典

匹配掩码长度

masklen

整数

掩码长度。

operator

字符串

等于/大于/小于

选项

  • "eq"

  • "le"

  • "ge"

resequence

字典

重新排序列表。

default

布尔值

使用默认值 (10) 重新排序。

选项

  • false

  • true

start_seq

整数

起始序列号。

step

整数

递增序列号的步长。

sequence

整数

序列号

name

字符串 / 必填

前缀列表的名称

running_config

字符串

此选项仅与状态 *parsed* 一起使用。

此选项的值应是从 EOS 设备通过执行命令 **show running-config | section access-list** 收到的输出。

状态 *parsed* 从 running_config 选项读取配置并将其转换为 Ansible 结构化数据,根据资源模块的 argspec,然后该值将返回结果中的 *parsed* 键中。

state

字符串

配置应保留的状态。

选项

  • "deleted"

  • "merged" ← (默认)

  • "overridden"

  • "replaced"

  • "gathered"

  • "rendered"

  • "parsed"

注释

注意

  • 在 Arista EOS 4.24.6F 上测试过

  • 此模块与连接 network_cli 一起使用。请参阅 EOS 平台选项

示例

# Using merged


# Before state
# veos#show running-config | section prefix-lists
# veos#

- name: Merge provided configuration with device configuration
  arista.eos.eos_prefix_lists:
    config:
      - afi: "ipv4"
        prefix_lists:
          - name: "v401"
            entries:
              - sequence: 25
                action: "deny"
                address: "45.55.4.0/24"
              - sequence: 100
                action: "permit"
                address: "11.11.2.0/24"
                match:
                  masklen: 32
                  operator: "ge"
          - name: "v402"
            entries:
              - action: "deny"
                address: "10.1.1.0/24"
                sequence: 10
                match:
                  masklen: 32
                  operator: "ge"
      - afi: "ipv6"
        prefix_lists:
          - name: "v601"
            entries:
              - sequence: 125
                action: "deny"
                address: "5000:1::/64"

# Task Output
# -------------
# before: {}
# commands:
# - ipv6 prefix-list v601
# - seq 125 deny 5000:1::/64
# - ip prefix-list v401
# - seq 25 deny 45.55.4.0/24
# - seq 100 permit 11.11.2.0/24 ge 32
# - ip prefix-list v402
# - seq 10 deny 10.1.1.0/24 ge 32
# after:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601


# After state:
# ------------
# veos#
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24
#    seq 100 permit 11.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#


# Using merged:
# Failure scenario : 'merged' should not be used when an existing prefix-list (sequence number)
# is to be modified.


# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24
#    seq 100 permit 11.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#

- name: Merge provided configuration with device configuration
  arista.eos.eos_prefix_lists:
    config:
      - afi: "ipv4"
        prefix_lists:
          - name: "v401"
            entries:
              - sequence: 25
                action: "deny"
                address: "45.55.4.0/24"
                match:
                  masklen: 32
                  operator: "ge"
              - sequence: 100
                action: "permit"
                address: "11.11.2.0/24"
                match:
                  masklen: 32
                  operator: "ge"
          - name: "v402"
            entries:
              - action: "deny"
                address: "10.1.1.0/24"
                sequence: 10
                match:
                  masklen: 32
                  operator: "ge"
      - afi: "ipv6"
        prefix_lists:
          - name: "v601"
            entries:
              - sequence: 125
                action: "deny"
                address: "5000:1::/64"
    state: merged

# Task Output
# -------------
# changed: false
# invocation:
#   module_args:
#     config:
#     - afi: ipv4
#       prefix_lists:
#       - entries:
#         - action: deny
#           address: 45.55.4.0/24
#           match:
#             masklen: 32
#             operator: ge
#           resequence:
#           sequence: 25
#         - action: permit
#           address: 11.11.2.0/24
#           match:
#             masklen: 32
#             operator: ge
#           resequence:
#           sequence: 100
#         name: v401
#       - entries:
#         - action: deny
#           address: 10.1.1.0/24
#           match:
#             masklen: 32
#             operator: ge
#           resequence:
#           sequence: 10
#         name: v402
#     - afi: ipv6
#       prefix_lists:
#       - entries:
#         - action: deny
#           address: 5000:1::/64
#           match:
#           resequence:
#           sequence: 125
#         name: v601
#     running_config:
#     state: merged
# msg: Sequence number 25 is already present. Use replaced/overridden operation to change
#   the configuration


# Using Replaced:

# Before state:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24
#    seq 100 permit 11.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#


- name: Replace Provided configuration with given configuration
  arista.eos.eos_prefix_lists:
    config:
      - afi: "ipv4"
        prefix_lists:
          - name: "v401"
            entries:
              - sequence: 25
                action: "deny"
                address: "45.55.4.0/24"
                match:
                  masklen: 32
                  operator: "ge"
              - sequence: 200
                action: "permit"
                address: "200.11.2.0/24"
                match:
                  masklen: 32
                  operator: "ge"
    state: replaced


# Task Output
# -------------
# before:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601
# commands:
# - ip prefix-list v401
# - no seq 25
# - seq 25 deny 45.55.4.0/24 ge 32
# - seq 200 permit 200.11.2.0/24 ge 32
# - no seq 100
# - no ip prefix-list v402
# after:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 25
#     - action: permit
#       address: 200.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 200
#     name: v401
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601


# After State:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24 ge 32
#    seq 200 permit 200.11.2.0/24 ge 32
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#
#
#


# Using overridden:


# Before State:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24 ge 32
#    seq 100 permit 11.11.2.0/24 ge 32
#    seq 200 permit 200.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#

- name: Override
  arista.eos.eos_prefix_lists:
    config:
      - afi: "ipv4"
        prefix_lists:
          - name: "v401"
            entries:
              - sequence: 25
                action: "deny"
                address: "45.55.4.0/24"
              - sequence: 300
                action: "permit"
                address: "30.11.2.0/24"
                match:
                  masklen: 32
                  operator: "ge"
          - name: "v403"
            entries:
              - action: "deny"
                address: "10.1.1.0/24"
                sequence: 10
    state: overridden


# Task Output
# -------------
# before:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     - action: permit
#       address: 200.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 200
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601
# commands:
# - no ipv6 prefix-list v601
# - ip prefix-list v401
# - seq 25 deny 45.55.4.0/24
# - seq 300 permit 30.11.2.0/24 ge 32
# - no seq 100
# - no seq 200
# - ip prefix-list v403
# - seq 10 deny 10.1.1.0/24
# - no ip prefix-list v402
# after:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 25
#     - action: permit
#       address: 30.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 300
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       sequence: 10
#     name: v403


# After State
# veos#
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24 ge 32
#    seq 300 permit 30.11.2.0/24 ge 32
# !
# ip prefix-list v403
#    seq 10 deny 10.1.1.0/24
# veos#

# Using deleted:

# Before State:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24 ge 32
#    seq 100 permit 11.11.2.0/24 ge 32
#    seq 300 permit 30.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ip prefix-list v403
#    seq 10 deny 10.1.1.0/24
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#

- name: Delete device configuration
  arista.eos.eos_prefix_lists:
    config:
      - afi: "ipv6"
    state: deleted

# Task Output
# -------------
# before:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     - action: permit
#       address: 30.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 300
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       sequence: 10
#     name: v403
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601
# commands:
# - no ipv6 prefix-list v601
# after:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     - action: permit
#       address: 30.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 300
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       sequence: 10
#     name: v403

# after State:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24 ge 32
#    seq 100 permit 11.11.2.0/24 ge 32
#    seq 300 permit 30.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ip prefix-list v403
#    seq 10 deny 10.1.1.0/24
#


# Using deleted


# Before state:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24 ge 32
#    seq 100 permit 11.11.2.0/24 ge 32
#    seq 300 permit 30.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ip prefix-list v403
#    seq 10 deny 10.1.1.0/24
# veos#

- name: Delete device configuration
  arista.eos.eos_prefix_lists:
    state: deleted


# Task Output
# -------------
# before:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     - action: permit
#       address: 30.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 300
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       sequence: 10
#     name: v403
# commands:
# - no ip prefix-list v401
# - no ip prefix-list v402
# - no ip prefix-list v403
# after: {}

# After State:
# veos#show running-config | section prefix-list
# veos#


# Using parsed:


# parse_prefix_lists.cfg
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24
#    seq 100 permit 11.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
#


- name: parse configs
  arista.eos.eos_prefix_lists:
    running_config: "{{ lookup('file', './parsed_prefix_lists.cfg') }}"
    state: parsed


# Task Output
# -------------
# parsed:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       sequence: 10
#     name: v402
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601


# Using rendered:

- name: Render provided configuration
  arista.eos.eos_prefix_lists:
    config:
      - afi: "ipv4"
        prefix_lists:
          - name: "v401"
            entries:
              - sequence: 25
                action: "deny"
                address: "45.55.4.0/24"
              - sequence: 200
                action: "permit"
                address: "200.11.2.0/24"
                match:
                  masklen: 32
                  operator: "ge"
          - name: "v403"
            entries:
              - action: "deny"
                address: "10.1.1.0/24"
                sequence: 10
    state: rendered

# Task Output
# -------------
# rendered:
# - ip prefix-list v401
# - seq 25 deny 45.55.4.0/24
# - seq 200 permit 200.11.2.0/24 ge 32
# - ip prefix-list v403
# - seq 10 deny 10.1.1.0/24

# using gathered:


# Device config:
# veos#show running-config | section prefix-list
# ip prefix-list v401
#    seq 25 deny 45.55.4.0/24
#    seq 100 permit 11.11.2.0/24 ge 32
# !
# ip prefix-list v402
#    seq 10 deny 10.1.1.0/24 ge 32
# !
# ipv6 prefix-list v601
#    seq 125 deny 5000:1::/64
# veos#

- name: gather configs
  arista.eos.eos_prefix_lists:
    state: gathered

# Task Output
# -------------
# gathered:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 45.55.4.0/24
#       sequence: 25
#     - action: permit
#       address: 11.11.2.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 100
#     name: v401
#   - entries:
#     - action: deny
#       address: 10.1.1.0/24
#       match:
#         masklen: 32
#         operator: ge
#       sequence: 10
#     name: v402
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       address: 5000:1::/64
#       sequence: 125
#     name: v601

返回值

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

描述

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"]

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回:始终返回

示例: ["ip prefix-list v401", "seq 25 deny 45.55.4.0/24", "seq 200 permit 200.11.2.0/24 ge 32", "ip prefix-list v403", "seq 10 deny 10.1.1.0/24"]

gathered

列表 / 元素=字符串

从远程主机获取的运行配置转换后的结构化数据配置

返回:state 为 *gathered* 时

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

parsed

列表 / 元素=字符串

将配置作为结构化数据转换,用于running_config选项的值

返回:stateparsed

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

渲染

列表 / 元素=字符串

根据config选项中的值生成的CLI命令集

返回:staterendered

示例: ["- ip prefix-list v401 - seq 25 deny 45.55.4.0/24 - seq 200 permit 200.11.2.0/24 ge 32 - ip prefix-list v403 - seq 10 deny 10.1.1.0/24\n"]

作者

  • Gomathi Selvi Srinivasan (@GomathiselviS)