amnesh.soodar.soodar_l3_interfaces module – Resource module to configure L3 interfaces.
Note
This module is part of the amnesh.soodar collection (version 2.0.0).
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 https://soodar.ir/ansible/amnesh.soodar.tar.gz.
To use it in a playbook, specify: amnesh.soodar.soodar_l3_interfaces.
Synopsis
This module provides declarative management of Layer-3 interface on Amnesh Soodar devices.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
|---|---|
A dictionary of Layer-3 interface options |
|
IPv4 address to be set for the Layer-3 interface mentioned in name option. The address format is <ipv4 address>/<mask>, the mask is number in range 0-32 eg. 192.168.0.1/24 |
|
Configures the IPv4 address for Interface. |
|
IP Address negotiated via DHCP. |
|
Enable dhcp. Choices:
|
|
Set IP Maximum Transmission Unit. |
|
Enable proxy_arp. Choices:
|
|
IPv6 address to be set for the Layer-3 interface mentioned in name option. The address format is <ipv6 address>/<mask>, the mask is number in range 0-128 eg. fd5d:12c9:2201:1::1/64 |
|
Configures the IPv6 address for Interface. |
|
Enable IPv6 on interface Choices:
|
|
Use eui-64 interface identifier Choices:
|
|
Manually set interface MAC address. |
|
Full name of the interface e.g. ge0. |
|
This option is used only with state parsed. The value of this option should be the output received from the Soodar device by executing the command show running-config | section ^interface. The state parsed reads the configuration from |
|
The state the configuration should be left in The states rendered, gathered and parsed does not perform any change on the device. The state rendered will transform the configuration in The state gathered will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the gathered key within the result. The state parsed reads the configuration from Choices:
|
Notes
Note
Tested against Soodar Version 23.11
This module works with connection
amnesh.soodar.network_cli.The module examples uses callback plugin (stdout_callback = yaml) to generate task output in yaml format.
Examples
# Using merged
# Before state:
# -------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address dhcp
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# interface ge4
# no ip address
# shutdown
- name: Merge provided configuration with device configuration
amnesh.soodar.soodar_l3_interfaces:
config:
- name: ge1
ipv4:
- address: 192.168.0.1/24
- name: ge2
ipv4:
- address: 192.168.0.2/24
- name: ge3
ipv6:
- address: fd5d:12c9:2201:1::1/64
- name: ge3.100
ipv4:
- address: 192.168.0.3/24
state: merged
# Task Output
# -----------
#
# before:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - dhcp:
# enable: true
# name: ge2
# - name: ge3
# - name: ge4
# - name: loopback999
# commands:
# - interface ge2
# - ip address 192.168.0.2/24
# - interface ge3
# - ipv6 address fd5d:12c9:2201:1::1/64
# - interface ge3.100
# - ip address 192.168.0.3/24
# after:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.2/24
# name: ge2
# - ipv6:
# - address: FD5D:12C9:2201:1::1/64
# name: ge3
# - name: ge3.100
# ipv4:
# - address: 192.168.0.3/24
# - name: ge4
# - name: loopback999
# After state:
# ------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.2/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# ipv6 address FD5D:12C9:2201:1::1/64
# interface ge3.100
# ip address 192.168.0.3/24
# interface ge4
# no ip address
# shutdown
# Using replaced
# Before state:
# -------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.2/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# ipv6 address FD5D:12C9:2201:1::1/64
# interface ge3.100
# interface ge4
# no ip address
# shutdown
- name: Replaces device configuration of listed interfaces with provided configuration
amnesh.soodar.soodar_l3_interfaces:
config:
- name: ge2
ipv4:
- address: 192.168.2.0/24
- name: ge3
ipv4:
- dhcp:
enable: true
state: replaced
# Task Output
# -----------
#
# before:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.2/24
# name: ge2
# - ipv6:
# - address: FD5D:12C9:2201:1::1/64
# name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# commands:
# - interface ge2
# - ip address 192.168.0.3/24
# - no ip address 192.168.0.2/24
# - interface ge3
# - ip address dhcp
# - no ipv6 address fd5d:12c9:2201:1::1/64
# after:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.3/24
# name: ge2
# - ipv4:
# - dhcp:
# enable: true
# name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# After state:
# ------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.3/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# ip address dhcp
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
# Using overridden
# Before state:
# -------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.3/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# ip address dhcp
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
- name: Override device configuration of all interfaces with provided configuration
amnesh.soodar.soodar_l3_interfaces:
config:
- ipv4:
- dhcp:
enable: true
name: ge1
- name: ge2
ipv4:
- address: 192.168.0.1/24
- name: ge3
state: overridden
# Task Output
# -----------
# before:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.3/24
# name: ge2
# - ipv4:
# - dhcp:
# client_id: ge2
# enable: true
# name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# commands:
# - interface ge2
# - ip address 192.168.0.1/24
# - no ip address 192.168.0.3/24
# - interface ge3
# - no ip address dhcp
# after:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.1/24
# name: ge2
# - name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# After state:
# ------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.1/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
# Using deleted
# Before state:
# -------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.1/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
- name: "Delete attributes of given interfaces (NOTE: This won't delete the interfaces)"
amnesh.soodar.soodar_l3_interfaces:
config:
- name: ge2
- name: ge3.100
state: deleted
# Task Output
# -----------
#
# before:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.1/24
# name: ge2
# - name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# commands:
# - interface ge2
# - no ip address 192.168.0.1/24
# after:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - name: ge2
# - name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# After state:
# -------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# no ip address
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
# Using deleted without config passed, only interface's configuration will be negated
# Before state:
# -------------
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.2/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# ipv6 address FD5D:12C9:2201:1::1/64
# interface ge3.100
# interface ge4
# no ip address
# shutdown
- name: "Delete L3 config of all interfaces"
amnesh.soodar.soodar_l3_interfaces:
state: deleted
# Task Output
# -----------
#
# before:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.2/24
# name: ge2
# - ipv6:
# - address: FD5D:12C9:2201:1::1/64
# name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# commands:
# - interface ge1
# - no ip address dhcp
# - interface ge2
# - no ip address 192.168.0.2/24
# - interface ge3
# - no ipv6 address fd5d:12c9:2201:1::1/64
# after:
# - name: ge1
# - name: ge2
# - name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# After state:
# -------------
#
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# interface ge2
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# no ip address
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
# Using gathered
# Before state:
# -------------
#
# Router# show running-config | section ^interface
# interface loopback999
# no ip address
# shutdown
# interface ge1
# description Management interface do not change
# ip address dhcp
# interface ge2
# ip address 192.168.0.3/24
# shutdown
# speed 1000
# interface ge3
# description Configured and Overridden by Ansible Network
# ip address dhcp
# shutdown
# speed 1000
# interface ge3.100
# interface ge4
# no ip address
# shutdown
- name: Gather facts for l3 interfaces
amnesh.soodar.soodar_l3_interfaces:
state: gathered
# Task Output
# -----------
#
# gathered:
# - ipv4:
# - dhcp:
# enable: true
# name: ge1
# - ipv4:
# - address: 192.168.0.3/24
# name: ge2
# - ipv4:
# - dhcp:
# enable: true
# name: ge3
# - name: ge3.100
# - name: ge4
# - name: loopback999
# Using rendered
- name: Render the commands for provided configuration
amnesh.soodar.soodar_l3_interfaces:
config:
- name: ge1
ipv4:
- dhcp:
enable: true
- name: ge2
ipv4:
- address: 198.51.100.2/24
ipv6:
- address: 2001:db8:0:3::/64
state: rendered
# Task Output
# -----------
#
# rendered:
# - interface ge1
# - ip address dhcp
# - interface ge2
# - ip address 198.51.100.1/24 secondary
# - ip address 198.51.100.2/24
# - ipv6 address 2001:db8:0:3::/64
# Using parsed
# File: parsed.cfg
# ----------------
#
# interface ge0
# ip address dhcp
# interface ge1
# ip address 198.51.100.1/24
# ipv6 address 2001:db8:0:3::/64
- name: Parse the provided configuration
amnesh.soodar.soodar_l3_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Task Output
# -----------
#
# parsed:
# - ipv4:
# - dhcp:
# enable: true
# name: ge0
# - ipv4:
# - address: 198.51.100.2/24
# ipv6:
# - address: 2001:db8:0:3::/64
# name: ge1
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The resulting configuration after module execution. Returned: when changed Sample: |
|
The configuration prior to the module execution. Returned: when state is Sample: |
|
The set of commands pushed to the remote device. Returned: when state is Sample: |
|
Facts about the network resource gathered from the remote device as structured data. Returned: when state is Sample: |
|
The device native config provided in running_config option parsed into structured data as per module argspec. Returned: when state is Sample: |
|
The provided configuration in the task rendered in device-native format (offline). Returned: when state is Sample: |