cisco.iosxr.iosxr_l3_interfaces 模块 – 配置 L3 接口的资源模块。
注意
此模块是 cisco.iosxr 集合 (版本 10.2.2) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install cisco.iosxr
。
要在 playbook 中使用它,请指定: cisco.iosxr.iosxr_l3_interfaces
。
cisco.iosxr 1.0.0 中的新增功能
概要
此模块提供对 Cisco IOS-XR 设备上三层接口的声明式管理。
参数
参数 |
注释 |
---|---|
三层接口选项的字典 |
|
为name选项中提到的三层接口设置的 IPv4 地址。 地址格式为 <ipv4 地址>/<掩码>,掩码是 0-32 范围内的数字,例如 192.168.0.1/24 |
|
配置接口的 IPv4 地址。 |
|
将 IP 地址配置为辅助地址。 选项
|
|
为name选项中提到的三层接口设置的 IPv6 地址。 地址格式为 <ipv6 地址>/<掩码>,掩码是 0-128 范围内的数字,例如 fd5d:12c9:2201:1::1/64 |
|
配置接口的 IPv6 地址。 |
|
接口的全名,不包括任何逻辑单元号,例如 GigabitEthernet0/1。 |
|
此选项仅与 state parsed 一起使用。 此选项的值应为通过执行命令 show running-config interface 从 IOS-XR 设备接收到的输出。 state parsed 从 |
|
模块完成后配置的状态 选项
|
备注
注意
此模块适用于连接
network_cli
。请参阅 IOS-XR 平台选项。
示例
# Using merged
# Before state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# !
# interface preconfigure GigabitEthernet0/0/0/3
# !
- name: Merge provided configuration with device configuration
cisco.iosxr.iosxr_l3_interfaces:
config:
- name: GigabitEthernet0/0/0/2
ipv4:
- address: 192.168.0.1/24
- name: GigabitEthernet0/0/0/3
ipv4:
- address: 192.168.2.1/24
secondary: true
state: merged
# Task Output
# -----------
#
# before:
# - name: Loopback888
# - name: Loopback999
# - name: GigabitEthernet0/0/0/2
# - name: GigabitEthernet0/0/0/3
# commands:
# - interface GigabitEthernet0/0/0/2
# - ipv4 address 192.168.0.1 255.255.255.0
# - interface GigabitEthernet0/0/0/3
# - ipv4 address 192.168.2.1 255.255.255.0 secondary
# after:
# - name: Loopback888
# - name: Loopback999
# - ipv4:
# - address: 192.168.0.1/24
# name: GigabitEthernet0/0/0/2
# - ipv4:
# - address: 192.168.2.1/24
# secondary: true
# name: GigabitEthernet0/0/0/3
# After state:
# ------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# ipv4 address 192.168.0.1 255.255.255.0
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv4 address 192.168.2.1 255.255.255.0 secondary
# !
# Using overridden
# Before state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# ipv4 address 192.168.0.1 255.255.255.0
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv4 address 192.168.2.1 255.255.255.0 secondary
# !
- name: Override device configuration of all interfaces with provided configuration
cisco.iosxr.iosxr_l3_interfaces:
config:
- name: GigabitEthernet0/0/0/3
ipv4:
- address: 192.168.0.2/24
- address: 192.168.2.1/24
secondary: true
state: overridden
# Task Output
# -----------
#
# before:
# - name: Loopback888
# - name: Loopback999
# - ipv4:
# - address: 192.168.0.1/24
# name: GigabitEthernet0/0/0/2
# - ipv4:
# - address: 192.168.2.1/24
# secondary: true
# name: GigabitEthernet0/0/0/3
# commands:
# - interface GigabitEthernet0/0/0/2
# - no ipv4 address
# - interface GigabitEthernet0/0/0/3
# - ipv4 address 192.168.0.2 255.255.255.0
# - ipv4 address 192.168.0.1 255.255.255.0
# after:
# - name: Loopback888
# - name: Loopback999
# - name: GigabitEthernet0/0/0/2
# - ipv4:
# - address: 192.168.0.1/24
# - address: 192.168.2.1/24
# secondary: true
# name: GigabitEthernet0/0/0/3
# After state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv4 address 192.168.0.1 255.255.255.0
# ipv4 address 192.168.2.1 255.255.255.0 secondary
# !
# Using replaced
# Before state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv4 address 192.168.0.1 255.255.255.0
# ipv4 address 192.168.2.1 255.255.255.0 secondary
# !
- name: >-
Replaces device configuration of listed interfaces with provided
configuration
cisco.iosxr.iosxr_l3_interfaces:
config:
- name: GigabitEthernet0/0/0/3
ipv6:
- address: 'fd5d:12c9:2201:1::1/64'
- name: GigabitEthernet0/0/0/2
ipv4:
- address: 192.168.0.2/24
state: replaced
# Task Output
# -----------
#
# before:
# - name: Loopback888
# - name: Loopback999
# - name: GigabitEthernet0/0/0/2
# - ipv4:
# - address: 192.168.0.1/24
# - address: 192.168.2.1/24
# secondary: true
# name: GigabitEthernet0/0/0/3
# commands:
# - interface GigabitEthernet0/0/0/3
# - no ipv4 address
# - ipv6 address fd5d:12c9:2201:1::1/64
# - interface GigabitEthernet0/0/0/2
# - ipv4 address 192.168.0.2 255.255.255.0
# after:
# - name: Loopback888
# - name: Loopback999
# - ipv4:
# - address: 192.168.0.2/24
# name: GigabitEthernet0/0/0/2
# - ipv6:
# - address: fd5d:12c9:2201:1::1/64
# name: GigabitEthernet0/0/0/3
# After state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# ipv4 address 192.168.0.2 255.255.255.0
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv6 address fd5d:12c9:2201:1::1/64
# !
# Using deleted
# Before state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# ipv4 address 192.168.0.2 255.255.255.0
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv6 address fd5d:12c9:2201:1::1/64
# !
- name: Delete attributes for interfaces (This won't delete the interface itself)
cisco.iosxr.iosxr_l3_interfaces:
config:
- name: GigabitEthernet0/0/0/3
- name: GigabitEthernet0/0/0/4
- name: GigabitEthernet0/0/0/3.700
state: deleted
# Task Output
# -----------
#
# before:
# - name: Loopback888
# - name: Loopback999
# - ipv4:
# - address: 192.168.0.2/24
# name: GigabitEthernet0/0/0/2
# - ipv6:
# - address: fd5d:12c9:2201:1::1/64
# name: GigabitEthernet0/0/0/3
# commands:
# - interface GigabitEthernet0/0/0/3
# - no ipv6 address
# after:
# - name: Loopback888
# - name: Loopback999
# - ipv4:
# - address: 192.168.0.2/24
# name: GigabitEthernet0/0/0/2
# - name: GigabitEthernet0/0/0/3
# After state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/2
# ipv4 address 192.168.0.2 255.255.255.0
# !
# interface preconfigure GigabitEthernet0/0/0/3
# !
# Using deleted - will delete all interface configuration and not interface
# Before state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/1
# ipv4 address 192.168.2.1 255.255.255.0
# shutdown
# !
# interface preconfigure GigabitEthernet0/0/0/2
# ipv4 address 192.168.3.1 255.255.255.0
# shutdown
# !
# interface preconfigure GigabitEthernet0/0/0/3
# ipv4 address 192.168.0.2 255.255.255.0
# shutdown
# !
# interface preconfigure GigabitEthernet0/0/0/3.700
# ipv4 address 192.168.0.1 255.255.255.0
# !
# interface preconfigure GigabitEthernet0/0/0/4
# ipv6 address fd5d:12c9:2201:1::1/64
# shutdown
# !
- name: "Delete L3 config of all interfaces (This won't delete the interface itself)"
cisco.iosxr.iosxr_l3_interfaces:
state: deleted
# Task Output
# -----------
#
# before:
# - name: Loopback888
# - name: Loopback999
# - ipv4:
# - address: 192.168.2.1/24
# name: GigabitEthernet0/0/0/1
# - ipv4:
# - address: 192.168.3.1/24
# name: GigabitEthernet0/0/0/2
# - ipv4:
# - address: 192.168.0.2/24
# name: GigabitEthernet0/0/0/3
# - ipv4:
# - address: 192.168.0.1/24
# name: GigabitEthernet0/0/0/3.700
# - ipv6:
# - address: fd5d:12c9:2201:1::1/64
# name: GigabitEthernet0/0/0/4
# commands:
# - interface GigabitEthernet0/0/0/1
# - no ipv4 address
# - interface GigabitEthernet0/0/0/2
# - no ipv4 address
# - interface GigabitEthernet0/0/0/3
# - no ipv4 address
# - interface GigabitEthernet0/0/0/3.700
# - no ipv4 address
# - interface GigabitEthernet0/0/0/4
# - no ipv6 address
# after:
# - name: Loopback888
# - name: Loopback999
# - name: GigabitEthernet0/0/0/1
# - name: GigabitEthernet0/0/0/2
# - name: GigabitEthernet0/0/0/3
# - name: GigabitEthernet0/0/0/3.700
# - name: GigabitEthernet0/0/0/4
# After state:
# -------------
#
# viosxr#show running-config interface
# interface Loopback888
# !
# interface Loopback999
# !
# interface MgmtEth0/RP0/CPU0/0
# ipv4 address dhcp
# !
# interface preconfigure GigabitEthernet0/0/0/1
# shutdown
# !
# interface preconfigure GigabitEthernet0/0/0/2
# shutdown
# !
# interface preconfigure GigabitEthernet0/0/0/3
# shutdown
# !
# interface preconfigure GigabitEthernet0/0/0/3.700
# !
# interface preconfigure GigabitEthernet0/0/0/4
# shutdown
# !
# Using parsed
# File: parsed.cfg
# ----------------
#
# interface Loopback888
# description test for ansible
# shutdown
# !
# interface MgmtEth0/0/CPU0/0
# ipv4 address 10.8.38.70 255.255.255.0
# !
# interface GigabitEthernet0/0/0/0
# description Configured and Merged by Ansible-Network
# mtu 66
# ipv4 address 192.0.2.1 255.255.255.0
# ipv4 address 192.0.2.2 255.255.255.0 secondary
# ipv6 address 2001:db8:0:3::/64
# duplex half
# !
# interface GigabitEthernet0/0/0/1
# description Configured and Merged by Ansible-Network
# mtu 66
# speed 100
# duplex full
# dot1q native vlan 10
# l2transport
# l2protocol cdp forward
# l2protocol pvst tunnel
# propagate remote-status
# !
# !
# interface GigabitEthernet0/0/0/3
# ipv4 address 192.0.22.1 255.255.255.0
# ipv4 address 192.0.23.1 255.255.255.0
# !
- name: Convert L3 interfaces config to argspec without connecting to the appliance
cisco.iosxr.iosxr_l3_interfaces:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
# Task Output
# -----------
#
# parsed:
# - ipv4:
# - address: 192.0.2.1 255.255.255.0
# - address: 192.0.2.2 255.255.255.0
# secondary: true
# ipv6:
# - address: 2001:db8:0:3::/64
# name: GigabitEthernet0/0/0/0
# - name: GigabitEthernet0/0/0/1
# - ipv4:
# - address: 192.0.22.1 255.255.255.0
# - address: 192.0.23.1 255.255.255.0
# name: GigabitEthernet0/0/0/3
# Using rendered
- name: Render platform specific commands from task input using rendered state
cisco.iosxr.iosxr_l3_interfaces:
config:
- name: GigabitEthernet0/0/0/0
ipv4:
- address: 198.51.100.1/24
- name: GigabitEthernet0/0/0/1
ipv6:
- address: '2001:db8:0:3::/64'
ipv4:
- address: 192.0.2.1/24
- address: 192.0.2.2/24
secondary: true
state: rendered
# Task Output
# -----------
#
# rendered:
# - interface GigabitEthernet0/0/0/0
# - ipv4 address 198.51.100.1 255.255.255.0
# - interface GigabitEthernet0/0/0/1
# - ipv4 address 192.0.2.2 255.255.255.0 secondary
# - ipv4 address 192.0.2.1 255.255.255.0
# - ipv6 address 2001:db8:0:3::/64
# Using gathered
# Before state:
# ------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config interface
# interface Loopback888
# description test for ansible
# shutdown
# !
# interface MgmtEth0/0/CPU0/0
# ipv4 address 10.8.38.70 255.255.255.0
# !
# interface GigabitEthernet0/0/0/0
# description Configured and Merged by Ansible-Network
# mtu 66
# ipv4 address 192.0.2.1 255.255.255.0
# ipv4 address 192.0.2.2 255.255.255.0 secondary
# ipv6 address 2001:db8:0:3::/64
# duplex half
# !
# interface GigabitEthernet0/0/0/1
# description Configured and Merged by Ansible-Network
# mtu 66
# speed 100
# duplex full
# dot1q native vlan 10
# l2transport
# l2protocol cdp forward
# l2protocol pvst tunnel
# propagate remote-status
# !
# !
# interface GigabitEthernet0/0/0/3
# shutdown
# !
# interface GigabitEthernet0/0/0/4
# shutdown
# dot1q native vlan 40
# !
- name: Gather l3 interfaces facts
cisco.iosxr.iosxr_l3_interfaces:
config:
state: gathered
# Task Output
# -----------
#
# gathered:
# - name: Loopback888
# - ipv4:
# - address: 192.0.2.1 255.255.255.0
# - address: 192.0.2.2 255.255.255.0
# secondary: true
# ipv6:
# - address: 2001:db8:0:3::/64
# name: GigabitEthernet0/0/0/0
# - name: GigabitEthernet0/0/0/1
# - name: GigabitEthernet0/0/0/3
# - name: GigabitEthernet0/0/0/4
返回值
常见的返回值已在 此处 记录,以下是此模块特有的字段
键 |
描述 |
---|---|
模块完成后作为结构化数据的配置。 返回:发生更改时 示例: |
|
模块调用之前的结构化数据配置。 返回:始终 示例: |
|
推送到远程设备的命令集 返回:始终 示例: |