junipernetworks.junos.junos_interfaces – Junos Interfaces resource module¶
Note
This plugin is part of the junipernetworks.junos collection (version 1.3.0).
To install it use: ansible-galaxy collection install junipernetworks.junos.
To use it in a playbook, specify: junipernetworks.junos.junos_interfaces.
New in version 1.0.0: of junipernetworks.junos
Synopsis¶
This module manages the interfaces on Juniper Junos OS network devices.
Note
This module has a corresponding action plugin.
Requirements¶
The below requirements are needed on the host that executes this module.
ncclient (>=v0.6.4)
Parameters¶
Notes¶
Note
This module requires the netconf system service be enabled on the remote device being managed.
Tested against vSRX JUNOS version 18.4R1.
This module works with connection
netconf. See the Junos OS Platform Options.
Examples¶
# Using deleted
# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
# description "Configured by Ansible-1";
# speed 1g;
# mtu 1800
# }
# ge-0/0/2 {
# description "Configured by Ansible-2";
# ether-options {
# auto-negotiation;
# }
# }
- name: "Delete given options for the interface (Note: This won't delete the interface itself if any other values are configured for interface)"
junipernetworks.junos.junos_interfaces:
config:
- name: ge-0/0/1
description: Configured by Ansible-1
speed: 1g
mtu: 1800
- name: ge-0/0/2
description: Configured by Ansible -2
state: deleted
# After state:
# ------------
# user@junos01# show interfaces
# ge-0/0/2 {
# ether-options {
# auto-negotiation;
# }
# }
# Using merged
# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
# description "test interface";
# speed 1g;
# }
- name: Merge provided configuration with device configuration (default operation
is merge)
junipernetworks.junos.junos_interfaces:
config:
- name: ge-0/0/1
description: Configured by Ansible-1
enabled: true
mtu: 1800
- name: ge-0/0/2
description: Configured by Ansible-2
enabled: false
state: merged
# After state:
# ------------
# user@junos01# show interfaces
# ge-0/0/1 {
# description "Configured by Ansible-1";
# speed 1g;
# mtu 1800
# }
# ge-0/0/2 {
# disable;
# description "Configured by Ansible-2";
# }
# Using overridden
# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
# description "Configured by Ansible-1";
# speed 1g;
# mtu 1800
# }
# ge-0/0/2 {
# disable;
# description "Configured by Ansible-2";
# ether-options {
# auto-negotiation;
# }
# }
# ge-0/0/11 {
# description "Configured by Ansible-11";
# }
- name: Override device configuration of all interfaces with provided configuration
junipernetworks.junos.junos_interfaces:
config:
- name: ge-0/0/2
description: Configured by Ansible-2
enabled: false
mtu: 2800
- name: ge-0/0/3
description: Configured by Ansible-3
state: overridden
# After state:
# ------------
# user@junos01# show interfaces
# ge-0/0/2 {
# disable;
# description "Configured by Ansible-2";
# mtu 2800
# }
# ge-0/0/3 {
# description "Configured by Ansible-3";
# }
# Using replaced
# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
# description "Configured by Ansible-1";
# speed 1g;
# mtu 1800
# }
# ge-0/0/2 {
# disable;
# mtu 1800;
# speed 1g;
# description "Configured by Ansible-2";
# ether-options {
# auto-negotiation;
# }
# }
# ge-0/0/11 {
# description "Configured by Ansible-11";
# }
- name: Replaces device configuration of listed interfaces with provided configuration
junipernetworks.junos.junos_interfaces:
config:
- name: ge-0/0/2
description: Configured by Ansible-2
enabled: false
mtu: 2800
- name: ge-0/0/3
description: Configured by Ansible-3
state: replaced
# After state:
# ------------
# user@junos01# show interfaces
# ge-0/0/1 {
# description "Configured by Ansible-1";
# speed 1g;
# mtu 1800
# }
# ge-0/0/2 {
# disable;
# description "Configured by Ansible-2";
# mtu 2800
# }
# ge-0/0/3 {
# description "Configured by Ansible-3";
# }
# ge-0/0/11 {
# description "Configured by Ansible-11";
# }
# Using gathered
# Before state:
# ------------
#
# user@junos01# show interfaces
# gr-0/0/0 {
# description "test gre interface";
# }
# fxp0 {
# unit 0 {
# family inet {
# dhcp;
# }
# }
# }
# pp0 {
# unit 0 {
# pppoe-options {
# idle-timeout 100;
# access-concentrator ispl.com;
# service-name "[email protected]";
# auto-reconnect 100;
# client;
# ## Warning: missing mandatory statement(s): 'underlying-interface'
# }
# }
# }
#
- name: Gather junos interfaces as in given arguments
junipernetworks.junos.junos_interfaces:
state: gathered
# Task Output (redacted)
# -----------------------
#
# "gathered": [
# {
# "description": "test gre interface",
# "enabled": true,
# "name": "gr-0/0/0"
# },
# {
# "enabled": true,
# "name": "fxp0"
# },
# {
# "enabled": true,
# "name": "pp0"
# }
# ]
# After state:
# ------------
#
# user@junos01# show interfaces
# gr-0/0/0 {
# description "test gre interface";
# }
# fxp0 {
# unit 0 {
# family inet {
# dhcp;
# }
# }
# }
# pp0 {
# unit 0 {
# pppoe-options {
# idle-timeout 100;
# access-concentrator ispl.com;
# service-name "[email protected]";
# auto-reconnect 100;
# client;
# ## Warning: missing mandatory statement(s): 'underlying-interface'
# }
# }
# }
# Using parsed
# parsed.cfg
# ------------
#
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
# <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
# <interfaces>
# <interface>
# <name>ge-0/0/1</name>
# <description>Configured by Ansible</description>
# <disable/>
# <speed>100m</speed>
# <mtu>1024</mtu>
# <hold-time>
# <up>2000</up>
# <down>2200</down>
# </hold-time>
# <link-mode>full-duplex</link-mode>
# <unit>
# <name>0</name>
# <family>
# <ethernet-switching>
# <interface-mode>access</interface-mode>
# <vlan>
# <members>vlan100</members>
# </vlan>
# </ethernet-switching>
# </family>
# </unit>
# </interface>
# </interfaces>
# </configuration>
# </rpc-reply>
# - name: Convert interfaces config to argspec without connecting to the appliance
# junipernetworks.junos.junos_interfaces:
# running_config: "{{ lookup('file', './parsed.cfg') }}"
# state: parsed
# Task Output (redacted)
# -----------------------
# "parsed": [
# {
# "description": "Configured by Ansible",
# "duplex": "full-duplex",
# "enabled": false,
# "hold_time": {
# "down": 2200,
# "up": 2000
# },
# "mtu": 1024,
# "name": "ge-0/0/1",
# "speed": "100m"
# }
# ]
#
# Using rendered
- name: Render platform specific xml from task input using rendered state
junipernetworks.junos.junos_interfaces:
config:
- name: ge-0/0/2
description: Configured by Ansibull
mtu: 2048
speed: 20m
hold_time:
up: 3200
down: 3200
state: rendered
# Task Output (redacted)
# -----------------------
# "rendered": <nc:interfaces
# xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# <nc:interface>
# <nc:name>ge-0/0/2</nc:name>
# <nc:description>Configured by Ansibull</nc:description>
# <nc:speed>20m</nc:speed>
# <nc:mtu>2048</nc:mtu>
# <nc:hold-time>
# <nc:up>3200</nc:up>
# <nc:down>3200</nc:down>
# </nc:hold-time>
# </nc:interface>
# </nc:interfaces>"
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Ganesh Nalawade (@ganeshrn)