junos_l3_interfaces – Manage Layer 3 interface on Juniper JUNOS devices

New in version 2.9.

Synopsis

  • This module provides declarative management of a Layer 3 interface on Juniper JUNOS devices

Requirements

The below requirements are needed on the host that executes this module.

  • ncclient (>=v0.6.4)

Parameters

Parameter Choices/Defaults Comments
config
list / elements=dictionary
A dictionary of Layer 3 interface options
ipv4
list / elements=dictionary
IPv4 addresses to be set for the Layer 3 logical interface mentioned in name option. The address format is <ipv4 address>/<mask>. The mask is number in range 0-32 for example, 192.0.2.1/24, or dhcp to query DHCP for an IP address
address
string
IPv4 address to be set for the specific interface
ipv6
list / elements=dictionary
IPv6 addresses to be set for the Layer 3 logical interface mentioned in name option. The address format is <ipv6 address>/<mask>, the mask is number in range 0-128 for example, 2001:db8:2201:1::1/64 or auto-config to use SLAAC
address
string
IPv6 address to be set for the specific interface
name
string / required
Full name of interface, e.g. ge-0/0/1
unit
integer
Default:
0
Logical interface number. Value of unit should be of type integer
state
string
    Choices:
  • merged ←
  • replaced
  • overridden
  • deleted
The state of the configuration after module completion

Notes

Note

  • This module requires the netconf system service be enabled on the device being managed.

  • This module works with connection netconf. See the Junos OS Platform Options.

  • Tested against JunOS v18.4R1

Examples

# Using deleted

# Before state:
# -------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 10.200.16.10/24;
#         }
#     }
# }
# ge-0/0/2 {
#     description "non L3 interface";
#     unit 0 {
#         family ethernet-switching {
#             interface-mode access;
#             vlan {
#                 members 2;
#             }
#         }
#     }
# }

- name: Delete JUNOS L3 logical interface
  junos_l3_interfaces:
    config:
      - name: ge-0/0/1
      - name: ge-0/0/2
  state: deleted

# After state:
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "deleted L3 interface";
# }
# ge-0/0/2 {
#     description "non L3 interface";
#     unit 0 {
#         family ethernet-switching {
#             interface-mode access;
#             vlan {
#                 members 2;
#             }
#         }
#     }
# }


# Using merged

# Before state
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 10.200.16.10/24;
#         }
#     }
# }
# ge-0/0/2 {
#     description "non configured interface";
#     unit 0;
# }

- name: Merge provided configuration with device configuration (default operation is merge)
  junos_l3_interfaces:
    config:
      - name: ge-0/0/1
        ipv4:
           - address: 192.168.1.10/24
        ipv6:
           - address: 8d8d:8d01::1/64
      - name: ge-0/0/2
        ipv4:
           - address: dhcp
    state: merged

# After state:
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 10.200.16.10/24;
#             address 192.168.1.10/24;
#         }
#         family inet6 {
#             address 8d8d:8d01::1/64;
#         }
#     }
# }
# ge-0/0/2 {
#     description "L3 interface with dhcp";
#     unit 0 {
#         family inet {
#             dhcp;
#         }
#     }
# }


# Using overridden

# Before state
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 10.200.16.10/24;
#         }
#     }
# }
# ge-0/0/2 {
#     description "L3 interface with dhcp";
#     unit 0 {
#         family inet {
#             dhcp;
#         }
#     }
# }
# ge-0/0/3 {
#     description "another L3 interface";
#     unit 0 {
#         family inet {
#             address 192.168.1.10/24;
#         }
#     }
# }

- name: Override provided configuration with device configuration
  junos_l3_interfaces:
    config:
      - name: ge-0/0/1
        ipv4:
           - address: 192.168.1.10/24
        ipv6:
           - address: 8d8d:8d01::1/64
      - name: ge-0/0/2
        ipv6:
           - address: 2001:db8:3000::/64
    state: overridden

# After state:
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 192.168.1.10/24;
#         }
#         family inet6 {
#             address 8d8d:8d01::1/64;
#         }
#     }
# }
# ge-0/0/2 {
#     description "L3 interface with ipv6";
#     unit 0 {
#         family inet6 {
#             address 2001:db8:3000::/64;
#         }
#     }
# }
# ge-0/0/3 {
#     description "overridden L3 interface";
#     unit 0;
# }


# Using replaced

# Before state
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 10.200.16.10/24;
#         }
#     }
# }
# ge-0/0/2 {
#     description "non configured interface";
#     unit 0;
# }
# ge-0/0/3 {
#     description "another L3 interface";
#     unit 0 {
#         family inet {
#             address 192.168.1.10/24;
#         }
#     }
# }

- name: Replace provided configuration with device configuration
  junos_l3_interfaces:
    config:
      - name: ge-0/0/1
        ipv4:
           - address: 192.168.1.10/24
        ipv6:
           - address: 8d8d:8d01::1/64
      - name: ge-0/0/2
        ipv4:
           - address: dhcp
    state: replaced

# After state:
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
#     description "L3 interface";
#     unit 0 {
#         family inet {
#             address 192.168.1.10/24;
#         }
#         family inet6 {
#             address 8d8d:8d01::1/64;
#         }
#     }
# }
# ge-0/0/2 {
#     description "L3 interface with dhcp";
#     unit 0 {
#         family inet {
#             dhcp;
#         }
#     }
# }
# ge-0/0/3 {
#     description "another L3 interface";
#     unit 0 {
#         family inet {
#             address 192.168.1.10/24;
#         }
#     }
# }

Return Values

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

Key Returned Description
after
list
when changed
The configuration as structured data after module completion.

Sample:
The configuration returned will always be in the same format of the parameters above.
before
list
always
The configuration as structured data prior to module invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
commands
list
always
The set of commands pushed to the remote device.

Sample:
['command 1', 'command 2', 'command 3']


Status

Red Hat Support

More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.

Authors

  • Daniel Mellado (@dmellado)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.