summaryrefslogtreecommitdiffstats
path: root/ansible_collections/junipernetworks/junos/plugins/modules
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/junipernetworks/junos/plugins/modules
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/junipernetworks/junos/plugins/modules')
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_acl_interfaces.py70
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_acls.py21
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_banner.py2
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_address_family.py850
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_global.py852
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_command.py13
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py59
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_hostname.py1
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_interfaces.py751
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_l2_interfaces.py943
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_l3_interfaces.py707
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp.py1
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp_interfaces.py67
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_lag_interfaces.py67
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_lldp_interfaces.py26
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_logging.py16
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_ospf_interfaces.py59
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv2.py888
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv3.py640
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_package.py83
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_ping.py4
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_prefix_lists.py590
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_routing_instances.py78
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.py67
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_security_policies.py26
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_security_zones.py269
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_snmp_server.py44
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_static_routes.py267
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_system.py10
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_user.py17
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_vlans.py38
-rw-r--r--ansible_collections/junipernetworks/junos/plugins/modules/junos_vrf.py42
32 files changed, 5107 insertions, 2461 deletions
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_acl_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_acl_interfaces.py
index ccc604a11..9465cac7b 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_acl_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_acl_interfaces.py
@@ -131,15 +131,15 @@ EXAMPLES = """
- name: Delete JUNOS L3 interface filter
junipernetworks.junos.junos_acl_interfaces:
config:
- - name: ge-1/0/0
- access_groups:
- - afi: ipv4
- acls:
- - name: inbound_acl
- direction: in
- - name: outbound_acl
- direction: out
- state: deleted
+ - name: ge-1/0/0
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: inbound_acl
+ direction: in
+ - name: outbound_acl
+ direction: out
+ state: deleted
# After state:
# -------------
@@ -175,15 +175,15 @@ EXAMPLES = """
- name: Merge JUNOS L3 interface filter
junipernetworks.junos.junos_acl_interfaces:
config:
- - name: ge-1/0/0
- access_groups:
- - afi: ipv4
- acls:
- - name: inbound_acl
- direction: in
- - name: outbound_acl
- direction: out
- state: merged
+ - name: ge-1/0/0
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: inbound_acl
+ direction: in
+ - name: outbound_acl
+ direction: out
+ state: merged
# After state:
# -------------
@@ -226,15 +226,15 @@ EXAMPLES = """
- name: Override JUNOS L3 interface filter
junipernetworks.junos.junos_acl_interfaces:
config:
- - name: ge-1/0/0
- access_groups:
- - afi: ipv4
- acls:
- - name: inbound_acl
- direction: in
- - name: outbound_acl
- direction: out
- state: overridden
+ - name: ge-1/0/0
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: inbound_acl
+ direction: in
+ - name: outbound_acl
+ direction: out
+ state: overridden
# After state:
# -------------
@@ -278,13 +278,13 @@ EXAMPLES = """
- name: Replace JUNOS L3 interface filter
junipernetworks.junos.junos_acl_interfaces:
config:
- - name: ge-1/0/0
- access_groups:
- - afi: ipv4
- acls:
- - name: inbound_acl
- direction: in
- state: replaced
+ - name: ge-1/0/0
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: inbound_acl
+ direction: in
+ state: replaced
# After state:
# -------------
@@ -303,8 +303,6 @@ EXAMPLES = """
# }
# family inet6;
# }
-
-
"""
RETURN = """
before:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_acls.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_acls.py
index 2b1bafc7a..0b38587b0 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_acls.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_acls.py
@@ -278,16 +278,16 @@ EXAMPLES = """
- name: Merge JUNOS acl
junipernetworks.junos.junos_acls:
config:
- - afi: ipv4
- acls:
- - name: allow_ssh_acl
- aces:
- - name: ssh_rule
- source:
- port_protocol:
- eq: ssh
- protocol: tcp
- state: merged
+ - afi: ipv4
+ acls:
+ - name: allow_ssh_acl
+ aces:
+ - name: ssh_rule
+ source:
+ port_protocol:
+ eq: ssh
+ protocol: tcp
+ state: merged
# After state:
# -------------
@@ -302,7 +302,6 @@ EXAMPLES = """
# }
# }
# }
-
"""
RETURN = """
before:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_banner.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_banner.py
index d57f8f6aa..ce81a141a 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_banner.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_banner.py
@@ -49,7 +49,7 @@ options:
description:
- Specifies whether or not the configuration is active or deactivated
type: bool
- default: yes
+ default: true
requirements:
- ncclient (>=v0.5.2)
notes:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_address_family.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_address_family.py
index b40e5e816..66928d3c5 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_address_family.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_address_family.py
@@ -489,6 +489,90 @@ EXAMPLES = """
graceful_restart_forwarding_state_bit: 'from-fib'
state: merged
+# Task Output:
+# ------------
+#
+# before: {}
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:family><nc:evpn><nc:signaling>
+# <nc:accepted-prefix-limit><nc:maximum>20</nc:maximum><nc:teardown><nc:limit-threshold>98</nc:limit-threshold>
+# <nc:idle-timeout><nc:timeout>2001</nc:timeout></nc:idle-timeout></nc:teardown></nc:accepted-prefix-limit>
+# <nc:damping/><nc:defer-initial-multipath-build><nc:maximum-delay>2</nc:maximum-delay>
+# </nc:defer-initial-multipath-build></nc:signaling></nc:evpn><nc:inet><nc:flow><nc:legacy-redirect-ip-action>
+# <nc:send/><nc:receive/></nc:legacy-redirect-ip-action><nc:loops>4</nc:loops><nc:no-install/>
+# <nc:output-queue-priority><nc:expedited/></nc:output-queue-priority><nc:secondary-independent-resolution/>
+# </nc:flow><nc:unicast><nc:extended-nexthop/><nc:extended-nexthop-color/><nc:local-ipv4-address>9.9.9.9</nc:local-ipv4-address>
+# </nc:unicast><nc:labeled-unicast><nc:entropy-label><nc:no-next-hop-validation/></nc:entropy-label>
+# <nc:explicit-null><nc:connected-only/></nc:explicit-null><nc:per-prefix-label/><nc:per-group-label/>
+# <nc:prefix-limit><nc:maximum>20</nc:maximum><nc:teardown>99<nc:idle-timeout><nc:forever/></nc:idle-timeout>
+# </nc:teardown></nc:prefix-limit><nc:resolve-vpn/><nc:rib><nc:inet.3/></nc:rib><nc:route-refresh-priority>
+# <nc:expedited/><nc:priority>3</nc:priority></nc:route-refresh-priority></nc:labeled-unicast><nc:any>
+# <nc:accepted-prefix-limit><nc:maximum>20</nc:maximum><nc:teardown><nc:limit-threshold>99</nc:limit-threshold>
+# <nc:idle-timeout><nc:timeout>2000</nc:timeout></nc:idle-timeout></nc:teardown></nc:accepted-prefix-limit>
+# <nc:damping/><nc:defer-initial-multipath-build><nc:maximum-delay>2</nc:maximum-delay></nc:defer-initial-multipath-build>
+# <nc:delay-route-advertisements><nc:maximum-delay><nc:route-age>20</nc:route-age><nc:routing-uptime>32000</nc:routing-uptime>
+# </nc:maximum-delay><nc:minimum-delay><nc:inbound-convergence>32000</nc:inbound-convergence>
+# <nc:routing-uptime>23000</nc:routing-uptime></nc:minimum-delay></nc:delay-route-advertisements><nc:graceful-restart>
+# <nc:forwarding-state-bit>from-fib</nc:forwarding-state-bit></nc:graceful-restart></nc:any></nc:inet></nc:family>
+# </nc:bgp></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
+#
+# after:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+
# After state
# -----------
#
@@ -562,6 +646,8 @@ EXAMPLES = """
# }
# }
# }
+
+#
# Using replaced
#
# Before state
@@ -651,38 +737,154 @@ EXAMPLES = """
- name: Replace existing Junos BGP address family config with provided config
junipernetworks.junos.junos_bgp_address_family:
- config:
- address_family:
- - afi: 'evpn'
- af_type:
- - type: 'signaling'
- accepted_prefix_limit:
- maximum: 21
- limit_threshold: 99
- idle_timeout_value: 2002
- delay_route_advertisements:
- max_delay_route_age: 20
- max_delay_routing_uptime: 32000
- min_delay_inbound_convergence: 32000
- min_delay_routing_uptime: 23000
- damping: true
- state: replaced
+ config:
+ address_family:
+ - afi: 'evpn'
+ af_type:
+ - type: 'signaling'
+ accepted_prefix_limit:
+ maximum: 21
+ limit_threshold: 99
+ idle_timeout_value: 2002
+ delay_route_advertisements:
+ max_delay_route_age: 20
+ max_delay_routing_uptime: 32000
+ min_delay_inbound_convergence: 32000
+ min_delay_routing_uptime: 23000
+ damping: true
+ state: replaced
+# Task Output:
+# ------------
+#
+# before:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:family>
+# <nc:evpn delete="delete"/></nc:family><nc:family><nc:evpn><nc:signaling><nc:accepted-prefix-limit>
+# <nc:maximum>21</nc:maximum><nc:teardown><nc:limit-threshold>99</nc:limit-threshold><nc:idle-timeout>
+# <nc:timeout>2002</nc:timeout></nc:idle-timeout></nc:teardown></nc:accepted-prefix-limit><nc:damping/>
+# <nc:delay-route-advertisements><nc:maximum-delay><nc:route-age>20</nc:route-age>
+# <nc:routing-uptime>32000</nc:routing-uptime></nc:maximum-delay><nc:minimum-delay>
+# <nc:inbound-convergence>32000</nc:inbound-convergence><nc:routing-uptime>23000</nc:routing-uptime>
+# </nc:minimum-delay></nc:delay-route-advertisements></nc:signaling></nc:evpn></nc:family></nc:bgp></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
+#
+# after:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2002
+# limit_threshold: 99
+# maximum: 21
+# damping: true
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+#
# After state
# -----------
#
# admin# show protocols bgp
-# preference 2;
-# hold-time 5;
-# advertise-inactive;
-# out-delay 10;
-# bgp-error-tolerance {
-# malformed-route-limit 40000000;
-# }
-# authentication-algorithm md5;
-# advertise-bgp-static {
-# policy static-to-bgp;
-# }
# family inet {
# unicast {
# local-ipv4-address 9.9.9.9;
@@ -759,6 +961,7 @@ EXAMPLES = """
# }
# }
# }
+
# Using overridden
#
# Before state
@@ -837,23 +1040,96 @@ EXAMPLES = """
- name: Override Junos BGP address family config
junipernetworks.junos.junos_bgp_address_family:
- config:
- address_family:
- - afi: 'evpn'
- af_type:
- - type: 'signaling'
- accepted_prefix_limit:
- maximum: 21
- limit_threshold: 99
- idle_timeout_value: 2002
- delay_route_advertisements:
- max_delay_route_age: 20
- max_delay_routing_uptime: 32000
- min_delay_inbound_convergence: 32000
- min_delay_routing_uptime: 23000
- damping: true
- state: overridden
+ config:
+ address_family:
+ - afi: 'evpn'
+ af_type:
+ - type: 'signaling'
+ accepted_prefix_limit:
+ maximum: 21
+ limit_threshold: 99
+ idle_timeout_value: 2002
+ delay_route_advertisements:
+ max_delay_route_age: 20
+ max_delay_routing_uptime: 32000
+ min_delay_inbound_convergence: 32000
+ min_delay_routing_uptime: 23000
+ damping: true
+ state: overridden
+# Task Output:
+# ------------
+#
+# before:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2002
+# limit_threshold: 99
+# maximum: 21
+# damping: true
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:family>
+# <nc:evpn delete="delete"/><nc:inet delete="delete"/></nc:family><nc:family><nc:evpn delete="delete"/>
+# </nc:family><nc:family><nc:evpn><nc:signaling><nc:accepted-prefix-limit><nc:maximum>21</nc:maximum>
+# <nc:teardown><nc:limit-threshold>99</nc:limit-threshold><nc:idle-timeout><nc:timeout>2002</nc:timeout>
+# </nc:idle-timeout></nc:teardown></nc:accepted-prefix-limit><nc:damping/><nc:delay-route-advertisements>
+# <nc:maximum-delay><nc:route-age>20</nc:route-age><nc:routing-uptime>32000</nc:routing-uptime>
+# </nc:maximum-delay><nc:minimum-delay><nc:inbound-convergence>32000</nc:inbound-convergence>
+# <nc:routing-uptime>23000</nc:routing-uptime></nc:minimum-delay></nc:delay-route-advertisements>
+# </nc:signaling></nc:evpn></nc:family></nc:bgp></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
+#
# After state
# -----------
#
@@ -960,19 +1236,91 @@ EXAMPLES = """
- name: Delete Junos BGP address family config based on the afi
junipernetworks.junos.junos_bgp_address_family:
- config:
- address_family:
- - afi: 'inet'
- state: deleted
+ config:
+ address_family:
+ - afi: 'inet'
+ state: deleted
+# Task Output:
+# ------------
+#
+# before:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp>
+# <nc:family><nc:inet delete="delete"/></nc:family></nc:bgp></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
+#
+# after:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+#
# After state
# -----------
#
# admin# show protocols bgp
-# preference 2;
-# hold-time 5;
-# advertise-inactive;
-# out-delay 10;
# family evpn {
# signaling {
# accepted-prefix-limit {
@@ -992,10 +1340,6 @@ EXAMPLES = """
# ------------
#
# admin# show protocols bgp
-# preference 2;
-# hold-time 5;
-# advertise-inactive;
-# out-delay 10;
# family inet {
# unicast {
# local-ipv4-address 9.9.9.9;
@@ -1068,18 +1412,79 @@ EXAMPLES = """
- name: Delete complete Junos BGP address family config
junipernetworks.junos.junos_bgp_address_family:
- config:
- state: deleted
+ config:
+ state: deleted
+
+# Task Output:
+# ------------
+#
+# before:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:bgp><nc:family><nc:evpn delete="delete"/><nc:inet delete="delete"/>
+# </nc:family></nc:bgp></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
+#
+# after: {}
# After state
# -----------
#
# admin# show protocols bgp
-# preference 2;
-# hold-time 5;
-# advertise-inactive;
-# out-delay 10;
-
+#
# Using gathered
#
@@ -1087,10 +1492,6 @@ EXAMPLES = """
# ------------
#
# admin# show protocols bgp
-# preference 2;
-# hold-time 5;
-# advertise-inactive;
-# out-delay 10;
# family inet {
# unicast {
# local-ipv4-address 9.9.9.9;
@@ -1167,92 +1568,64 @@ EXAMPLES = """
state: gathered
#
#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "gathered": {
-# "address_family": [
-# {
-# "af_type": [
-# {
-# "accepted_prefix_limit": {
-# "idle_timeout_value": 2001,
-# "limit_threshold": 98,
-# "maximum": 20
-# },
-# "damping": true,
-# "defer_initial_multipath_build": {
-# "maximum_delay": 2
-# },
-# "type": "signaling"
-# }
-# ],
-# "afi": "evpn"
-# },
-# {
-# "af_type": [
-# {
-# "accepted_prefix_limit": {
-# "idle_timeout_value": 2000,
-# "limit_threshold": 99,
-# "maximum": 20
-# },
-# "damping": true,
-# "defer_initial_multipath_build": {
-# "maximum_delay": 2
-# },
-# "delay_route_advertisements": {
-# "max_delay_route_age": 20,
-# "max_delay_routing_uptime": 32000,
-# "min_delay_inbound_convergence": 32000,
-# "min_delay_routing_uptime": 23000
-# },
-# "graceful_restart_forwarding_state_bit": "from-fib",
-# "type": "any"
-# },
-# {
-# "legacy_redirect_ip_action": {
-# "receive": true,
-# "send": true
-# },
-# "loops": 4,
-# "no_install": true,
-# "output_queue_priority_expedited": true,
-# "secondary_independent_resolution": true,
-# "type": "flow"
-# },
-# {
-# "entropy_label": {
-# "no_next_hop_validation": true
-# },
-# "explicit_null": {
-# "connected_only": true
-# },
-# "per_group_label": true,
-# "per_prefix_label": true,
-# "prefix_limit": {
-# "forever": true,
-# "limit_threshold": 99,
-# "maximum": 20
-# },
-# "resolve_vpn": true,
-# "rib": "inet.3",
-# "route_refresh_priority_priority": 3,
-# "type": "labeled-unicast"
-# },
-# {
-# "extended_nexthop": true,
-# "extended_nexthop_color": true,
-# "local_ipv4_address": "9.9.9.9",
-# "type": "unicast"
-# }
-# ],
-# "afi": "inet"
-# }
-# ]
-# }
+# Task Output:
+# ------------
#
+# gathered:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+
# Using parsed
# parsed.cfg
# ------------
@@ -1396,96 +1769,66 @@ EXAMPLES = """
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
#
+# Task Output:
+# ------------
#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "parsed": {
-# "address_family": [
-# {
-# "af_type": [
-# {
-# "accepted_prefix_limit": {
-# "idle_timeout_value": 2001,
-# "limit_threshold": 98,
-# "maximum": 20
-# },
-# "damping": true,
-# "defer_initial_multipath_build": {
-# "maximum_delay": 2
-# },
-# "type": "signaling"
-# }
-# ],
-# "afi": "evpn"
-# },
-# {
-# "af_type": [
-# {
-# "accepted_prefix_limit": {
-# "idle_timeout_value": 2000,
-# "limit_threshold": 99,
-# "maximum": 20
-# },
-# "damping": true,
-# "defer_initial_multipath_build": {
-# "maximum_delay": 2
-# },
-# "delay_route_advertisements": {
-# "max_delay_route_age": 20,
-# "max_delay_routing_uptime": 32000,
-# "min_delay_inbound_convergence": 32000,
-# "min_delay_routing_uptime": 23000
-# },
-# "graceful_restart_forwarding_state_bit": "from-fib",
-# "type": "any"
-# },
-# {
-# "legacy_redirect_ip_action": {
-# "receive": true,
-# "send": true
-# },
-# "loops": 4,
-# "no_install": true,
-# "output_queue_priority_expedited": true,
-# "secondary_independent_resolution": true,
-# "type": "flow"
-# },
-# {
-# "entropy_label": {
-# "no_next_hop_validation": true
-# },
-# "explicit_null": {
-# "connected_only": true
-# },
-# "per_group_label": true,
-# "per_prefix_label": true,
-# "prefix_limit": {
-# "forever": true,
-# "limit_threshold": 99,
-# "maximum": 20
-# },
-# "resolve_vpn": true,
-# "rib": "inet.3",
-# "route_refresh_priority_priority": 3,
-# "type": "labeled-unicast"
-# },
-# {
-# "extended_nexthop": true,
-# "extended_nexthop_color": true,
-# "local_ipv4_address": "9.9.9.9",
-# "type": "unicast"
-# }
-# ],
-# "afi": "inet"
-# }
-# ]
-# }
+# parsed:
+# address_family:
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2001
+# limit_threshold: 98
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# type: signaling
+# afi: evpn
+# - af_type:
+# - accepted_prefix_limit:
+# idle_timeout_value: 2000
+# limit_threshold: 99
+# maximum: 20
+# damping: true
+# defer_initial_multipath_build:
+# maximum_delay: 2
+# delay_route_advertisements:
+# max_delay_route_age: 20
+# max_delay_routing_uptime: 32000
+# min_delay_inbound_convergence: 32000
+# min_delay_routing_uptime: 23000
+# graceful_restart_forwarding_state_bit: from-fib
+# type: any
+# - legacy_redirect_ip_action:
+# receive: true
+# send: true
+# loops: 4
+# no_install: true
+# output_queue_priority_expedited: true
+# secondary_independent_resolution: true
+# type: flow
+# - entropy_label:
+# no_next_hop_validation: true
+# explicit_null:
+# connected_only: true
+# per_group_label: true
+# per_prefix_label: true
+# prefix_limit:
+# forever: true
+# limit_threshold: 99
+# maximum: 20
+# resolve_vpn: true
+# rib: inet.3
+# route_refresh_priority_priority: 3
+# type: labeled-unicast
+# - extended_nexthop: true
+# extended_nexthop_color: true
+# local_ipv4_address: 9.9.9.9
+# type: unicast
+# afi: inet
+
# Using rendered
#
-#
- name: Render the commands for provided configuration
junipernetworks.junos.junos_bgp_address_family:
config:
@@ -1548,14 +1891,10 @@ EXAMPLES = """
graceful_restart_forwarding_state_bit: 'from-fib'
state: rendered
+# Task Output:
+# ------------
#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "rendered": "<nc:protocols xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
+# rendered: "<nc:protocols xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
# <nc:bgp><nc:family><nc:evpn><nc:signaling><nc:accepted-prefix-limit><nc:maximum>20</nc:maximum>
# <nc:teardown><nc:limit-threshold>98</nc:limit-threshold><nc:idle-timeout><nc:timeout>2001</nc:timeout>
# </nc:idle-timeout></nc:teardown></nc:accepted-prefix-limit><nc:damping/><nc:defer-initial-multipath-build>
@@ -1581,7 +1920,6 @@ EXAMPLES = """
# <nc:routing-uptime>23000</nc:routing-uptime></nc:minimum-delay></nc:delay-route-advertisements>
# <nc:graceful-restart><nc:forwarding-state-bit>from-fib</nc:forwarding-state-bit>
# </nc:graceful-restart></nc:any></nc:inet></nc:family></nc:bgp></nc:protocols>"
-
"""
RETURN = """
before:
@@ -1612,6 +1950,26 @@ commands:
</nc:maximum-delay><nc:minimum-delay><nc:inbound-convergence>32000</nc:inbound-convergence>
<nc:routing-uptime>23000</nc:routing-uptime></nc:minimum-delay></nc:delay-route-advertisements>
</nc:signaling></nc:evpn></nc:family></nc:bgp></nc:protocols>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_global.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_global.py
index de4715ff0..70c779e32 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_global.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_bgp_global.py
@@ -947,6 +947,7 @@ options:
- purged
- merged
- replaced
+ - overridden
- deleted
- gathered
- parsed
@@ -956,16 +957,15 @@ options:
EXAMPLES = """
# Using merged
#
-# Before state
-# ------------
+# Before state:
+# -------------
#
-# admin# show protocols bgp
-# [edit]
+# vsrx# show bgp summary
+# BGP is not running
-# admin# show routing-options autonomous-system
-# [edit]
+# vsrx# show routing-options autonomous-system
-- name: Merge Junos BGP config
+- name: Merge provided bgp config with device configuration
junipernetworks.junos.junos_bgp_global:
config:
as_number: "65534"
@@ -973,8 +973,6 @@ EXAMPLES = """
asdot_notation: true
accept_remote_nexthop: true
add_path_display_ipv4_address: true
- advertise_bgp_static:
- policy: "static-to-bgp"
advertise_from_main_vpn_tables: true
advertise_inactive: true
authentication_algorithm: "md5"
@@ -997,13 +995,50 @@ EXAMPLES = """
preference: 2
state: merged
-# After state
-# -----------
+# Task Output:
+# ------------
+# before: {}
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:accept-remote-nexthop/>
+# <nc:add-path-display-ipv4-address/><nc:advertise-from-main-vpn-tables/><nc:advertise->
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:autonomous-system>65534<nc:loops>3</nc:loops><nc:asdot-notation/></nc:autonomous-system></nc:routing-options>
#
-# admin# show routing-options autonomous-system
+# after:
+# accept_remote_nexthop: true
+# add_path_display_ipv4_address: true
+# advertise_from_main_vpn_tables: true
+# advertise_inactive: true
+# as_number: '65534'
+# asdot_notation: true
+# authentication_algorithm: md5
+# bgp_error_tolerance:
+# malformed_route_limit: 20000000
+# bmp:
+# monitor: true
+# damping: true
+# description: This is configured with Junos_bgp resource module
+# egress_te_sid_stats: true
+# hold_time: 5
+# holddown_all_stale_labels: true
+# include_mp_next_hop: true
+# log_updown: true
+# loops: 3
+# no_advertise_peer_as: true
+# no_aggregator_id: true
+# no_client_reflect: true
+# out_delay: 10
+# precision_timers: true
+# preference: '2'
+
+# After state:
+# ------------
+#
+# vsrx# show routing-options autonomous-system
# 65534 loops 3 asdot-notation;
-# admin# show protocols bgp
+# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
@@ -1026,22 +1061,17 @@ EXAMPLES = """
# bmp {
# monitor enable;
# }
-# advertise-bgp-static {
-# policy static-to-bgp;
-# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
-
-# Using merged
+# Using replaced
#
-# Before state
-# ------------
+# Before state:
+# -------------
#
-# admin# show routing-options autonomous-system
-# 65534 loops 3 asdot-notation;
-
-# admin# show protocols bgp
+# vsrx# show routing-options autonomous-system
+# [edit]
+# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
@@ -1064,146 +1094,123 @@ EXAMPLES = """
# bmp {
# monitor enable;
# }
-# advertise-bgp-static {
-# policy static-to-bgp;
-# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
-- name: Update running Junos BGP config
+- name: Replace running config with provided config
junipernetworks.junos.junos_bgp_global:
config:
- egress_te_backup_paths:
- templates:
- - path_name: customer1
- peers:
- - '11.11.11.11'
- - '11.11.11.12'
- - '11.11.11.13'
- remote_nexthop: '2.2.2.2'
- groups:
- - name: 'internal'
- type: 'internal'
- vpn_apply_export: true
- out_delay: 30
- accept_remote_nexthop: true
- add_path_display_ipv4_address: true
- peer_as: '65534'
- allow:
- - 'all'
- - '1.1.1.0/24'
- neighbors:
- - neighbor_address: '11.11.11.11'
- peer_as: '65534'
- out_delay: 11
- - neighbor_address: '11.11.11.12'
- peer_as: '65534'
- out_delay: 12
-
- - name: 'external'
- out_delay: 20
- peer_as: '65534'
- accept_remote_nexthop: true
- add_path_display_ipv4_address: true
- neighbors:
- - neighbor_address: '12.12.12.12'
- peer_as: '65534'
- out_delay: 21
- accept_remote_nexthop: true
- add_path_display_ipv4_address: true
- - neighbor_address: '11.11.11.13'
- peer_as: '65534'
- out_delay: 31
- accept_remote_nexthop: true
- add_path_display_ipv4_address: true
- state: merged
+ advertise_inactive: true
+ authentication_algorithm: "md5"
+ bfd_liveness_detection:
+ minimum_receive_interval: 8
+ multiplier: 30
+ no_adaptation: true
+ transmit_interval:
+ minimum_interval: 4
+ version: "automatic"
+ bgp_error_tolerance:
+ malformed_route_limit: 40000000
+ description: "Replace running bgp config"
+ egress_te_sid_stats: true
+ hold_time: 5
+ out_delay: 10
+ preference: "2"
+ state: replaced
-# After state
-# -----------
+# Task Output:
+# ------------
#
-# admin# show routing-options autonomous-system
-# 65534 loops 3 asdot-notation;
+# before:
+# accept_remote_nexthop: true
+# add_path_display_ipv4_address: true
+# advertise_from_main_vpn_tables: true
+# advertise_inactive: true
+# as_number: '65534'
+# asdot_notation: true
+# authentication_algorithm: md5
+# bgp_error_tolerance:
+# malformed_route_limit: 20000000
+# bmp:
+# monitor: true
+# damping: true
+# description: This is configured with Junos_bgp resource module
+# egress_te_sid_stats: true
+# hold_time: 5
+# holddown_all_stale_labels: true
+# include_mp_next_hop: true
+# log_updown: true
+# loops: 3
+# no_advertise_peer_as: true
+# no_aggregator_id: true
+# no_client_reflect: true
+# out_delay: 10
+# precision_timers: true
+# preference: '2'
-# admin# show protocols bgp
-# precision-timers;
-# advertise-from-main-vpn-tables;
-# holddown-all-stale-labels;
-# egress-te-backup-paths {
-# template customer1 {
-# peer 11.11.11.11;
-# peer 11.11.11.12;
-# peer 11.11.11.13;
-# remote-nexthop {
-# 2.2.2.2;
-# }
-# }
-# }
-# description "This is configured with Junos_bgp resource module";
-# accept-remote-nexthop;
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp>
+# <nc:accept-remote-nexthop delete="delete"/><nc:add-path-display-ipv4-address delete="delete"/><nc:advertise-bgp-t
+# delete="delete"/><nc:include-mp-next-hop delete="delete"/><nc:ipsec-sa delete="delete"/><nc:keep delete="delete"/>
+# <nc:local-address delete="delete"/><nc:local-interface delete="delete"/t
+# delete="delete"/></nc:bgp><nc:bgp><nc:advertise-inactive/><nc:egress-te-sid-stats/>
+# <nc:authentication-algorithm>md5</nc:authentication-algorithm><nc:description>Replace running bgp conf>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:autonomous-system delete="delete"/></nc:routing-options>
+
+#
+# after:
+# advertise_inactive: true
+# authentication_algorithm: md5
+# bfd_liveness_detection:
+# minimum_receive_interval: 8
+# multiplier: 30
+# no_adaptation: true
+# transmit_interval:
+# minimum_interval: 4
+# version: automatic
+# bgp_error_tolerance:
+# malformed_route_limit: 40000000
+# description: Replace running bgp config
+# egress_te_sid_stats: true
+# hold_time: 5
+# out_delay: 10
+# preference: '2'
+
+# After state:
+# ------------
+#
+# varx# show protocols bgp
+# description "Replace running bgp config";
# preference 2;
# hold-time 5;
# advertise-inactive;
-# no-advertise-peer-as;
-# no-aggregator-id;
# out-delay 10;
-# log-updown;
-# damping;
# bgp-error-tolerance {
-# malformed-route-limit 20000000;
+# malformed-route-limit 40000000;
# }
# authentication-algorithm md5;
-# no-client-reflect;
-# include-mp-next-hop;
-# bmp {
-# monitor enable;
-# }
-# add-path-display-ipv4-address;
-# egress-te-sid-stats;
-# group internal {
-# type internal;
-# accept-remote-nexthop;
-# out-delay 30;
-# vpn-apply-export;
-# peer-as 65534;
-# add-path-display-ipv4-address;
-# allow [ 0.0.0.0/0 1.1.1.0/24 ];
-# neighbor 11.11.11.11 {
-# out-delay 11;
-# peer-as 65534;
-# }
-# neighbor 11.11.11.12 {
-# out-delay 12;
-# peer-as 65534;
-# }
-# }
-# group external {
-# accept-remote-nexthop;
-# out-delay 20;
-# peer-as 65534;
-# add-path-display-ipv4-address;
-# neighbor 12.12.12.12 {
-# accept-remote-nexthop;
-# out-delay 21;
-# peer-as 65534;
-# add-path-display-ipv4-address;
-# }
-# neighbor 11.11.11.13 {
-# accept-remote-nexthop;
-# out-delay 31;
-# peer-as 65534;
-# add-path-display-ipv4-address;
+# bfd-liveness-detection {
+# version automatic;
+# minimum-receive-interval 8;
+# multiplier 30;
+# no-adaptation;
+# transmit-interval {
+# minimum-interval 4;
# }
# }
+# egress-te-sid-stats;
+# vsrx# show routing-options autonomous-system
-# Using replaced
+# Using overridden
+# "(NOTE: This will work same as replaced operation)"
#
-# Before state
-# ------------
+# Before state:
+# -------------
#
-# admin# show routing-options autonomous-system
+# vsrx# show routing-options autonomous-system
# [edit]
-# admin# show protocols bgp
+# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
@@ -1226,40 +1233,93 @@ EXAMPLES = """
# bmp {
# monitor enable;
# }
-# advertise-bgp-static {
-# policy static-to-bgp;
-# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
-- name: Replace Junos BGP global config
+- name: Override running config with provided config
junipernetworks.junos.junos_bgp_global:
- config:
- advertise_bgp_static:
- policy: "static-to-bgp"
- advertise_inactive: true
- authentication_algorithm: "md5"
- bfd_liveness_detection:
- minimum_receive_interval: 8
- multiplier: 30
- no_adaptation: true
- transmit_interval:
- minimum_interval: 4
- version: "automatic"
- bgp_error_tolerance:
- malformed_route_limit: 40000000
- description: "This is configured with Junos_bgp resource module replace"
- egress_te_sid_stats: true
- hold_time: 5
- out_delay: 10
- preference: "2"
- state: replaced
-
-# After state
-# -----------
+ config:
+ advertise_inactive: true
+ authentication_algorithm: "md5"
+ bfd_liveness_detection:
+ minimum_receive_interval: 8
+ multiplier: 30
+ no_adaptation: true
+ transmit_interval:
+ minimum_interval: 4
+ version: "automatic"
+ bgp_error_tolerance:
+ malformed_route_limit: 40000000
+ description: "Replace running bgp config"
+ egress_te_sid_stats: true
+ hold_time: 5
+ out_delay: 10
+ preference: "2"
+ state: overridden
+
+# Task Output:
+# ------------
+#
+# before:
+# accept_remote_nexthop: true
+# add_path_display_ipv4_address: true
+# advertise_from_main_vpn_tables: true
+# advertise_inactive: true
+# as_number: '65534'
+# asdot_notation: true
+# authentication_algorithm: md5
+# bgp_error_tolerance:
+# malformed_route_limit: 20000000
+# bmp:
+# monitor: true
+# damping: true
+# description: This is configured with Junos_bgp resource module
+# egress_te_sid_stats: true
+# hold_time: 5
+# holddown_all_stale_labels: true
+# include_mp_next_hop: true
+# log_updown: true
+# loops: 3
+# no_advertise_peer_as: true
+# no_aggregator_id: true
+# no_client_reflect: true
+# out_delay: 10
+# precision_timers: true
+# preference: '2'
+
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp>
+# <nc:accept-remote-nexthop delete="delete"/><nc:add-path-display-ipv4-address delete="delete"/><nc:advertise-bgp-t
+# delete="delete"/><nc:include-mp-next-hop delete="delete"/><nc:ipsec-sa delete="delete"/><nc:keep delete="delete"/>
+# <nc:local-address delete="delete"/><nc:local-interface delete="delete"/t
+# delete="delete"/></nc:bgp><nc:bgp><nc:advertise-inactive/><nc:egress-te-sid-stats/>
+# <nc:authentication-algorithm>md5</nc:authentication-algorithm><nc:description>Replace running bgp conf>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:autonomous-system delete="delete"/></nc:routing-options>
+
#
-# admin# show protocols bgp
-# description "This is configured with Junos_bgp resource module replace";
+# after:
+# advertise_inactive: true
+# authentication_algorithm: md5
+# bfd_liveness_detection:
+# minimum_receive_interval: 8
+# multiplier: 30
+# no_adaptation: true
+# transmit_interval:
+# minimum_interval: 4
+# version: automatic
+# bgp_error_tolerance:
+# malformed_route_limit: 40000000
+# description: Replace running bgp config
+# egress_te_sid_stats: true
+# hold_time: 5
+# out_delay: 10
+# preference: '2'
+
+# After state:
+# ------------
+#
+# varx# show protocols bgp
+# description "Replace running bgp config";
# preference 2;
# hold-time 5;
# advertise-inactive;
@@ -1268,9 +1328,6 @@ EXAMPLES = """
# malformed-route-limit 40000000;
# }
# authentication-algorithm md5;
-# advertise-bgp-static {
-# policy static-to-bgp;
-# }
# bfd-liveness-detection {
# version automatic;
# minimum-receive-interval 8;
@@ -1282,136 +1339,149 @@ EXAMPLES = """
# }
# egress-te-sid-stats;
-# admin# show routing-options autonomous-system
-# [edit]
+# vsrx# show routing-options autonomous-system
-#
# Using deleted
-#
+# "(NOTE: This WILL delete the bgp global attributes)"
# Before state
# ------------
#
-# admin# show protocols bgp
-# precision-timers;
-# advertise-from-main-vpn-tables;
-# holddown-all-stale-labels;
-# description "This is configured with Junos_bgp resource module";
-# accept-remote-nexthop;
+# vsrx# show protocols bgp
+# description "Replace running bgp config";
# preference 2;
# hold-time 5;
# advertise-inactive;
-# no-advertise-peer-as;
-# no-aggregator-id;
# out-delay 10;
-# log-updown;
-# damping;
# bgp-error-tolerance {
-# malformed-route-limit 20000000;
+# malformed-route-limit 40000000;
# }
# authentication-algorithm md5;
-# no-client-reflect;
-# include-mp-next-hop;
-# bmp {
-# monitor enable;
+# bfd-liveness-detection {
+# version automatic;
+# minimum-receive-interval 8;
+# multiplier 30;
+# no-adaptation;
+# transmit-interval {
+# minimum-interval 4;
+# }
# }
-# add-path-display-ipv4-address;
# egress-te-sid-stats;
-# group internal {
-# out-delay 12;
-# }
-# admin# show routing-options autonomous-system
-# 65534 loops 3 asdot-notation;
-- name: Delete Junos BGP global config
+- name: Delete bgp section of running config
junipernetworks.junos.junos_bgp_global:
config:
state: deleted
-# After state
-# -----------
-# admin# show protocols bgp
-# group internal {
-# out-delay 12;
-# }
+# Task Output:
+# ------------
+# before:
+# advertise_inactive: true
+# authentication_algorithm: md5
+# bfd_liveness_detection:
+# minimum_receive_interval: 8
+# multiplier: 30
+# no_adaptation: true
+# transmit_interval:
+# minimum_interval: 4
+# version: automatic
+# bgp_error_tolerance:
+# malformed_route_limit: 40000000
+# description: Replace running bgp config
+# egress_te_sid_stats: true
+# hold_time: 5
+# out_delay: 10
+# preference: '2'
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:accept-remote-nexthop delete="delete"/>
+# <nc:add-path-display-ipv4-address delete="delete"/><nc:advertise-bgp-t
+# delete="delete"/><nc:include-mp-next-hop delete="delete"/><nc:ipsec-sa delete="delete"/><nc:keep delete="delete"/>
+# <nc:local-address delete="delete"/><nc:local-interface delete="delete"/t
+# delete="delete"/></nc:bgp></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
-# admin# show protocols bgp
-# [edit]
+# after: {}
+
+# After state:
+# ------------
+# vsrx# show protocols bgp
+
+# vsrx# show routing-options autonomous-system
-# admin# show routing-options autonomous-system
-# [edit]
# Using gathered
#
-# Before state
-# ------------
+# Before state:
+# -------------
#
-# admin# show protocols bgp
-# description "This is configured with Junos_bgp resource module replace";
+# vsrx# show protocols bgp
+# precision-timers;
+# advertise-from-main-vpn-tables;
+# holddown-all-stale-labels;
+# description "This is configured with Junos_bgp resource module";
+# accept-remote-nexthop;
# preference 2;
# hold-time 5;
# advertise-inactive;
+# no-advertise-peer-as;
+# no-aggregator-id;
# out-delay 10;
+# log-updown;
+# damping;
# bgp-error-tolerance {
-# malformed-route-limit 40000000;
+# malformed-route-limit 20000000;
# }
# authentication-algorithm md5;
-# advertise-bgp-static {
-# policy static-to-bgp;
-# }
-# bfd-liveness-detection {
-# version automatic;
-# minimum-receive-interval 8;
-# multiplier 30;
-# no-adaptation;
-# transmit-interval {
-# minimum-interval 4;
-# }
+# no-client-reflect;
+# include-mp-next-hop;
+# bmp {
+# monitor enable;
# }
+# add-path-display-ipv4-address;
# egress-te-sid-stats;
-- name: Gather Junos BGP global config
+- name: Gather BGP facts from running config
junipernetworks.junos.junos_bgp_global:
config:
state: gathered
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "gathered": {
-# "advertise_bgp_static": {
-# "policy": "static-to-bgp"
-# },
-# "advertise_inactive": true,
-# "authentication_algorithm": "md5",
-# "bfd_liveness_detection": {
-# "minimum_receive_interval": 8,
-# "multiplier": 30,
-# "no_adaptation": true,
-# "transmit_interval": {
-# "minimum_interval": 4
-# },
-# "version": "automatic"
-# },
-# "bgp_error_tolerance": {
-# "malformed_route_limit": 40000000
-# },
-# "description": "This is configured with Junos_bgp resource module replace",
-# "egress_te_sid_stats": true,
-# "hold_time": 5,
-# "out_delay": 10,
-# "preference": "2"
-# }
-#
-#
-# Using purged
-#
-# Before state
+
+# Task Output:
# ------------
+
+# gathered:
+# accept_remote_nexthop: true
+# add_path_display_ipv4_address: true
+# advertise_from_main_vpn_tables: true
+# advertise_inactive: true
+# as_number: '65534'
+# asdot_notation: true
+# authentication_algorithm: md5
+# bgp_error_tolerance:
+# malformed_route_limit: 20000000
+# bmp:
+# monitor: true
+# damping: true
+# description: This is configured with Junos_bgp resource module
+# egress_te_sid_stats: true
+# hold_time: 5
+# holddown_all_stale_labels: true
+# include_mp_next_hop: true
+# log_updown: true
+# loops: 3
+# no_advertise_peer_as: true
+# no_aggregator_id: true
+# no_client_reflect: true
+# out_delay: 10
+# precision_timers: true
+# preference: '2'
+
+# Using purged
+# "(NOTE: This WILL delete the configured global BGP, and BGP address family config)"
+
+# Before state:
+# -------------
#
-# admin# show protocols bgp
+# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
@@ -1436,41 +1506,68 @@ EXAMPLES = """
# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
-# group internal {
-# out-delay 12;
-# }
-# admin# show routing-options autonomous-system
-# 65534 loops 3 asdot-notation;
-- name: Purge Junos BGP global config
+- name: Purge BGP config from running config
junipernetworks.junos.junos_bgp_global:
config:
state: purged
-# After state
-# ----------
-# admin# show protocols bgp
-#
-# [edit]
-# admin# show routing-options autonomous-system
-#
-#[edit]
+# Task Output:
+# ------------
+
+# before:
+# accept_remote_nexthop: true
+# add_path_display_ipv4_address: true
+# advertise_from_main_vpn_tables: true
+# advertise_inactive: true
+# as_number: '65534'
+# asdot_notation: true
+# authentication_algorithm: md5
+# bgp_error_tolerance:
+# malformed_route_limit: 20000000
+# bmp:
+# monitor: true
+# damping: true
+# description: This is configured with Junos_bgp resource module
+# egress_te_sid_stats: true
+# hold_time: 5
+# holddown_all_stale_labels: true
+# include_mp_next_hop: true
+# log_updown: true
+# loops: 3
+# no_advertise_peer_as: true
+# no_aggregator_id: true
+# no_client_reflect: true
+# out_delay: 10
+# precision_timers: true
+# preference: '2'
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp delete="delete"/></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:autonomous-system delete="delete"/></nc:routing-options>
+
+# after: {}
+
+# After state:
+# ------------
+# vsrx# show protocols bgp
+
+# vsrx# show routing-options autonomous-system
# Using rendered
-#
-#
-- name: Render the commands for provided configuration
+
+- name: Render the commands for provided configuration
junipernetworks.junos.junos_bgp_global:
config:
+ as_number: "65534"
+ loops: 3
+ asdot_notation: true
+ accept_remote_nexthop: true
+ add_path_display_ipv4_address: true
+ advertise_from_main_vpn_tables: true
+ advertise_inactive: true
authentication_algorithm: "md5"
- bfd_liveness_detection:
- minimum_receive_interval: 4
- multiplier: 10
- no_adaptation: true
- transmit_interval:
- minimum_interval: 2
- version: "automatic"
bgp_error_tolerance:
malformed_route_limit: 20000000
bmp:
@@ -1479,41 +1576,25 @@ EXAMPLES = """
description: "This is configured with Junos_bgp resource module"
egress_te_sid_stats: true
hold_time: 5
+ holddown_all_stale_labels: true
+ include_mp_next_hop: true
+ log_updown: true
+ no_advertise_peer_as: true
+ no_aggregator_id: true
+ no_client_reflect: true
+ out_delay: 10
+ precision_timers: true
+ preference: 2
state: rendered
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "rendered": "
-# <nc:protocols
-# xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# <nc:bgp>
-# <nc:damping/>
-# <nc:egress-te-sid-stats/>
-# <nc:authentication-algorithm>md5</nc:authentication-algorithm>
-# <nc:description>This is configured with Junos_bgp resource module</nc:description>
-# <nc:hold-time>5</nc:hold-time>
-# <nc:bfd-liveness-detection>
-# <nc:transmit-interval>
-# <nc:minimum-interval>2</nc:minimum-interval>
-# </nc:transmit-interval>
-# <nc:minimum-receive-interval>4</nc:minimum-receive-interval>
-# <nc:multiplier>10</nc:multiplier>
-# <nc:no-adaptation/>
-# <nc:version>automatic</nc:version>
-# </nc:bfd-liveness-detection>
-# <nc:bgp-error-tolerance>
-# <nc:malformed-route-limit>20000000</nc:malformed-route-limit>
-# </nc:bgp-error-tolerance>
-# <nc:bmp>
-# <nc:monitor>enable</nc:monitor>
-# </nc:bmp>
-# </nc:bgp>
-# </nc:protocols>"
+# Task Output:
+# ------------
+
+# rendered:
+# <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:bgp><nc:accept-remote-nexthop/><nc:add-path-display-ipv4-address/>
+# <nc:advertise-from-main-vpn-tables/><nc:ad>
+
#
# Using parsed
# parsed.cfg
@@ -1619,64 +1700,66 @@ EXAMPLES = """
# </rpc-reply>
-- name: Parsed the device configuration to get output commands
+- name: Parsed the device configuration to get ansible facts
junipernetworks.junos.junos_bgp_global:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "parsed": {
-# "accept_remote_nexthop": true,
-# "add_path_display_ipv4_address": true,
-# "advertise_bgp_static": {
-# "policy": "static-to-bgp"
-# },
-# "advertise_from_main_vpn_tables": true,
-# "advertise_inactive": true,
-# "as_number": "65432",
-# "authentication_algorithm": "md5",
-# "bfd_liveness_detection": {
-# "detection_time": {
-# "threshold": 300000
-# },
-# "minimum_receive_interval": 4,
-# "multiplier": 10,
-# "no_adaptation": true,
-# "transmit_interval": {
-# "minimum_interval": 2
-# },
-# "version": "automatic"
-# },
-# "bgp_error_tolerance": {
-# "malformed_route_limit": 20000000
-# },
-# "bmp": {
-# "monitor": false,
-# "route_monitoring": {
-# "none": true
-# }
-# },
-# "damping": true,
-# "description": "This is configured with Junos_bgp resource module",
-# "egress_te_sid_stats": true,
-# "hold_time": 5,
-# "holddown_all_stale_labels": true,
-# "include_mp_next_hop": true,
-# "log_updown": true,
-# "no_advertise_peer_as": true,
-# "no_aggregator_id": true,
-# "no_client_reflect": true,
-# "out_delay": 10,
-# "precision_timers": true,
-# "preference": "2"
-# }
-#
+# Task Output:
+# ------------
+
+# parsed:
+# accept_remote_nexthop: true
+# add_path_display_ipv4_address: true
+# advertise_bgp_static:
+# policy: static-to-bgp
+# advertise_from_main_vpn_tables: true
+# advertise_inactive: true
+# as_number: '65432'
+# authentication_algorithm: md5
+# bfd_liveness_detection:
+# detection_time:
+# threshold: 300000
+# minimum_receive_interval: 4
+# multiplier: 10
+# no_adaptation: true
+# transmit_interval:
+# minimum_interval: 2
+# version: automatic
+# bgp_error_tolerance:
+# malformed_route_limit: 20000000
+# bmp:
+# monitor: false
+# route_monitoring:
+# none: true
+# damping: true
+# description: This is configured with Junos_bgp resource module
+# egress_te_sid_stats: true
+# groups:
+# - name: internal
+# out_delay: 8
+# - name: external
+# out_delay: 9
+# - name: inboun
+# type: internal
+# - export: static-to-bgp
+# local_address: 10.2.2.2
+# name: ibgp
+# neighbors:
+# - neighbor_address: 10.1.1.1
+# type: internal
+# hold_time: 5
+# holddown_all_stale_labels: true
+# include_mp_next_hop: true
+# log_updown: true
+# no_advertise_peer_as: true
+# no_aggregator_id: true
+# no_client_reflect: true
+# out_delay: 10
+# precision_timers: true
+# preference: '2'
+# remove_private:
+# set: true
"""
RETURN = """
before:
@@ -1723,6 +1806,26 @@ commands:
</nc:bmp>
</nc:bgp>
</nc:protocols>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
@@ -1745,6 +1848,7 @@ def main():
required_if = [
("state", "merged", ("config",)),
("state", "replaced", ("config",)),
+ ("state", "overridden", ("config",)),
("state", "rendered", ("config",)),
("state", "parsed", ("running_config",)),
]
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_command.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_command.py
index ec713f230..602a24138 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_command.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_command.py
@@ -114,17 +114,17 @@ EXAMPLES = """
- name: run multiple commands on remote nodes
junipernetworks.junos.junos_command:
commands:
- - show version
- - show interfaces
+ - show version
+ - show interfaces
- name: run multiple commands and evaluate the output
junipernetworks.junos.junos_command:
commands:
- - show version
- - show interfaces
+ - show version
+ - show interfaces
wait_for:
- - result[0] contains Juniper
- - result[1] contains Loopback0
+ - result[0] contains Juniper
+ - result[1] contains Loopback0
- name: run commands and specify the output format
junipernetworks.junos.junos_command:
@@ -204,7 +204,6 @@ USE_PERSISTENT_CONNECTION = True
def rpc(module, items):
-
responses = list()
for item in items:
name = item["name"]
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
index c8bfde10c..5b5151d39 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
@@ -62,7 +62,7 @@ options:
back to initial defaults. This argument will effectively remove all current
configuration statements on the remote device.
type: bool
- default: no
+ default: false
confirm:
description:
- The C(confirm) argument will configure a time out value in minutes for the commit
@@ -95,7 +95,7 @@ options:
playbook root directory or role root directory, if playbook is part of an ansible
role. If the directory does not exist, it is created.
type: bool
- default: no
+ default: false
update:
description:
- This argument will decide how to load the configuration data particularly when
@@ -124,19 +124,19 @@ options:
- This argument will execute commit operation on remote device. It can be used
to confirm a previous commit.
type: bool
- default: no
+ default: false
check_commit:
description:
- This argument will check correctness of syntax; do not apply changes.
- Note that this argument can be used to confirm verified configuration done via
commit confirmed operation
type: bool
- default: no
+ default: false
backup_options:
description:
- This is a dict object containing configurable options related to backup file
- path. The value of this option is read only when C(backup) is set to I(yes),
- if C(backup) is set to I(no) this option will be silently ignored.
+ path. The value of this option is read only when C(backup) is set to I(true),
+ if C(backup) is set to I(false) this option will be silently ignored.
suboptions:
filename:
description:
@@ -172,8 +172,7 @@ requirements:
notes:
- This module requires the netconf system service be enabled on the remote device
being managed.
-- Abbreviated commands are NOT idempotent, see L(Network FAQ,../network/user_guide/faq.html
- #why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
+- Abbreviated commands are NOT idempotent, see L(Network FAQ,../network/user_guide/faq.html)
- Loading JSON-formatted configuration I(json) is supported starting in Junos OS Release
16.1 onwards.
- Update C(override) not currently compatible with C(set) notation.
@@ -191,20 +190,20 @@ EXAMPLES = """
- name: load configure lines into device
junipernetworks.junos.junos_config:
lines:
- - set interfaces ge-0/0/1 unit 0 description "Test interface"
- - set vlans vlan01 description "Test vlan"
+ - set interfaces ge-0/0/1 unit 0 description "Test interface"
+ - set vlans vlan01 description "Test vlan"
comment: update config
- name: Set routed VLAN interface (RVI) IPv4 address
junipernetworks.junos.junos_config:
lines:
- - set vlans vlan01 vlan-id 1
- - set interfaces irb unit 10 family inet address 10.0.0.1/24
- - set vlans vlan01 l3-interface irb.10
+ - set vlans vlan01 vlan-id 1
+ - set interfaces irb unit 10 family inet address 10.0.0.1/24
+ - set vlans vlan01 l3-interface irb.10
- name: Check correctness of commit configuration
junipernetworks.junos.junos_config:
- check_commit: yes
+ check_commit: true
- name: rollback the configuration to id 10
junipernetworks.junos.junos_config:
@@ -212,31 +211,30 @@ EXAMPLES = """
- name: zero out the current configuration
junipernetworks.junos.junos_config:
- zeroize: yes
+ zeroize: true
- name: Set VLAN access and trunking
junipernetworks.junos.junos_config:
lines:
- - set vlans vlan02 vlan-id 6
- - set interfaces ge-0/0/6.0 family ethernet-switching interface-mode access vlan
- members vlan02
- - set interfaces ge-0/0/6.0 family ethernet-switching interface-mode trunk vlan
- members vlan02
+ - set vlans vlan02 vlan-id 6
+ - set interfaces ge-0/0/6.0 family ethernet-switching interface-mode access vlan
+ members vlan02
+ - set interfaces ge-0/0/6.0 family ethernet-switching interface-mode trunk vlan
+ members vlan02
- name: confirm a previous commit
junipernetworks.junos.junos_config:
- confirm_commit: yes
+ confirm_commit: true
- name: for idempotency, use full-form commands
junipernetworks.junos.junos_config:
lines:
- # - set int ge-0/0/1 unit 0 desc "Test interface"
- - set interfaces ge-0/0/1 unit 0 description "Test interface"
+ - set interfaces ge-0/0/1 unit 0 description "Test interface"
- name: configurable backup path
junipernetworks.junos.junos_config:
src: srx.cfg
- backup: yes
+ backup: true
backup_options:
filename: backup.cfg
dir_path: /home/user
@@ -245,27 +243,27 @@ EXAMPLES = """
RETURN = """
backup_path:
description: The full path to the backup file
- returned: when backup is yes
+ returned: when backup is true
type: str
sample: /playbooks/ansible/backup/config.2016-07-16@22:28:34
filename:
description: The name of the backup file
- returned: when backup is yes and filename is not specified in backup options
+ returned: when backup is true and filename is not specified in backup options
type: str
sample: junos01_config.2016-07-16@22:28:34
shortname:
description: The full path to the backup file excluding the timestamp
- returned: when backup is yes and filename is not specified in backup options
+ returned: when backup is true and filename is not specified in backup options
type: str
sample: /playbooks/ansible/backup/junos01_config
date:
description: The date extracted from the backup file name
- returned: when backup is yes
+ returned: when backup is true
type: str
sample: "2016-07-16"
time:
description: The time extracted from the backup file name
- returned: when backup is yes
+ returned: when backup is true
type: str
sample: "22:28:34"
"""
@@ -366,7 +364,6 @@ def filter_delete_statements(module, candidate):
def configure_device(module, warnings, candidate):
-
kwargs = {}
config_format = None
@@ -468,7 +465,7 @@ def main():
result["__backup__"] = reply
rollback_id = module.params["rollback"]
- if rollback_id:
+ if isinstance(rollback_id, int) and rollback_id >= 0:
diff = rollback(module, rollback_id)
if commit:
kwargs = {"comment": module.params["comment"]}
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_hostname.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_hostname.py
index 093645a6f..86eb0f7df 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_hostname.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_hostname.py
@@ -300,7 +300,6 @@ EXAMPLES = """
# "hostname": "vsrx-18.4R1"
# }
#
-
"""
RETURN = """
before:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_interfaces.py
index f3b749d63..04f65df96 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_interfaces.py
@@ -134,57 +134,163 @@ notes:
being managed.
- Tested against vSRX JUNOS version 18.4R1.
- This module works with connection C(netconf).
-- See L(the Junos OS Platform Options,https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html).
+ See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html)
+- The module examples uses callback plugin (stdout_callback = yaml) to generate task
+ output in yaml format.
"""
EXAMPLES = """
-# Using deleted
+# Using merged
# Before state:
# -------------
+#
# user@junos01# show interfaces
# ge-0/0/1 {
-# description "Configured by Ansible-1";
-# speed 1g;
-# mtu 1800
-# unit 0 {
-# description "This is logical intf unit0";
+# description "test interface";
+# speed 1g;
# }
-# ge-0/0/2 {
-# description "Configured by Ansible-2";
-# ether-options {
-# auto-negotiation;
-# }
+# fe-0/0/2 {
+# vlan-tagging;
+# unit 10 {
+# vlan-id 10;
+# }
+# unit 11 {
+# vlan-id 11;
+# }
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
# }
-- name: "Delete given options for the interface (Note: This won't delete the interface itself if any other values are configured for interface)"
+- 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
- speed: 1g
- mtu: 1800
- - name: ge-0/0/2
- description: Configured by Ansible -2
- state: deleted
+ - name: ge-0/0/1
+ description: Configured by Ansible-1
+ enabled: true
+ units:
+ - name: 0
+ description: "This is logical intf unit0"
+ mtu: 1800
+ - name: ge-0/0/2
+ description: Configured by Ansible-2
+ enabled: false
+ state: merged
+
+# Task Output
+# -----------
+#
+# before:
+# - description: test interface
+# enabled: true
+# name: ge-0/0/1
+# speed: 1g
+# - enabled: true
+# name: fe-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:interface><nc:name>ge-0/0/1</nc:name>
+# <nc:description>Configured by Ansible-1</nc:description><nc:mtu>1800</nc:mtu><nc:unit><nc:name>0</nc:name>
+# <nc:description>This is logical intf unit0</nc:description></nc:unit></nc:interface><nc:interface><nc:name>ge-0/0/2</nc:name>
+# <nc:description>Configured by Ansible-2</nc:description><nc:disable/></nc:interface></nc:interfaces>
+# after:
+# - description: Configured by Ansible-1
+# enabled: true
+# mtu: 1800
+# name: ge-0/0/1
+# speed: 1g
+# units:
+# - description: This is logical intf unit0
+# name: 0
+# - enabled: true
+# name: fe-0/0/2
+# - description: Configured by Ansible-2
+# enabled: false
+# name: ge-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
# After state:
# ------------
+#
# user@junos01# show interfaces
+# ge-0/0/1 {
+# description "Configured by Ansible-1";
+# speed 1g;
+# mtu 1800;
+# unit 0 {
+# description "This is logical intf unit0";
+# }
+# }
+# fe-0/0/2 {
+# vlan-tagging;
+# unit 10 {
+# vlan-id 10;
+# }
+# unit 11 {
+# vlan-id 11;
+# }
+# }
# ge-0/0/2 {
-# ether-options {
-# auto-negotiation;
-# }
+# description "Configured by Ansible-2";
+# disable;
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
# }
-
-# Using merged
+# Using deleted
# Before state:
# -------------
-# user@junos01# show interfaces
+#
# ge-0/0/1 {
-# description "test interface";
-# speed 1g;
+# description "Configured by Ansible-1";
+# speed 1g;
+# mtu 1800;
+# unit 0 {
+# description "This is logical intf unit0";
+# }
# }
# fe-0/0/2 {
# vlan-tagging;
@@ -195,82 +301,262 @@ EXAMPLES = """
# vlan-id 11;
# }
# }
+# ge-0/0/2 {
+# description "Configured by Ansible-2";
+# disable;
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
+# }
-- name: Merge provided configuration with device configuration (default operation
- is merge)
+- 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
- enabled: true
- units:
- - name: 0
- description: "This is logical intf unit0"
- mtu: 1800
- - name: ge-0/0/2
- description: Configured by Ansible-2
- enabled: false
- state: merged
+ - 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
+
+# Task Output
+# -----------
+#
+# before:
+# - description: Configured by Ansible-1
+# enabled: true
+# mtu: 1800
+# name: ge-0/0/1
+# speed: 1g
+# units:
+# - description: This is logical intf unit0
+# name: 0
+# - enabled: true
+# name: fe-0/0/2
+# - description: Configured by Ansible-2
+# enabled: false
+# name: ge-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:interface>
+# <nc:name>ge-0/0/1</nc:name><nc:description delete="delete"/>
+# <nc:speed delete="delete"/><nc:mtu delete="delete"/><nc:link-mode delete="delete"/>
+# <nc:disable delete="delete"/><nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/></nc:hold-time><nc:unit>
+# <nc:name>0</nc:name><nc:description delete="delete"/></nc:unit></nc:interface><nc:interface><nc:name>ge-0/0/2</nc:name>
+# <nc:description delete="delete"/><nc:speed delete="delete"/><nc:mtu delete="delete"/><nc:link-mode delete="delete"/>
+# <nc:disable delete="delete"/><nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/></nc:hold-time></nc:interface>
+# </nc:interfaces>
+# after:
+# - enabled: true
+# name: ge-0/0/1
+# - enabled: true
+# name: fe-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
# After state:
# ------------
+#
# user@junos01# show interfaces
# ge-0/0/1 {
-# description "Configured by Ansible-1";
-# speed 1g;
-# mtu 1800
-# unit 0 {
-# description "This is logical intf unit0";
-# }
+# unit 0;
# }
-# ge-0/0/2 {
-# disable;
-# description "Configured by Ansible-2";
+# fe-0/0/2 {
+# vlan-tagging;
+# unit 10 {
+# vlan-id 10;
+# }
+# unit 11 {
+# vlan-id 11;
+# }
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
# }
-
# Using overridden
# Before state:
# -------------
+#
# user@junos01# show interfaces
# ge-0/0/1 {
-# description "Configured by Ansible-1";
-# speed 1g;
-# mtu 1800
+# unit 0;
# }
-# ge-0/0/2 {
-# disable;
-# description "Configured by Ansible-2";
-# ether-options {
-# auto-negotiation;
-# }
+# fe-0/0/2 {
+# vlan-tagging;
+# unit 10 {
+# vlan-id 10;
+# }
+# unit 11 {
+# vlan-id 11;
+# }
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
# }
-# ge-0/0/11 {
-# description "Configured by Ansible-11";
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
# }
- 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
+ - enabled: true
+ name: ge-0/0/1
+ - name: fe-0/0/2
+ description: Configured by Ansible-2
+ enabled: false
+ mtu: 2800
+ - description: Updated by Ansible-3
+ enabled: true
+ name: ge-0/0/3
+ - enabled: true
+ name: fxp0
+ - enabled: true
+ name: lo0
state: overridden
+# Task Output
+# -----------
+#
+# before:
+# - enabled: true
+# name: ge-0/0/1
+# - enabled: true
+# name: fe-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface><nc:name>ge-0/0/1</nc:name><nc:description delete="delete"/>
+# <nc:speed delete="delete"/><nc:mtu delete="delete"/><nc:link-mode delete="delete"/>
+# <nc:disable delete="delete"/><nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/>
+# </nc:hold-time></nc:interface><nc:interface><nc:name>fe-0/0/2</nc:name><nc:description delete="delete"/>
+# <nc:speed delete="delete"/><nc:mtu delete="delete"/><nc:link-mode delete="delete"/><nc:disable delete="delete"/>
+# <nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/></nc:hold-time></nc:interface><nc:interface>
+# <nc:name>ge-0/0/3</nc:name><nc:description delete="delete"/><nc:speed delete="delete"/><nc:mtu delete="delete"/>
+# <nc:link-mode delete="delete"/><nc:disable delete="delete"/><nc:hold-time>
+# <nc:up delete="delete"/><nc:down delete="delete"/></nc:hold-time></nc:interface>
+# <nc:interface><nc:name>fxp0</nc:name><nc:description delete="delete"/><nc:speed delete="delete"/>
+# <nc:link-mode delete="delete"/><nc:disable delete="delete"/>
+# <nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/>
+# </nc:hold-time></nc:interface><nc:interface><nc:name>lo0</nc:name>
+# <nc:description delete="delete"/><nc:disable delete="delete"/>
+# <nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/>
+# </nc:hold-time></nc:interface><nc:interface><nc:name>ge-0/0/1</nc:name>
+# </nc:interface><nc:interface><nc:name>fe-0/0/2</nc:name>
+# <nc:description>Configured by Ansible-2</nc:description>
+# <nc:mtu>2800</nc:mtu><nc:disable/></nc:interface><nc:interface>
+# <nc:name>ge-0/0/3</nc:name><nc:description>Updated by Ansible-3</nc:description>
+# </nc:interface><nc:interface><nc:name>fxp0</nc:name></nc:interface><nc:interface>
+# <nc:name>lo0</nc:name></nc:interface></nc:interfaces>
+# after:
+# - enabled: true
+# name: ge-0/0/1
+# - description: Configured by Ansible-2
+# enabled: false
+# mtu: 2800
+# name: fe-0/0/2
+# - description: Updated by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+
# After state:
# ------------
+#
# user@junos01# show interfaces
-# ge-0/0/2 {
-# disable;
-# description "Configured by Ansible-2";
-# mtu 2800
+# ge-0/0/1 {
+# unit 0;
+# }
+# fe-0/0/2 {
+# description "Configured by Ansible-2";
+# disable;
+# vlan-tagging;
+# mtu 2800;
+# unit 10 {
+# vlan-id 10;
+# }
+# unit 11 {
+# vlan-id 11;
+# }
# }
# ge-0/0/3 {
-# description "Configured by Ansible-3";
+# description "Updated by Ansible-3";
+# }
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
# }
@@ -278,143 +564,212 @@ EXAMPLES = """
# Before state:
# -------------
+#
# user@junos01# show interfaces
# ge-0/0/1 {
-# description "Configured by Ansible-1";
-# speed 1g;
-# mtu 1800
+# unit 0;
# }
-# ge-0/0/2 {
-# disable;
-# mtu 1800;
-# speed 1g;
-# description "Configured by Ansible-2";
-# ether-options {
-# auto-negotiation;
-# }
+# fe-0/0/2 {
+# description "Configured by Ansible-2";
+# disable;
+# vlan-tagging;
+# mtu 2800;
+# unit 10 {
+# vlan-id 10;
+# }
+# unit 11 {
+# vlan-id 11;
+# }
+# }
+# ge-0/0/3 {
+# description "Updated by Ansible-3";
# }
-# ge-0/0/11 {
-# description "Configured by Ansible-11";
+# fxp0 {
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
# }
-- name: Replaces device configuration of listed interfaces with provided configuration
+- name: Replace 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
+ - 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
+# Task Output
+# -----------
+#
+# before:
+# - enabled: true
+# name: ge-0/0/1
+# - description: Configured by Ansible-2
+# enabled: false
+# mtu: 2800
+# name: fe-0/0/2
+# - description: Updated by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+# commands:
+# - <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 delete="delete"/><nc:speed delete="delete"/>
+# <nc:mtu delete="delete"/><nc:link-mode delete="delete"/><nc:disable delete="delete"/>
+# <nc:hold-time><nc:up delete="delete"/><nc:down delete="delete"/></nc:hold-time></nc:interface>
+# <nc:interface><nc:name>ge-0/0/3</nc:name><nc:description delete="delete"/><nc:speed delete="delete"/>
+# <nc:mtu delete="delete"/><nc:link-mode delete="delete"/><nc:disable delete="delete"/><nc:hold-time>
+# <nc:up delete="delete"/><nc:down delete="delete"/></nc:hold-time></nc:interface><nc:interface><nc:name>ge-0/0/2</nc:name>
+# <nc:description>Configured by Ansible-2</nc:description><nc:mtu>2800</nc:mtu><nc:disable/></nc:interface><nc:interface>
+# <nc:name>ge-0/0/3</nc:name><nc:description>Configured by Ansible-3</nc:description></nc:interface></nc:interfaces>
+# after:
+# - enabled: true
+# name: ge-0/0/1
+# - description: Configured by Ansible-2
+# enabled: false
+# mtu: 2800
+# name: fe-0/0/2
+# - description: Configured by Ansible-2
+# enabled: false
+# mtu: 2800
+# name: ge-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+
# 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";
+# unit 0;
# }
-# Using gathered
-# Before state:
-# ------------
-#
-# vagrant@vsrx# show interfaces
# fe-0/0/2 {
-# description "This is interface DESCRIPTION";
+# description "Configured by Ansible-2";
+# disable;
# vlan-tagging;
+# mtu 2800;
# unit 10 {
-# description "UNIT 10 DESCRIPTION";
# vlan-id 10;
# }
# unit 11 {
-# description "UNIT 11 DESCRIPTION";
# vlan-id 11;
# }
# }
+# ge-0/0/2 {
+# description "Configured by Ansible-2";
+# disable;
+# mtu 2800;
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
# fxp0 {
-# description OUTER;
# unit 0 {
-# description "Sample config";
# family inet {
# dhcp;
# }
# }
# }
-#
-- name: Gather junos interfaces as in given arguments
- junipernetworks.junos.junos_interfaces:
- state: gathered
-# Task Output (redacted)
-# -----------------------
-#
-# "gathered": [
-# {
-# "description": "This is interface DESCRIPTION",
-# "enabled": true,
-# "name": "fe-0/0/2",
-# "units": [
-# {
-# "description": "UNIT 10 DESCRIPTION",
-# "name": 10
-# },
-# {
-# "description": "UNIT 11 DESCRIPTION",
-# "name": 11
-# }
-# ]
-# },
-# {
-# "description": "OUTER",
-# "enabled": true,
-# "name": "fxp0",
-# "units": [
-# {
-# "description": "Sample config",
-# "name": 0
-# }
-# ]
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
# }
-# ]
-# After state:
+# }
+# }
+
+# Using gathered
+
+# Before state:
# ------------
#
# vagrant@vsrx# show interfaces
+# ge-0/0/1 {
+# unit 0;
+# }
# fe-0/0/2 {
-# description "This is interface DESCRIPTION";
+# description "Configured by Ansible-2";
+# disable;
# vlan-tagging;
+# mtu 2800;
# unit 10 {
-# description "UNIT 10 DESCRIPTION";
# vlan-id 10;
# }
# unit 11 {
-# description "UNIT 11 DESCRIPTION";
# vlan-id 11;
# }
# }
+# ge-0/0/2 {
+# description "Configured by Ansible-2";
+# disable;
+# mtu 2800;
+# }
+# ge-0/0/3 {
+# description "Configured by Ansible-3";
+# }
# fxp0 {
-# description OUTER;
# unit 0 {
-# description "Sample config";
# family inet {
# dhcp;
# }
# }
# }
+# lo0 {
+# unit 0 {
+# family inet {
+# address 192.0.2.1/32;
+# }
+# }
+# }
+
+- name: Gather junos interfaces as in given arguments
+ junipernetworks.junos.junos_interfaces:
+ state: gathered
+
+# Task Output
+# -----------
#
+# gathered:
+# - enabled: true
+# name: ge-0/0/1
+# - description: Configured by Ansible-2
+# enabled: false
+# mtu: 2800
+# name: fe-0/0/2
+# - description: Configured by Ansible-2
+# enabled: false
+# mtu: 2800
+# name: ge-0/0/2
+# - description: Configured by Ansible-3
+# enabled: true
+# name: ge-0/0/3
+# - enabled: true
+# name: fxp0
+# - enabled: true
+# name: lo0
+
# Using parsed
+
# parsed.cfg
# ------------
#
@@ -448,46 +803,48 @@ EXAMPLES = """
# </interfaces>
# </configuration>
# </rpc-reply>
-# - name: Convert interfaces config to argspec without connecting to the appliance
+
+# - name: Convert interfaces config to structured data 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"
-# }
-# ]
+
+# Task Output
+# -----------
#
+# 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
+ - name: ge-0/0/2
+ description: Configured by Ansible
+ mtu: 2048
+ speed: 20m
+ hold_time:
+ up: 3200
+ down: 3200
state: rendered
-# Task Output (redacted)
-# -----------------------
-# "rendered": <nc:interfaces
+
+# Task Output
+# -----------
+#
+# 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:description>Configured by Ansible</nc:description>
# <nc:speed>20m</nc:speed>
# <nc:mtu>2048</nc:mtu>
# <nc:hold-time>
@@ -496,7 +853,6 @@ EXAMPLES = """
# </nc:hold-time>
# </nc:interface>
# </nc:interfaces>"
-
"""
RETURN = """
before:
@@ -547,6 +903,29 @@ xml:
</interfaces>
</configuration>
</rpc-reply>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the
+ task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered
+ from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed
+ into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
from ansible.module_utils.basic import AnsibleModule
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_l2_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_l2_interfaces.py
index d5def410b..bbd5f25b5 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_l2_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_l2_interfaces.py
@@ -113,122 +113,169 @@ notes:
- 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 C(netconf). See L(the Junos OS Platform Options,../network/user_guide/platform_junos.html).
+- This module works with connection C(netconf).
+ See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html)
+- The module examples uses callback plugin (stdout_callback = yaml) to generate task
+ output in yaml format.
"""
+
EXAMPLES = """
-# Using deleted
+# Using merged
# Before state:
# -------------
#
# ansible@junos01# show interfaces
# ge-0/0/1 {
-# description "L2 interface";
-# speed 1g;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode access;
-# vlan {
-# members vlan30;
-# }
-# }
-# }
-#}
-#ge-0/0/2 {
-# description "non L2 interface";
-# unit 0 {
-# family inet {
-# address 192.168.56.14/24;
-# }
-# }
-
-- name: "Delete L2 attributes of given interfaces (Note: This won't delete the
- interface itself)."
- junipernetworks.junos.junos_l2_interfaces:
- config:
- - name: ge-0/0/1
- - name: ge-0/0/2
- state: deleted
-
-# After state:
-# ------------
-#
-# ansible@junos01# show interfaces
-# ge-0/0/1 {
-# description "L2 interface";
-# speed 1g;
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
# }
-#ge-0/0/2 {
-# description "non L2 interface";
-# unit 0 {
-# family inet {
-# address 192.168.56.14/24;
-# }
-# }
-
-
-# Using merged
-
-# Before state:
-# -------------
-# ansible@junos01# show interfaces
# ge-0/0/3 {
-# description "test interface";
-# speed 1g;
-#}
+# unit 0 {
+# family ethernet-switching {
+# interface-mode access;
+# }
+# }
+# }
# ge-0/0/4 {
-# description interface-trunk;
-# native-vlan-id 100;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan40 ];
-# }
-# }
-# }
-# }
-
-- name: Merge provided configuration with device configuration (default operation
- is merge)
+# unit 0 {
+# family ethernet-switching {
+# interface-mode access;
+# }
+# }
+# }
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
+# }
+
+- name: Merge provided configuration with device configuration
junipernetworks.junos.junos_l2_interfaces:
config:
- - name: ge-0/0/3
- access:
- vlan: v101
- - name: ge-0/0/4
- trunk:
- allowed_vlans:
- - vlan30
- native_vlan: 50
+ - name: ge-0/0/3
+ access:
+ vlan: v101
+ - name: ge-0/0/4
+ trunk:
+ allowed_vlans:
+ - vlan30
+ native_vlan: 50
state: merged
+# Task Output
+# -----------
+#
+# before:
+# - enhanced_layer: true
+# name: ge-0/0/3
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/4
+# unit: 0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/3</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode>access</nc:interface-mode>
+# <nc:vlan>
+# <nc:members>v101</nc:members>
+# </nc:vlan>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/4</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode>trunk</nc:interface-mode>
+# <nc:vlan>
+# <nc:members>vlan30</nc:members>
+# </nc:vlan>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id>50</nc:native-vlan-id>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - access:
+# vlan: v101
+# enhanced_layer: true
+# name: ge-0/0/3
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - vlan30
+# native_vlan: '50'
+# unit: 0
+
# After state:
# ------------
+#
# user@junos01# show interfaces
+# ge-0/0/1 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
# ge-0/0/3 {
-# description "test interface";
-# speed 1g;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode access;
-# vlan {
-# members v101;
-# }
-# }
-# }
+# unit 0 {
+# family ethernet-switching {
+# interface-mode access;
+# vlan {
+# members v101;
+# }
+# }
+# }
# }
# ge-0/0/4 {
-# description interface-trunk;
-# native-vlan-id 50;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan40 vlan30 ];
-# }
-# }
-# }
+# native-vlan-id 50;
+# unit 0 {
+# family ethernet-switching {
+# interface-mode trunk;
+# vlan {
+# members vlan30;
+# }
+# }
+# }
+# }
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
# }
@@ -237,94 +284,211 @@ EXAMPLES = """
# Before state:
# -------------
# ansible@junos01# show interfaces
+# ge-0/0/1 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
# ge-0/0/3 {
-# description "test interface";
-# speed 1g;
-#}
+# unit 0 {
+# family ethernet-switching {
+# interface-mode access;
+# vlan {
+# members v101;
+# }
+# }
+# }
+# }
# ge-0/0/4 {
-# description interface-trunk;
-# native-vlan-id 100;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan40 ];
-# }
-# }
-# }
-# }
-# ge-0/0/5 {
-# description "Configured by Ansible-11";
-# unit 0 {
-# family ethernet-switching {
-# interface-mode access;
-# vlan {
-# members v101;
-# }
-# }
-# }
+# native-vlan-id 50;
+# unit 0 {
+# family ethernet-switching {
+# interface-mode trunk;
+# vlan {
+# members vlan30;
+# }
+# }
+# }
+# }
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
# }
- name: Override provided configuration with device configuration
junipernetworks.junos.junos_l2_interfaces:
config:
- - name: ge-0/0/3
- access:
- vlan: v101
- name: ge-0/0/4
trunk:
allowed_vlans:
- - vlan30
- native_vlan: 50
+ - v101
+ native_vlan: 30
state: overridden
+# Task Output
+# -----------
+#
+# before:
+# - access:
+# vlan: v101
+# enhanced_layer: true
+# name: ge-0/0/3
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - vlan30
+# native_vlan: '50'
+# unit: 0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/4</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode delete="delete"/>
+# <nc:vlan delete="delete"/>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id delete="delete"/>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/4</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode>trunk</nc:interface-mode>
+# <nc:vlan>
+# <nc:members>v101</nc:members>
+# </nc:vlan>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id>30</nc:native-vlan-id>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/3</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode delete="delete"/>
+# <nc:vlan delete="delete"/>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id delete="delete"/>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - v101
+# native_vlan: '30'
+# unit: 0
+
# After state:
# ------------
# user@junos01# show interfaces
+# ge-0/0/1 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
# ge-0/0/3 {
-# unit 0 {
-# family ethernet-switching {
-# interface-mode access;
-# vlan {
-# members v101;
-# }
-# }
-# }
+# unit 0 {
+# family ethernet-switching;
+# }
# }
# ge-0/0/4 {
-# description interface-trunk;
-# native-vlan-id 50;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan30 ];
-# }
-# }
-# }
+# native-vlan-id 30;
+# unit 0 {
+# family ethernet-switching {
+# interface-mode trunk;
+# vlan {
+# members v101;
+# }
+# }
+# }
+# }
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
# }
-
# Using replaced
# Before state:
# -------------
+#
# ansible@junos01# show interfaces
+# ge-0/0/1 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
# ge-0/0/3 {
-# description "test interface";
-# speed 1g;
-#}
+# unit 0 {
+# family ethernet-switching;
+# }
+# }
# ge-0/0/4 {
-# description interface-trunk;
-# native-vlan-id 100;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan40 ];
-# }
-# }
-# }
+# native-vlan-id 30;
+# unit 0 {
+# family ethernet-switching {
+# interface-mode trunk;
+# vlan {
+# members v101;
+# }
+# }
+# }
+# }
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
# }
- name: Replace provided configuration with device configuration
@@ -340,111 +504,268 @@ EXAMPLES = """
native_vlan: 50
state: replaced
+# Task Output
+# -----------
+#
+# before:
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - v101
+# native_vlan: '30'
+# unit: 0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/4</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode delete="delete"/>
+# <nc:vlan delete="delete"/>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id delete="delete"/>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/3</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode>access</nc:interface-mode>
+# <nc:vlan>
+# <nc:members>v101</nc:members>
+# </nc:vlan>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/4</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode>trunk</nc:interface-mode>
+# <nc:vlan>
+# <nc:members>vlan30</nc:members>
+# </nc:vlan>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id>50</nc:native-vlan-id>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - access:
+# vlan: v101
+# enhanced_layer: true
+# name: ge-0/0/3
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - vlan30
+# native_vlan: '50'
+# unit: 0
+
# After state:
# ------------
+#
# user@junos01# show interfaces
+# ge-0/0/1 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
# ge-0/0/3 {
-# unit 0 {
-# family ethernet-switching {
-# interface-mode access;
-# vlan {
-# members v101;
-# }
-# }
-# }
+# unit 0 {
+# family ethernet-switching {
+# interface-mode access;
+# vlan {
+# members v101;
+# }
+# }
+# }
# }
# ge-0/0/4 {
-# description interface-trunk;
-# native-vlan-id 50;
-# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan30 ];
-# }
-# }
-# }
+# native-vlan-id 50;
+# unit 0 {
+# family ethernet-switching {
+# interface-mode trunk;
+# vlan {
+# members vlan30;
+# }
+# }
+# }
# }
-# Using gathered
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
+# }
+
+# Using deleted
+
# Before state:
-# ------------
+# -------------
#
-# user@junos01# show interfaces
+# ansible@junos01# show interfaces
# ge-0/0/1 {
-# description "Configured by Ansible";
-# disable;
-# speed 100m;
-# mtu 1024;
-# hold-time up 2000 down 2200;
-# link-mode full-duplex;
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/3 {
# unit 0 {
# family ethernet-switching {
# interface-mode access;
# vlan {
-# members vlan100;
+# members v101;
# }
# }
# }
# }
-# ge-0/0/2 {
-# description "Configured by Ansible";
-# native-vlan-id 400;
-# speed 10m;
-# mtu 2048;
-# hold-time up 3000 down 3200;
+# ge-0/0/4 {
+# native-vlan-id 50;
# unit 0 {
# family ethernet-switching {
# interface-mode trunk;
# vlan {
-# members [ vlan200 vlan300 ];
+# members vlan30;
# }
# }
# }
# }
-# em1 {
-# description TEST;
-# }
# fxp0 {
-# description ANSIBLE;
-# speed 1g;
-# link-mode automatic;
+# enable;
# unit 0 {
# family inet {
-# address 10.8.38.38/24;
+# dhcp;
# }
+# family inet6;
# }
# }
-- name: Gather junos layer 2 interfaces as in given arguments
+
+- name: "Delete L2 attributes of given interfaces (Note: This won't delete the
+ interface itself)."
junipernetworks.junos.junos_l2_interfaces:
- state: gathered
-# Task Output (redacted)
-# -----------------------
+ config:
+ - name: ge-0/0/1
+ - name: ge-0/0/2
+ state: deleted
+
+# Task Output
+# -----------
#
-# "gathered": [
-# {
-# "access": {
-# "vlan": "vlan100"
-# },
-# "enhanced_layer": true,
-# "name": "ge-0/0/1",
-# "unit": 0
-# },
-# {
-# "enhanced_layer": true,
-# "name": "ge-0/0/2",
-# "trunk": {
-# "allowed_vlans": [
-# "vlan200",
-# "vlan300"
-# ],
-# "native_vlan": "400"
-# },
-# "unit": 0
-# }
-# ]
+# before:
+# - access:
+# vlan: v101
+# enhanced_layer: true
+# name: ge-0/0/3
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - vlan30
+# native_vlan: '50'
+# unit: 0
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/3</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:ethernet-switching>
+# <nc:interface-mode delete="delete"/>
+# <nc:vlan delete="delete"/>
+# </nc:ethernet-switching>
+# </nc:family>
+# </nc:unit>
+# <nc:native-vlan-id delete="delete"/>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - enhanced_layer: true
+# name: ge-0/0/4
+# trunk:
+# allowed_vlans:
+# - vlan30
+# native_vlan: '50'
+# unit: 0
+
# After state:
# ------------
#
+# ansible@junos01# show interfaces
+# ge-0/0/1 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/2 {
+# unit 0 {
+# family inet;
+# family inet6;
+# }
+# }
+# ge-0/0/3 {
+# unit 0 {
+# family ethernet-switching;
+# }
+# }
+# ge-0/0/4 {
+# native-vlan-id 50;
+# unit 0 {
+# family ethernet-switching {
+# interface-mode trunk;
+# vlan {
+# members vlan30;
+# }
+# }
+# }
+# }
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
+# }
+
+# Using gathered
+
+# Before state:
+# -------------
+#
# user@junos01# show interfaces
# ge-0/0/1 {
# description "Configured by Ansible";
@@ -490,7 +811,31 @@ EXAMPLES = """
# }
# }
# }
+
+- name: Gather junos layer 2 interfaces facts
+ junipernetworks.junos.junos_l2_interfaces:
+ state: gathered
+
+# Task Output
+# -----------
+#
+# gathered:
+# - access:
+# vlan: vlan100
+# enhanced_layer: true
+# name: ge-0/0/1
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/2
+# trunk:
+# allowed_vlans:
+# - vlan200
+# - vlan300
+# native_vlan: '400'
+# unit: 0
+
# Using parsed
+
# parsed.cfg
# ------------
#
@@ -524,36 +869,32 @@ EXAMPLES = """
# </interfaces>
# </configuration>
# </rpc-reply>
-# - name: Convert interfaces config to argspec without connecting to the appliance
-# junipernetworks.junos.junos_l2_interfaces:
-# running_config: "{{ lookup('file', './parsed.cfg') }}"
-# state: parsed
-# Task Output (redacted)
-# -----------------------
-# "parsed": [
-# {
-# "access": {
-# "vlan": "vlan100"
-# },
-# "enhanced_layer": true,
-# "name": "ge-0/0/1",
-# "unit": 0
-# },
-# {
-# "enhanced_layer": true,
-# "name": "ge-0/0/2",
-# "trunk": {
-# "allowed_vlans": [
-# "vlan200",
-# "vlan300"
-# ],
-# "native_vlan": "400"
-# },
-# "unit": 0
-# }
-# ]
+
+- name: Convert interfaces config to argspec without connecting to the appliance
+ junipernetworks.junos.junos_l2_interfaces:
+ running_config: "{{ lookup('file', './parsed.cfg') }}"
+ state: parsed
+
+# Task Output
+# -----------
#
+# parsed:
+# - access:
+# vlan: vlan100
+# enhanced_layer: true
+# name: ge-0/0/1
+# unit: 0
+# - enhanced_layer: true
+# name: ge-0/0/2
+# trunk:
+# allowed_vlans:
+# - vlan200
+# - vlan300
+# native_vlan: '400'
+# unit: 0
+
# Using rendered
+
- name: Render platform specific xml from task input using rendered state
junipernetworks.junos.junos_l2_interfaces:
config:
@@ -567,10 +908,11 @@ EXAMPLES = """
- vlan300
native_vlan: '400'
state: rendered
-# Task Output (redacted)
-# -----------------------
-# "rendered": "<nc:interfaces
-# xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
+
+# Task Output
+# -----------
+#
+# "rendered": "<nc:interfaces xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
# <nc:interface>
# <nc:name>ge-0/0/1</nc:name>
# <nc:unit>
@@ -602,8 +944,8 @@ EXAMPLES = """
# <nc:native-vlan-id>400</nc:native-vlan-id>
# </nc:interface>
# </nc:interfaces>"
-
"""
+
RETURN = """
before:
description: The configuration as structured data prior to module invocation.
@@ -624,38 +966,61 @@ commands:
returned: always
type: list
sample: ['<nc:interfaces
- xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
- <nc:interface>
- <nc:name>ge-0/0/1</nc:name>
- <nc:unit>
- <nc:name>0</nc:name>
- <nc:family>
- <nc:ethernet-switching>
- <nc:interface-mode>access</nc:interface-mode>
- <nc:vlan>
- <nc:members>vlan100</nc:members>
- </nc:vlan>
- </nc:ethernet-switching>
- </nc:family>
- </nc:unit>
- </nc:interface>
- <nc:interface>
- <nc:name>ge-0/0/2</nc:name>
- <nc:unit>
- <nc:name>0</nc:name>
- <nc:family>
- <nc:ethernet-switching>
- <nc:interface-mode>trunk</nc:interface-mode>
- <nc:vlan>
- <nc:members>vlan200</nc:members>
- <nc:members>vlan300</nc:members>
- </nc:vlan>
- </nc:ethernet-switching>
- </nc:family>
- </nc:unit>
- <nc:native-vlan-id>400</nc:native-vlan-id>
- </nc:interface>
- </nc:interfaces>', 'xml 2', 'xml 3']
+ xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
+ <nc:interface>
+ <nc:name>ge-0/0/1</nc:name>
+ <nc:unit>
+ <nc:name>0</nc:name>
+ <nc:family>
+ <nc:ethernet-switching>
+ <nc:interface-mode>access</nc:interface-mode>
+ <nc:vlan>
+ <nc:members>vlan100</nc:members>
+ </nc:vlan>
+ </nc:ethernet-switching>
+ </nc:family>
+ </nc:unit>
+ </nc:interface>
+ <nc:interface>
+ <nc:name>ge-0/0/2</nc:name>
+ <nc:unit>
+ <nc:name>0</nc:name>
+ <nc:family>
+ <nc:ethernet-switching>
+ <nc:interface-mode>trunk</nc:interface-mode>
+ <nc:vlan>
+ <nc:members>vlan200</nc:members>
+ <nc:members>vlan300</nc:members>
+ </nc:vlan>
+ </nc:ethernet-switching>
+ </nc:family>
+ </nc:unit>
+ <nc:native-vlan-id>400</nc:native-vlan-id>
+ </nc:interface>
+</nc:interfaces>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the
+ task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered
+ from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed
+ into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_l3_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_l3_interfaces.py
index 3e59e0844..3e9fd57b7 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_l3_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_l3_interfaces.py
@@ -43,8 +43,11 @@ requirements:
- ncclient (>=v0.6.4)
notes:
- This module requires the netconf system service be enabled on the device being managed.
-- This module works with connection C(netconf). See L(the Junos OS Platform Options,../network/user_guide/platform_junos.html).
- Tested against JunOS v18.4R1
+- This module works with connection C(netconf).
+ See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html)
+- The module examples uses callback plugin (stdout_callback = yaml) to generate task
+ output in yaml format.
options:
config:
description: A dictionary of Layer 3 interface options
@@ -111,75 +114,22 @@ options:
default: merged
"""
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
- junipernetworks.junos.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";
+# fxp0 {
+# enable;
# unit 0 {
# family inet {
-# address 10.200.16.10/24;
+# dhcp;
# }
# }
# }
-# ge-0/0/2 {
-# description "non configured interface";
-# unit 0;
-# }
-- name: Merge provided configuration with device configuration (default operation is merge)
+
+- name: Merge provided configuration with device configuration
junipernetworks.junos.junos_l3_interfaces:
config:
- name: ge-0/0/1
@@ -192,15 +142,71 @@ EXAMPLES = """
- address: dhcp
state: merged
+# Task Output
+# -----------
+#
+# before:
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/1</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:address>
+# <nc:name>192.168.1.10/24</nc:name>
+# </nc:address>
+# </nc:inet>
+# </nc:family>
+# <nc:family>
+# <nc:inet6>
+# <nc:address>
+# <nc:name>8d8d:8d01::1/64</nc:name>
+# </nc:address>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/2</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:dhcp/>
+# </nc:inet>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - ipv4:
+# - address: 192.168.1.10/24
+# ipv6:
+# - address: 8d8d:8d01::1/64
+# name: ge-0/0/1
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+
# 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 {
@@ -209,14 +215,20 @@ EXAMPLES = """
# }
# }
# ge-0/0/2 {
-# description "L3 interface with dhcp";
# unit 0 {
# family inet {
# dhcp;
# }
# }
# }
-
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# }
+# }
# Using overridden
@@ -225,26 +237,27 @@ EXAMPLES = """
#
# 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;
# }
# }
# }
-# ge-0/0/3 {
-# description "another L3 interface";
+# fxp0 {
+# enable;
# unit 0 {
# family inet {
-# address 192.168.1.10/24;
+# dhcp;
# }
# }
# }
@@ -255,42 +268,139 @@ EXAMPLES = """
- 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
+ - ipv4:
+ - address: dhcp
+ name: fxp0
+ unit: '0'
state: overridden
+# Task Output
+# -----------
+#
+# before:
+# - ipv4:
+# - address: 192.168.1.10/24
+# ipv6:
+# - address: 8d8d:8d01::1/64
+# name: ge-0/0/1
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/1</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:address delete="delete"/>
+# </nc:inet>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/2</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:dhcp delete="delete"/>
+# </nc:inet>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>fxp0</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:dhcp delete="delete"/>
+# </nc:inet>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/1</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:address>
+# <nc:name>192.168.1.10/24</nc:name>
+# </nc:address>
+# </nc:inet>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>fxp0</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:dhcp/>
+# </nc:inet>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - ipv4:
+# - address: 192.168.1.10/24
+# name: ge-0/0/1
+# unit: '0'
+# - name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+
# 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;
-# }
+# family inet6;
# }
# }
# ge-0/0/2 {
-# description "L3 interface with ipv6";
# unit 0 {
-# family inet6 {
-# address 2001:db8:3000::/64;
-# }
+# family inet;
+# family inet6;
# }
# }
-# ge-0/0/3 {
-# description "overridden L3 interface";
-# unit 0;
+# fxp0 {
+# enable;
+# unit 0 {
+# family inet {
+# dhcp;
+# }
+# family inet6;
+# }
# }
-
# Using replaced
# Before state
@@ -298,23 +408,26 @@ EXAMPLES = """
#
# 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;
# }
# }
# ge-0/0/2 {
-# description "non configured interface";
-# unit 0;
+# unit 0 {
+# family inet;
+# family inet6;
+# }
# }
-# ge-0/0/3 {
-# description "another L3 interface";
+# fxp0 {
+# enable;
# unit 0 {
# family inet {
-# address 192.168.1.10/24;
+# dhcp;
# }
+# family inet6;
# }
# }
@@ -331,12 +444,101 @@ EXAMPLES = """
- address: dhcp
state: replaced
+# Task Output
+# -----------
+#
+# before:
+# - ipv4:
+# - address: 192.168.1.10/24
+# name: ge-0/0/1
+# unit: '0'
+# - name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/1</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:address delete="delete"/>
+# </nc:inet>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/2</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet/>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/1</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:address>
+# <nc:name>192.168.1.10/24</nc:name>
+# </nc:address>
+# </nc:inet>
+# </nc:family>
+# <nc:family>
+# <nc:inet6>
+# <nc:address>
+# <nc:name>8d8d:8d01::1/64</nc:name>
+# </nc:address>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/2</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:dhcp/>
+# </nc:inet>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - ipv4:
+# - address: 192.168.1.10/24
+# ipv6:
+# - address: 8d8d:8d01::1/64
+# name: ge-0/0/1
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+
# After state:
# ------------
#
# admin# show interfaces
# ge-0/0/1 {
-# description "L3 interface";
# unit 0 {
# family inet {
# address 192.168.1.10/24;
@@ -347,151 +549,152 @@ EXAMPLES = """
# }
# }
# ge-0/0/2 {
-# description "L3 interface with dhcp";
# unit 0 {
# family inet {
# dhcp;
# }
+# family inet6;
# }
# }
-# ge-0/0/3 {
-# description "another L3 interface";
+# fxp0 {
+# enable;
# unit 0 {
# family inet {
-# address 192.168.1.10/24;
+# dhcp;
# }
+# family inet6;
# }
# }
-# Using gathered
+
+# Using deleted
+
# Before state:
-# ------------
+# -------------
#
-# user@junos01# show interfaces
+# admin# show interfaces
# ge-0/0/1 {
-# description "Configured by Ansible";
-# disable;
-# speed 100m;
-# mtu 1024;
-# hold-time up 2000 down 2200;
-# link-mode full-duplex;
# unit 0 {
-# family ethernet-switching {
-# interface-mode access;
-# vlan {
-# members vlan100;
-# }
+# family inet {
+# address 192.168.1.10/24;
+# }
+# family inet6 {
+# address 8d8d:8d01::1/64;
# }
# }
# }
# ge-0/0/2 {
-# description "Configured by Ansible";
-# native-vlan-id 400;
-# speed 10m;
-# mtu 2048;
-# hold-time up 3000 down 3200;
# unit 0 {
-# family ethernet-switching {
-# interface-mode trunk;
-# vlan {
-# members [ vlan200 vlan300 ];
-# }
+# family inet {
+# dhcp;
# }
+# family inet6;
# }
# }
-# ge-1/0/0 {
+# fxp0 {
+# enable;
# unit 0 {
# family inet {
-# address 192.168.100.1/24;
-# address 10.200.16.20/24;
+# dhcp;
# }
# family inet6;
# }
# }
-# ge-2/0/0 {
+
+- name: Delete L3 logical interface
+ junipernetworks.junos.junos_l3_interfaces:
+ config:
+ - name: ge-0/0/1
+ - name: ge-0/0/2
+ state: deleted
+
+# Task Output
+# -----------
+#
+# before:
+# - ipv4:
+# - address: 192.168.1.10/24
+# ipv6:
+# - address: 8d8d:8d01::1/64
+# name: ge-0/0/1
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+# commands:
+# - <nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:interface>
+# <nc:name>ge-0/0/1</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:address delete="delete"/>
+# </nc:inet>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# <nc:interface>
+# <nc:name>ge-0/0/2</nc:name>
+# <nc:unit>
+# <nc:name>0</nc:name>
+# <nc:family>
+# <nc:inet>
+# <nc:dhcp delete="delete"/>
+# </nc:inet>
+# <nc:inet6>
+# <nc:address delete="delete"/>
+# </nc:inet6>
+# </nc:family>
+# </nc:unit>
+# </nc:interface>
+# </nc:interfaces>
+# after:
+# - name: ge-0/0/1
+# unit: '0'
+# - name: ge-0/0/2
+# unit: '0'
+# - ipv4:
+# - address: dhcp
+# name: fxp0
+# unit: '0'
+
+# After state:
+# ------------
+#
+# admin# show interfaces
+# ge-0/0/1 {
# unit 0 {
-# family inet {
-# address 192.168.100.2/24;
-# address 10.200.16.21/24;
-# }
+# family inet;
# family inet6;
# }
# }
-# ge-3/0/0 {
+# ge-0/0/2 {
# unit 0 {
-# family inet {
-# address 192.168.100.3/24;
-# address 10.200.16.22/24;
-# }
+# family inet;
# family inet6;
# }
# }
-# em1 {
-# description TEST;
-# }
# fxp0 {
-# description ANSIBLE;
-# speed 1g;
-# link-mode automatic;
+# enable;
# unit 0 {
# family inet {
-# address 10.8.38.38/24;
+# dhcp;
# }
+# family inet6;
# }
# }
-- name: Gather junos layer3 interfaces as in given arguments
- junipernetworks.junos.junos_l3_interfaces:
- state: gathered
-# Task Output (redacted)
-# -----------------------
-#
-# "gathered": [
-# {
-# "ipv4": [
-# {
-# "address": "192.168.100.1/24"
-# },
-# {
-# "address": "10.200.16.20/24"
-# }
-# ],
-# "name": "ge-1/0/0",
-# "unit": "0"
-# },
-# {
-# "ipv4": [
-# {
-# "address": "192.168.100.2/24"
-# },
-# {
-# "address": "10.200.16.21/24"
-# }
-# ],
-# "name": "ge-2/0/0",
-# "unit": "0"
-# },
-# {
-# "ipv4": [
-# {
-# "address": "192.168.100.3/24"
-# },
-# {
-# "address": "10.200.16.22/24"
-# }
-# ],
-# "name": "ge-3/0/0",
-# "unit": "0"
-# },
-# {
-# "ipv4": [
-# {
-# "address": "10.8.38.38/24"
-# }
-# ],
-# "name": "fxp0",
-# "unit": "0"
-# }
-# ]
-# After state:
+
+# Using gathered
+
+# Before state:
# ------------
#
# user@junos01# show interfaces
@@ -566,7 +769,37 @@ EXAMPLES = """
# }
# }
# }
+
+- name: Gather layer3 interfaces facts
+ junipernetworks.junos.junos_l3_interfaces:
+ state: gathered
+
+# Task Output
+# -----------
+#
+# gathered:
+# - ipv4:
+# - address: 192.168.100.1/24
+# - address: 10.200.16.20/24
+# name: ge-1/0/0
+# unit: '0'
+# - ipv4:
+# - address: 192.168.100.2/24
+# - address: 10.200.16.21/24
+# name: ge-2/0/0
+# unit: '0'
+# - ipv4:
+# - address: 192.168.100.3/24
+# - address: 10.200.16.22/24
+# name: ge-3/0/0
+# unit: '0'
+# - ipv4:
+# - address: 10.8.38.38/24
+# name: fxp0
+# unit: '0'
+
# Using parsed
+
# parsed.cfg
# ------------
#
@@ -611,40 +844,29 @@ EXAMPLES = """
# </interfaces>
# </configuration>
# </rpc-reply>
+
# - name: Convert interfaces config to argspec without connecting to the appliance
# junipernetworks.junos.junos_l3_interfaces:
# running_config: "{{ lookup('file', './parsed.cfg') }}"
# state: parsed
-# Task Output (redacted)
-# -----------------------
-# "parsed": [
-# {
-# "ipv4": [
-# {
-# "address": "192.168.100.1/24"
-# },
-# {
-# "address": "10.200.16.20/24"
-# }
-# ],
-# "name": "ge-1/0/0",
-# "unit": "0"
-# },
-# {
-# "ipv4": [
-# {
-# "address": "192.168.100.2/24"
-# },
-# {
-# "address": "10.200.16.21/24"
-# }
-# ],
-# "name": "ge-2/0/0",
-# "unit": "0"
-# }
-# ]
+
+# Task Output
+# -----------
#
+# parsed:
+# - ipv4:
+# - address: 192.168.100.1/24
+# - address: 10.200.16.20/24
+# name: ge-1/0/0
+# unit: '0'
+# - ipv4:
+# - address: 192.168.100.2/24
+# - address: 10.200.16.21/24
+# name: ge-2/0/0
+# unit: '0'
+
# Using rendered
+
- name: Render platform specific xml from task input using rendered state
junipernetworks.junos.junos_l3_interfaces:
config:
@@ -653,17 +875,17 @@ EXAMPLES = """
- address: 192.168.100.1/24
- address: 10.200.16.20/24
unit: 0
-
- name: ge-2/0/0
ipv4:
- address: 192.168.100.2/24
- address: 10.200.16.21/24
unit: 0
state: rendered
-# Task Output (redacted)
-# -----------------------
-# "rendered": "<nc:interfaces
-# xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
+
+# Task Output
+# -----------
+#
+# "rendered": "<nc:interfaces xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
# <nc:interface>
# <nc:name>ge-1/0/0</nc:name>
# <nc:unit>
@@ -697,8 +919,8 @@ EXAMPLES = """
# </nc:unit>
# </nc:interface>
# </nc:interfaces>"
-
"""
+
RETURN = """
before:
description: The configuration as structured data prior to module invocation.
@@ -736,6 +958,29 @@ commands:
</nc:family>
</nc:unit>
</nc:interfaces>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the
+ task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered
+ from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed
+ into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp.py
index b2636f285..686404018 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp.py
@@ -231,7 +231,6 @@ EXAMPLES = """
# "link_protection": "revertive",
# "system_priority": 63
# }
-
"""
RETURN = """
before:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp_interfaces.py
index 0c05a0c54..5a2301367 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lacp_interfaces.py
@@ -163,16 +163,16 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
junipernetworks.junos.junos_lacp_interfaces:
config:
- - name: ae0
- period: fast
- sync_reset: enable
- system:
- priority: 100
- mac:
- address: 00:00:00:00:00:02
- - name: ge-0/0/3
- port_priority: 100
- force_up: true
+ - name: ae0
+ period: fast
+ sync_reset: enable
+ system:
+ priority: 100
+ mac:
+ address: 00:00:00:00:00:02
+ - name: ge-0/0/3
+ port_priority: 100
+ force_up: true
state: merged
# After state:
@@ -261,8 +261,8 @@ EXAMPLES = """
- name: Replace device LACP interfaces configuration with provided configuration
junipernetworks.junos.junos_lacp_interfaces:
config:
- - name: ae0
- period: slow
+ - name: ae0
+ period: slow
state: replaced
# After state:
@@ -345,14 +345,14 @@ EXAMPLES = """
- name: Overrides all device LACP interfaces configuration with provided configuration
junipernetworks.junos.junos_lacp_interfaces:
config:
- - name: ae0
- system:
- priority: 300
- mac:
- address: 00:00:00:00:00:03
- - name: ge-0/0/2
- port_priority: 200
- force_up: false
+ - name: ae0
+ system:
+ priority: 300
+ mac:
+ address: 00:00:00:00:00:03
+ - name: ge-0/0/2
+ port_priority: 200
+ force_up: false
state: overridden
# After state:
@@ -447,9 +447,9 @@ EXAMPLES = """
- name: "Delete LACP interfaces attributes of given interfaces (Note: This won't delete the interface itself)"
junipernetworks.junos.junos_lacp_interfaces:
config:
- - name: ae0
- - name: ge-0/0/3
- - name: ge-0/0/2
+ - name: ae0
+ - name: ge-0/0/3
+ - name: ge-0/0/2
state: deleted
# After state:
@@ -841,17 +841,17 @@ EXAMPLES = """
- name: Render platform specific xml from task input using rendered state
junipernetworks.junos.junos_lacp_interfaces:
config:
- - name: ae1
- period: fast
- sync_reset: enable
- system:
- priority: 100
- mac:
- address: 00:00:00:00:00:02
+ - name: ae1
+ period: fast
+ sync_reset: enable
+ system:
+ priority: 100
+ mac:
+ address: 00:00:00:00:00:02
- - name: ge-0/0/1
- port_priority: 100
- force_up: true
+ - name: ge-0/0/1
+ port_priority: 100
+ force_up: true
state: rendered
# Task Output (redacted)
# -----------------------
@@ -880,7 +880,6 @@ EXAMPLES = """
# </nc:ether-options>
# </nc:interface>
# </nc:interfaces>"
-
"""
RETURN = """
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lag_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lag_interfaces.py
index 81efca836..67c4ffb7e 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lag_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lag_interfaces.py
@@ -143,8 +143,8 @@ EXAMPLES = """
- name: "Delete LAG attributes of given interfaces (Note: This won't delete the interface itself)"
junipernetworks.junos.junos_lag_interfaces:
config:
- - name: ae0
- - name: ae1
+ - name: ae0
+ - name: ae1
state: deleted
# After state:
@@ -173,12 +173,12 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
junipernetworks.junos.junos_lag_interfaces:
config:
- - name: ae0
- members:
- - member: ge-0/0/1
- link_type: primary
- - member: ge-0/0/2
- link_type: backup
+ - name: ae0
+ members:
+ - member: ge-0/0/1
+ link_type: primary
+ - member: ge-0/0/2
+ link_type: backup
state: merged
# After state:
@@ -231,13 +231,13 @@ EXAMPLES = """
- name: Overrides all device LAG configuration with provided configuration
junipernetworks.junos.junos_lag_interfaces:
config:
- - name: ae0
- members:
- - member: ge-0/0/2
- - name: ae1
- members:
- - member: ge-0/0/1
- mode: passive
+ - name: ae0
+ members:
+ - member: ge-0/0/2
+ - name: ae1
+ members:
+ - member: ge-0/0/1
+ mode: passive
state: overridden
# After state:
@@ -285,10 +285,10 @@ EXAMPLES = """
- name: Replace device LAG configuration with provided configuration
junipernetworks.junos.junos_lag_interfaces:
config:
- - name: ae0
- members:
- - member: ge-0/0/1
- mode: active
+ - name: ae0
+ members:
+ - member: ge-0/0/1
+ mode: active
state: replaced
# After state:
@@ -701,20 +701,20 @@ EXAMPLES = """
- name: Render platform specific xml from task input using rendered state
junipernetworks.junos.junos_lag_interfaces:
config:
- - name: ae1
- members:
- - member: ge-0/0/1
- - member: ge-0/0/2
- mode: active
-
- - name: ae2
- link_protection: true
- members:
- - member: ge-0/0/3
- link_type: primary
- - member: ge-0/0/4
- link_type: backup
- mode: passive
+ - name: ae1
+ members:
+ - member: ge-0/0/1
+ - member: ge-0/0/2
+ mode: active
+
+ - name: ae2
+ link_protection: true
+ members:
+ - member: ge-0/0/3
+ link_type: primary
+ - member: ge-0/0/4
+ link_type: backup
+ mode: passive
# Task Output (redacted)
# -----------------------
# "rendered": "<nc:interfaces
@@ -771,7 +771,6 @@ EXAMPLES = """
# </nc:ether-options>
# </nc:interface>
# </nc:interfaces>"
-
"""
RETURN = """
before:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lldp_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lldp_interfaces.py
index b3d1b61ed..dd5c7fe4c 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_lldp_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_lldp_interfaces.py
@@ -89,9 +89,9 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
junipernetworks.junos.junos_lldp_interfaces:
config:
- - name: ge-0/0/1
- - name: ge-0/0/2
- enabled: false
+ - name: ge-0/0/1
+ - name: ge-0/0/2
+ enabled: false
state: merged
# After state:
@@ -118,10 +118,10 @@ EXAMPLES = """
- name: Replace provided configuration with device configuration
junipernetworks.junos.junos_lldp_interfaces:
config:
- - name: ge-0/0/2
- disable: false
- - name: ge-0/0/3
- enabled: false
+ - name: ge-0/0/2
+ disable: false
+ - name: ge-0/0/3
+ enabled: false
state: replaced
# After state:
@@ -149,8 +149,8 @@ EXAMPLES = """
- name: Override provided configuration with device configuration
junipernetworks.junos.junos_lldp_interfaces:
config:
- - name: ge-0/0/2
- enabled: false
+ - name: ge-0/0/2
+ enabled: false
state: overridden
# After state:
@@ -176,8 +176,8 @@ EXAMPLES = """
- name: Delete lldp interface configuration (this will not delete other lldp configuration)
junipernetworks.junos.junos_lldp_interfaces:
config:
- - name: ge-0/0/1
- - name: ge-0/0/3
+ - name: ge-0/0/1
+ - name: ge-0/0/3
state: deleted
# After state:
@@ -191,7 +191,7 @@ EXAMPLES = """
# Before state:
# ------------
#
-#ansible@cm123456tr21# show protocols lldp
+# ansible@cm123456tr21# show protocols lldp
# interface ge-0/0/1;
# interface ge-0/0/2 {
# disable;
@@ -214,7 +214,7 @@ EXAMPLES = """
# After state:
# ------------
#
-#ansible@cm123456tr21# show protocols lldp
+# ansible@cm123456tr21# show protocols lldp
# interface ge-0/0/1;
# interface ge-0/0/2 {
# disable;
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_logging.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_logging.py
index c2713a855..8f736d054 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_logging.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_logging.py
@@ -175,19 +175,19 @@ EXAMPLES = """
junipernetworks.junos.junos_logging:
dest: file
aggregate:
- - name: test-1
- facility: pfe
- level: critical
- - name: test-2
- facility: kernel
- level: emergency
+ - name: test-1
+ facility: pfe
+ level: critical
+ - name: test-2
+ facility: kernel
+ level: emergency
active: true
- name: Delete file logging using aggregate
junipernetworks.junos.junos_logging:
aggregate:
- - {dest: file, name: test-1, facility: pfe, level: critical}
- - {dest: file, name: test-2, facility: kernel, level: emergency}
+ - {dest: file, name: test-1, facility: pfe, level: critical}
+ - {dest: file, name: test-2, facility: kernel, level: emergency}
state: absent
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospf_interfaces.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospf_interfaces.py
index fdfaf2640..c2cef436f 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospf_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospf_interfaces.py
@@ -102,11 +102,12 @@ options:
md5:
description:
- Specify md5 based authentication.
- type: dict
+ type: list
+ elements: dict
suboptions:
key_id:
description: Specify md5 key-id
- type: str
+ type: int
key_value:
description: Specify key value
type: str
@@ -189,7 +190,7 @@ options:
node_link_protection:
description:
- Protect interface from both link and node faults.
- type: str
+ type: bool
dead_interval:
description:
- Dead interval (seconds).
@@ -244,14 +245,14 @@ EXAMPLES = """
- name: Merge Junos OSPF interfaces config
junipernetworks.junos.junos_ospf_interfaces:
config:
- - name: 'ge-0/0/2.0'
- address_family:
- - afi: 'ipv4'
- processes:
- area:
- area_id: '0.0.0.2'
- priority: 3
- metric: 5
+ - name: 'ge-0/0/2.0'
+ address_family:
+ - afi: 'ipv4'
+ processes:
+ area:
+ area_id: '0.0.0.2'
+ priority: 3
+ metric: 5
state: merged
# After state
@@ -279,16 +280,16 @@ EXAMPLES = """
# }
- name: Replace Junos OSPF interfaces config
junipernetworks.junos.junos_ospf_interfaces:
- config:
- - name: 'ge-0/0/2.0'
- address_family:
- - afi: 'ipv4'
- processes:
- area:
- area_id: '0.0.0.1'
- priority: 6
- metric: 6
- state: replaced
+ config:
+ - name: 'ge-0/0/2.0'
+ address_family:
+ - afi: 'ipv4'
+ processes:
+ area:
+ area_id: '0.0.0.1'
+ priority: 6
+ metric: 6
+ state: replaced
# After state
# -----------
@@ -436,14 +437,14 @@ EXAMPLES = """
- name: Render the commands for provided configuration
junipernetworks.junos.junos_ospf_interfaces:
config:
- - name: 'ge-0/0/2.0'
- address_family:
- - afi: 'ipv4'
- processes:
- area:
- area_id: '0.0.0.2'
- priority: 3
- metric: 5
+ - name: 'ge-0/0/2.0'
+ address_family:
+ - afi: 'ipv4'
+ processes:
+ area:
+ area_id: '0.0.0.2'
+ priority: 3
+ metric: 5
state: rendered
#
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv2.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv2.py
index 9d951cf79..c8ac99c97 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv2.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv2.py
@@ -36,10 +36,11 @@ DOCUMENTATION = """
module: junos_ospfv2
short_description: OSPFv2 resource module
description:
-- This module manages global OSPFv2 configuration on devices running Juniper JUNOS.
+- This module manages OSPFv2 configuration on devices running Juniper JUNOS.
version_added: 1.0.0
author:
- Daniel Mellado (@dmellado)
+- Rohit Thakur (@rohitthakur2590)
requirements:
- ncclient (>=v0.6.4)
- xmltodict (>=0.12.0)
@@ -72,7 +73,31 @@ options:
area_range:
description:
- Configure an address range for the area.
+ - Included for compatibility, remove/deprecate after 2025-07-01.
+ - Alternate for this would be area_ranges which is a list.
type: str
+ area_ranges:
+ description:
+ - Configure IP address ranges for the area.
+ type: list
+ elements: dict
+ suboptions:
+ address:
+ description:
+ - Specify ip address.
+ type: str
+ exact:
+ description:
+ - Enforce exact match for advertisement of this area range.
+ type: bool
+ restrict:
+ description:
+ - Restrict advertisement of this area range.
+ type: bool
+ override_metric:
+ description:
+ - Override the dynamic metric for this area-range.
+ type: int
stub:
description:
- Settings for configuring the area as a stub.
@@ -99,7 +124,26 @@ options:
type:
description:
- Type of authentication to use.
+ - Included for compatibility, remove/deprecate after 2025-07-01.
type: dict
+ password:
+ description: Specify authentication key.
+ type: str
+ md5:
+ description: MD5 authentication keys
+ type: list
+ elements: dict
+ suboptions:
+ key_id:
+ description: Specify the key identity
+ type: int
+ key:
+ description: Specify key value
+ type: str
+ start_time:
+ description: Specify Start time for key transmission (YYYY-MM-DD.HH:MM)
+ type: str
+
bandwidth_based_metrics:
description: Specify list of bandwidth based metrics
type: list
@@ -165,6 +209,15 @@ options:
description: Specify time for overload mode reset
type: dict
suboptions:
+ allow_route_leaking:
+ description: Allow routes to be leaked when overload is configured.
+ type: bool
+ as_external:
+ description: Advertise As External with maximum usable metric.
+ type: bool
+ stub_network:
+ description: Advertise Stub Network with maximum metric.
+ type: bool
timeout:
description:
- Time after which overload mode is reset (seconds).
@@ -203,11 +256,14 @@ options:
description:
- Number of maximum rapid SPF runs before holddown (seconds).
type: int
+ no_ignore_our_externals:
+ description: Do not ignore self-generated external and NSSA LSAs.
+ type: bool
running_config:
description:
- This option is used only with state I(parsed).
- The value of this option should be the output received from the Junos device
- by executing the command B(show protocols ospf.
+ by executing the command B(show protocols ospf).
- The state I(parsed) reads the configuration from C(running_config) option and
transforms it into Ansible structured data as per the resource module's argspec
and the value is then returned in the I(parsed) key within the result
@@ -234,44 +290,588 @@ EXAMPLES = """
#
# admin# show protocols ospf
-- name: Merge Junos OSPFv2 config
+- name: Merge provided OSPFv2 configuration into running config.
junipernetworks.junos.junos_ospfv2:
config:
- - reference_bandwidth: 10g
- areas:
- - area_id: 0.0.0.100
- area_range: 10.200.16.0/24
- stub:
- default_metric: 100
- set: true
- interfaces:
- - name: so-0/0/0.0
- priority: 3
- metric: 5
- flood_reduction: false
- passive: true
- bandwidth_based_metrics:
- - bandwidth: 1g
- metric: 5
- - bandwidth: 10g
- metric: 40
- timers:
- dead_interval: 4
- hello_interval: 2
- poll_interval: 2
- retransmit_interval: 2
- rfc1583compatibility: false
+ - reference_bandwidth: 10g
+ areas:
+ - area_id: 0.0.0.100
+ area_ranges:
+ - address: 10.200.17.0/24
+ exact: true
+ restrict: true
+ override_metric: 2000
+ - address: 10.200.15.0/24
+ exact: true
+ restrict: true
+ override_metric: 2000
+ stub:
+ default_metric: 100
+ set: true
+ interfaces:
+ - name: so-0/0/0.0
+ priority: 3
+ metric: 5
+ flood_reduction: false
+ passive: true
+ bandwidth_based_metrics:
+ - bandwidth: 1g
+ metric: 5
+ - bandwidth: 10g
+ metric: 40
+ timers:
+ dead_interval: 4
+ hello_interval: 2
+ poll_interval: 2
+ retransmit_interval: 2
+ rfc1583compatibility: false
state: merged
+# Task Output:
+# ------------
+#
+# before: []
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf><nc:reference-bandwidth>10g</nc:reference-bandwidth><nc:no-rfc-1583/>
+# <nc:area><nc:name>0.0.0.100</nc:name><nc:area-range><nc:name>10.200.17.0/24</nc:name><nc:exact/>
+# <nc:restrict/><nc:override-metric>2000</nc:override-metric></nc:area-range><nc:area-range>
+# <nc:name>10.200.15.0/24</nc:name><nc:exact/><nc:restrict/><nc:override-metric>2000</nc:override-metric>
+# </nc:area-range><nc:interface><nc:name>so-0/0/0.0</nc:name><nc:priority>3</nc:priority>
+# <nc:metric>5</nc:metric><nc:passive/><nc:bandwidth-based-metrics><nc:bandwidth><nc:name>1g</nc:name>
+# <nc:metric>5</nc:metric></nc:bandwidth><nc:bandwidth><nc:name>10g</nc:name><nc:metric>40</nc:metric>
+# </nc:bandwidth></nc:bandwidth-based-metrics><nc:dead-interval>4</nc:dead-interval>
+# <nc:hello-interval>2</nc:hello-interval><nc:poll-interval>2</nc:poll-interval>
+# <nc:retransmit-interval>2</nc:retransmit-interval></nc:interface><nc:stub>
+# <nc:default-metric>100</nc:default-metric></nc:stub></nc:area></nc:ospf></nc:protocols>
+#
+# after:
+# - areas:
+# - area_id: 0.0.0.100
+# area_range: '[''10.200.17.0/24'', ''10.200.15.0/24'']'
+# area_ranges:
+# - address: 10.200.17.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# - address: 10.200.15.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# timers:
+# dead_interval: 4
+# hello_interval: 2
+# poll_interval: 2
+# retransmit_interval: 2
+# stub:
+# default_metric: 100
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+
+# After state
+# -----------
+#
+# admin# show protocols ospf
+# reference-bandwidth 10g;
+# no-rfc-1583;
+# area 0.0.0.100 {
+# stub default-metric 100;
+# area-range 10.200.17.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# area-range 10.200.15.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# interface so-0/0/0.0 {
+# passive;
+# bandwidth-based-metrics {
+# bandwidth 1g metric 5;
+# bandwidth 10g metric 40;
+# }
+# metric 5;
+# priority 3;
+# retransmit-interval 2;
+# hello-interval 2;
+# dead-interval 4;
+# poll-interval 2;
+# }
+# }
+#
+# Using replaced
+#
+# Before state
+# ------------
+#
+# admin# show protocols ospf
+# reference-bandwidth 10g;
+# no-rfc-1583;
+# area 0.0.0.100 {
+# stub default-metric 100;
+# area-range 10.200.17.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# area-range 10.200.15.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# interface so-0/0/0.0 {
+# passive;
+# bandwidth-based-metrics {
+# bandwidth 1g metric 5;
+# bandwidth 10g metric 40;
+# }
+# metric 5;
+# priority 3;
+# retransmit-interval 2;
+# hello-interval 2;
+# dead-interval 4;
+# poll-interval 2;
+# }
+# }
+
+- name: Replace existing Junos OSPFv2 config with provided config
+ junipernetworks.junos.junos_ospfv2:
+ config:
+ - reference_bandwidth: 10g
+ areas:
+ - area_id: 0.0.0.100
+ area_ranges:
+ - address: 10.200.17.0/24
+ exact: true
+ restrict: true
+ - address: 10.200.16.0/24
+ exact: true
+ restrict: true
+ override_metric: 1000
+ stub:
+ default_metric: 100
+ set: true
+ interfaces:
+ - name: so-0/0/0.0
+ priority: 3
+ metric: 5
+ flood_reduction: false
+ passive: true
+ bandwidth_based_metrics:
+ - bandwidth: 1g
+ metric: 5
+ - bandwidth: 10g
+ metric: 40
+ timers:
+ dead_interval: 4
+ hello_interval: 2
+ poll_interval: 2
+ retransmit_interval: 2
+ rfc1583compatibility: false
+ state: replacedd
+
+# Task Output:
+# ------------
+#
+# before:
+# - areas:
+# - area_id: 0.0.0.100
+# area_range: '[''10.200.17.0/24'', ''10.200.15.0/24'']'
+# area_ranges:
+# - address: 10.200.17.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# - address: 10.200.15.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# timers:
+# dead_interval: 4
+# hello_interval: 2
+# poll_interval: 2
+# retransmit_interval: 2
+# stub:
+# default_metric: 100
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf><nc:area delete="delete">0.0.0.100</nc:area></nc:ospf><nc:ospf>
+# <nc:reference-bandwidth>10g</nc:reference-bandwidth><nc:no-rfc-1583/><nc:area>
+# <nc:name>0.0.0.100</nc:name><nc:area-range><nc:name>10.200.17.0/24</nc:name><nc:exact/>
+# <nc:restrict/></nc:area-range><nc:area-range><nc:name>10.200.16.0/24</nc:name><nc:exact/>
+# <nc:restrict/><nc:override-metric>1000</nc:override-metric></nc:area-range><nc:interface>
+# <nc:name>so-0/0/0.0</nc:name><nc:priority>3</nc:priority><nc:metric>5</nc:metric><nc:passive/>
+# <nc:bandwidth-based-metrics><nc:bandwidth><nc:name>1g</nc:name><nc:metric>5</nc:metric>
+# </nc:bandwidth><nc:bandwidth><nc:name>10g</nc:name><nc:metric>40</nc:metric></nc:bandwidth>
+# </nc:bandwidth-based-metrics><nc:dead-interval>4</nc:dead-interval><nc:hello-interval>2</nc:hello-interval>
+# <nc:poll-interval>2</nc:poll-interval><nc:retransmit-interval>2</nc:retransmit-interval></nc:interface>
+# <nc:stub><nc:default-metric>100</nc:default-metric></nc:stub></nc:area></nc:ospf></nc:protocols>
+#
+# after:
+# - areas:
+# - area_id: 0.0.0.100
+# area_range: '[''10.200.17.0/24'', ''10.200.16.0/24'']'
+# area_ranges:
+# - address: 10.200.17.0/24
+# exact: true
+# restrict: true
+# - address: 10.200.16.0/24
+# exact: true
+# override_metric: 1000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# timers:
+# dead_interval: 4
+# hello_interval: 2
+# poll_interval: 2
+# retransmit_interval: 2
+# stub:
+# default_metric: 100
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+#
+# After state
+# -----------
+#
+# admin# show protocols ospf
+# reference-bandwidth 10g;
+# no-rfc-1583;
+# area 0.0.0.100 {
+# stub default-metric 100;
+# area-range 10.200.17.0/24 {
+# restrict;
+# exact;
+# }
+# area-range 10.200.16.0/24 {
+# restrict;
+# exact;
+# override-metric 1000;
+# }
+# interface so-0/0/0.0 {
+# passive;
+# bandwidth-based-metrics {
+# bandwidth 1g metric 5;
+# bandwidth 10g metric 40;
+# }
+# metric 5;
+# priority 3;
+# retransmit-interval 2;
+# hello-interval 2;
+# dead-interval 4;
+# poll-interval 2;
+# }
+# }
+#
+# Using overridden
+#
+# Before state
+# ------------
+#
+# admin# show protocols ospf
+# reference-bandwidth 10g;
+# no-rfc-1583;
+# area 0.0.0.100 {
+# stub default-metric 100;
+# area-range 10.200.17.0/24 {
+# restrict;
+# exact;
+# }
+# area-range 10.200.16.0/24 {
+# restrict;
+# exact;
+# override-metric 1000;
+# }
+# interface so-0/0/0.0 {
+# passive;
+# bandwidth-based-metrics {
+# bandwidth 1g metric 5;
+# bandwidth 10g metric 40;
+# }
+# metric 5;
+# priority 3;
+# retransmit-interval 2;
+# hello-interval 2;
+# dead-interval 4;
+# poll-interval 2;
+# }
+# }
+
+- name: Override runnig OSPFv2 config with provided config
+ junipernetworks.junos.junos_ospfv2:
+ config:
+ - reference_bandwidth: 10g
+ areas:
+ - area_id: 0.0.0.110
+ area_ranges:
+ - address: 20.200.17.0/24
+ exact: true
+ restrict: true
+ override_metric: 2000
+ - address: 20.200.15.0/24
+ exact: true
+ restrict: true
+ override_metric: 2000
+ stub:
+ default_metric: 200
+ set: true
+ interfaces:
+ - name: so-0/0/0.0
+ priority: 3
+ metric: 5
+ flood_reduction: false
+ passive: true
+ bandwidth_based_metrics:
+ - bandwidth: 1g
+ metric: 5
+ - bandwidth: 10g
+ metric: 40
+ state: overridden
+
+# Task Output:
+# ------------
+#
+# before:
+# - areas:
+# - area_id: 0.0.0.100
+# area_range: '[''10.200.17.0/24'', ''10.200.16.0/24'']'
+# area_ranges:
+# - address: 10.200.17.0/24
+# exact: true
+# restrict: true
+# - address: 10.200.16.0/24
+# exact: true
+# override_metric: 1000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# timers:
+# dead_interval: 4
+# hello_interval: 2
+# poll_interval: 2
+# retransmit_interval: 2
+# stub:
+# default_metric: 100
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf><nc:area delete="delete">0.0.0.100</nc:area></nc:ospf><nc:ospf>
+# <nc:reference-bandwidth>10g</nc:reference-bandwidth><nc:area><nc:name>0.0.0.110</nc:name>
+# <nc:area-range><nc:name>20.200.17.0/24</nc:name><nc:exact/><nc:restrict/>
+# <nc:override-metric>2000</nc:override-metric></nc:area-range><nc:area-range>
+# <nc:name>20.200.15.0/24</nc:name><nc:exact/><nc:restrict/><nc:override-metric>2000</nc:override-metric>
+# </nc:area-range><nc:interface><nc:name>so-0/0/0.0</nc:name><nc:priority>3</nc:priority>
+# <nc:metric>5</nc:metric><nc:passive/><nc:bandwidth-based-metrics><nc:bandwidth><nc:name>1g</nc:name>
+# <nc:metric>5</nc:metric></nc:bandwidth><nc:bandwidth><nc:name>10g</nc:name><nc:metric>40</nc:metric>
+# </nc:bandwidth></nc:bandwidth-based-metrics></nc:interface><nc:stub>
+# <nc:default-metric>200</nc:default-metric></nc:stub></nc:area></nc:ospf></nc:protocols>
+#
+# after:
+# - areas:
+# - area_id: 0.0.0.110
+# area_range: '[''20.200.17.0/24'', ''20.200.15.0/24'']'
+# area_ranges:
+# - address: 20.200.17.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# - address: 20.200.15.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# stub:
+# default_metric: 200
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+
+# After state
+# -----------
+#
+# admin# show protocols ospf
+# reference-bandwidth 10g;
+# no-rfc-1583;
+# area 0.0.0.110 {
+# stub default-metric 200;
+# area-range 20.200.17.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# area-range 20.200.15.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# interface so-0/0/0.0 {
+# passive;
+# bandwidth-based-metrics {
+# bandwidth 1g metric 5;
+# bandwidth 10g metric 40;
+# }
+# metric 5;
+# priority 3;
+# }
+# }
+# Using deleted
+#
+# Before state
+# ------------
+#
+# admin# show protocols ospf
+# reference-bandwidth 10g;
+# no-rfc-1583;
+# area 0.0.0.110 {
+# stub default-metric 200;
+# area-range 20.200.17.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# area-range 20.200.15.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# interface so-0/0/0.0 {
+# passive;
+# bandwidth-based-metrics {
+# bandwidth 1g metric 5;
+# bandwidth 10g metric 40;
+# }
+# metric 5;
+# priority 3;
+# }
+# }
+
+- name: Delete OSPFv2 running config.
+ junipernetworks.junos.junos_ospfv2:
+ config:
+ state: deleted
+
+# Task Output:
+# ------------
+#
+# before:
+# - areas:
+# - area_id: 0.0.0.110
+# area_range: '[''20.200.17.0/24'', ''20.200.15.0/24'']'
+# area_ranges:
+# - address: 20.200.17.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# - address: 20.200.15.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# stub:
+# default_metric: 200
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf><nc:area delete="delete">0.0.0.100</nc:area><nc:reference-bandwidth delete="delete"/>
+# <nc:no-rfc-1583 delete="delete"/></nc:ospf></nc:protocols>
+#
+# after: []
+#
+#
# After state
# -----------
#
# admin# show protocols ospf
+
+# Using gathered
+#
+# Before state
+# ------------
+#
+# admin# show protocols ospf
# reference-bandwidth 10g;
# no-rfc-1583;
# area 0.0.0.100 {
# stub default-metric 100;
-# area-range 10.200.16.0/24;
+# area-range 10.200.17.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
+# area-range 10.200.15.0/24 {
+# restrict;
+# exact;
+# override-metric 2000;
+# }
# interface so-0/0/0.0 {
# passive;
# bandwidth-based-metrics {
@@ -287,17 +887,221 @@ EXAMPLES = """
# }
# }
+- name: Gather Junos OSPFv2 running-configuration
+ junipernetworks.junos.junos_ospfv2:
+ config:
+ state: gathered
+#
+#
+# Task Output:
+# ------------
+#
+# gathered:
+#
+# - areas:
+# - area_id: 0.0.0.100
+# area_range: '[''10.200.17.0/24'', ''10.200.15.0/24'']'
+# area_ranges:
+# - address: 10.200.17.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# - address: 10.200.15.0/24
+# exact: true
+# override_metric: 2000
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# timers:
+# dead_interval: 4
+# hello_interval: 2
+# poll_interval: 2
+# retransmit_interval: 2
+# stub:
+# default_metric: 100
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+
+# 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">
+# <version>18.4R1-S2.4</version>
+# <protocols>
+# <ospf>
+# <reference-bandwidth>10g</reference-bandwidth>
+# <no-rfc-1583/>
+# <area>
+# <name>0.0.0.100</name>
+# <stub>
+# <default-metric>100</default-metric>
+# </stub>
+# <area-range>
+# <name>10.200.16.0/24</name>
+# <exact/>
+# <override-metric>10000</override-metric>
+# </area-range>
+# <area-range>
+# <name>10.200.11.0/24</name>
+# <restrict/>
+# <exact/>
+# </area-range>
+# <interface>
+# <name>so-0/0/0.0</name>
+# <passive>
+# </passive>
+# <bandwidth-based-metrics>
+# <bandwidth>
+# <name>1g</name>
+# <metric>5</metric>
+# </bandwidth>
+# <bandwidth>
+# <name>10g</name>
+# <metric>40</metric>
+# </bandwidth>
+# </bandwidth-based-metrics>
+# <metric>5</metric>
+# <priority>3</priority>
+# <retransmit-interval>2</retransmit-interval>
+# <hello-interval>2</hello-interval>
+# <dead-interval>4</dead-interval>
+# <poll-interval>2</poll-interval>
+# </interface>
+# </area>
+# </ospf>
+# </protocols>
+# <routing-options>
+# <static>
+# <route>
+# <name>172.16.17.0/24</name>
+# <discard />
+# </route>
+# </static>
+# <router-id>10.200.16.75</router-id>
+# <autonomous-system>
+# <as-number>65432</as-number>
+# </autonomous-system>
+# </routing-options>
+# </configuration>
+# </rpc-reply>
+
+
+- name: Parsed the ospfv2 config into structured ansible resource facts.
+ junipernetworks.junos.junos_ospfv2:
+ running_config: "{{ lookup('file', './parsed.cfg') }}"
+ state: parsed
+#
+# Task Output:
+# ------------
+#
+# parsed:
+# - areas:
+# - area_id: 0.0.0.100
+# area_range: '[''10.200.16.0/24'', ''10.200.11.0/24'']'
+# area_ranges:
+# - address: 10.200.16.0/24
+# exact: true
+# override_metric: 10000
+# - address: 10.200.11.0/24
+# exact: true
+# restrict: true
+# interfaces:
+# - bandwidth_based_metrics:
+# - bandwidth: 1g
+# metric: 5
+# - bandwidth: 10g
+# metric: 40
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# timers:
+# dead_interval: 4
+# hello_interval: 2
+# poll_interval: 2
+# retransmit_interval: 2
+# stub:
+# default_metric: 100
+# set: true
+# reference_bandwidth: 10g
+# rfc1583compatibility: false
+# router_id: 10.200.16.75
+
+# Using rendered
+#
+- name: Render the commands for provided configuration
+ junipernetworks.junos.junos_ospfv2:
+ config:
+ - reference_bandwidth: 10g
+ areas:
+ - area_id: 0.0.0.100
+ area_ranges:
+ - address: 10.200.17.0/24
+ exact: true
+ restrict: true
+ override_metric: 2000
+ - address: 10.200.15.0/24
+ exact: true
+ restrict: true
+ override_metric: 2000
+ stub:
+ default_metric: 100
+ set: true
+ interfaces:
+ - name: so-0/0/0.0
+ priority: 3
+ metric: 5
+ flood_reduction: false
+ passive: true
+ bandwidth_based_metrics:
+ - bandwidth: 1g
+ metric: 5
+ - bandwidth: 10g
+ metric: 40
+ timers:
+ dead_interval: 4
+ hello_interval: 2
+ poll_interval: 2
+ retransmit_interval: 2
+ rfc1583compatibility: false
+ state: rendered
+
+# Task Output:
+# ------------
+#
+# rendered: "<nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf><nc:reference-bandwidth>10g</nc:reference-bandwidth><nc:no-rfc-1583/><nc:area><nc:name>0.0.0.100</nc:name>
+# <nc:area-range><nc:name>10.200.17.0/24</nc:name><nc:exact/><nc:restrict/><nc:override-metric>2000</nc:override-metric>
+# </nc:area-range><nc:area-range><nc:name>10.200.15.0/24</nc:name><nc:exact/><nc:restrict/>
+# <nc:override-metric>2000</nc:override-metric></nc:area-range><nc:interface><nc:name>so-0/0/0.0</nc:name>
+# <nc:priority>3</nc:priority><nc:metric>5</nc:metric><nc:passive/><nc:bandwidth-based-metrics><nc:bandwidth>
+# <nc:name>1g</nc:name><nc:metric>5</nc:metric></nc:bandwidth><nc:bandwidth><nc:name>10g</nc:name>
+# <nc:metric>40</nc:metric></nc:bandwidth></nc:bandwidth-based-metrics><nc:dead-interval>4</nc:dead-interval>
+# <nc:hello-interval>2</nc:hello-interval><nc:poll-interval>2</nc:poll-interval>
+# <nc:retransmit-interval>2</nc:retransmit-interval></nc:interface><nc:stub>
+# <nc:default-metric>100</nc:default-metric></nc:stub></nc:area></nc:ospf></nc:protocols>"
"""
RETURN = """
before:
- description: The configuration prior to the model invocation.
+ description: The configuration prior to the module invocation.
returned: always
type: dict
sample: >
The configuration returned will always be in the same format
of the parameters above.
after:
- description: The resulting configuration model invocation.
+ description: The resulting configuration module invocation.
returned: when changed
type: dict
sample: >
@@ -307,7 +1111,29 @@ commands:
description: The set of commands pushed to the remote device.
returned: always
type: list
- sample: ['command 1', 'command 2', 'command 3']
+ sample: ['<nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><
+ nc:ospf><nc:area delete="delete">0.0.0.100</nc:area><nc:reference-bandwidth delete="delete"/>
+ <nc:no-rfc-1583 delete="delete"/></nc:ospf></nc:protocols>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv3.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv3.py
index 0d49c625b..9a6a275dc 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv3.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ospfv3.py
@@ -205,7 +205,7 @@ options:
description:
- This option is used only with state I(parsed).
- The value of this option should be the output received from the Junos device
- by executing the command B(show protocols ospf.
+ by executing the command B(show protocols ospf).
- The state I(parsed) reads the configuration from C(running_config) option and
transforms it into Ansible structured data as per the resource module's argspec
and the value is then returned in the I(parsed) key within the result
@@ -235,57 +235,148 @@ EXAMPLES = """
- name: Merge Junos OSPFv3 config
junipernetworks.junos.junos_ospfv3:
config:
- - areas:
- - area_id: 0.0.0.100
- stub:
- default_metric: 200
- set: true
- interfaces:
- - name: so-0/0/0.0
- priority: 3
- metric: 5
+ - router_id: 10.200.16.75
+ areas:
+ - area_id: 0.0.0.100
+ interfaces:
+ - metric: 5
+ name: so-0/0/0.0
+ priority: 3
+ - metric: 6
+ name: so-0/0/1.0
+ priority: 2
+ stub:
+ default_metric: 200
+ set: true
state: merged
+# Task Output:
+# ------------
+#
+# before: []
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf3><nc:area><nc:name>0.0.0.100</nc:name><nc:interface><nc:name>so-0/0/0.0</nc:name>
+# <nc:priority>3</nc:priority><nc:metric>5</nc:metric></nc:interface><nc:interface>
+# <nc:name>so-0/0/1.0</nc:name><nc:priority>2</nc:priority><nc:metric>6</nc:metric>
+# </nc:interface><nc:stub><nc:default-metric>200</nc:default-metric></nc:stub></nc:area></nc:ospf3></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:router-id>10.200.16.75</nc:router-id></nc:routing-options>
+#
+# after:
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - metric: 5
+# name: so-0/0/0.0
+# priority: 3
+# - metric: 6
+# name: so-0/0/1.0
+# priority: 2
+# stub:
+# default_metric: 200
+# set: true
+# router_id: 10.200.16.75
+
# After state
# -----------
#
-# adimn# show protocols ospf3
+# admin# show protocols ospf3
# area 0.0.0.100 {
# stub default-metric 200;
# interface so-0/0/0.0 {
# metric 5;
# priority 3;
# }
+# interface so-0/0/1.0 {
+# metric 6;
+# priority 2;
+# }
# }
+#
# Using replaced
#
# Before state
# ------------
#
-# adimn# show protocols ospf3
+# admin# show protocols ospf3
+# admin# show protocols ospf3
# area 0.0.0.100 {
# stub default-metric 200;
# interface so-0/0/0.0 {
# metric 5;
# priority 3;
# }
+# interface so-0/0/1.0 {
+# metric 6;
+# priority 2;
+# }
# }
-- name: Replace Junos OSPFv3 config
+
+- name: Replace existing Junos OSPFv3 config with provided config
junipernetworks.junos.junos_ospfv3:
- config:
- - areas:
- - area_id: 0.0.0.100
- interfaces:
- - name: so-0/0/0.0
- state: replaced
+ config:
+ - router_id: 10.200.16.75
+ areas:
+ - area_id: 0.0.0.100
+ interfaces:
+ - name: so-0/0/0.0
+ state: replaced
+# Task Output:
+# ------------
+#
+# before:
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - metric: 5
+# name: so-0/0/0.0
+# priority: 3
+# - metric: 6
+# name: so-0/0/1.0
+# priority: 2
+# stub:
+# default_metric: 200
+# set: true
+# router_id: 10.200.16.75
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf3><nc:area><nc:name>0.0.0.100</nc:name><nc:interface delete="delete">
+# <nc:name>so-0/0/0.0</nc:name></nc:interface></nc:area></nc:ospf3><nc:ospf3>
+# <nc:area><nc:name>0.0.0.100</nc:name><nc:interface><nc:name>so-0/0/0.0</nc:name>
+# </nc:interface></nc:area></nc:ospf3></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:router-id>10.200.16.75</nc:router-id><nc:router-id>10.200.16.75</nc:router-id></nc:routing-options>
+#
+# after:
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - metric: 6
+# name: so-0/0/1.0
+# priority: 2
+# - name: so-0/0/0.0
+# stub:
+# default_metric: 200
+# set: true
+# router_id: 10.200.16.75
+#
# After state
# -----------
#
# admin# show protocols ospf3
# area 0.0.0.100 {
+# stub default-metric 200;
+# interface so-0/0/1.0 {
+# metric 6;
+# priority 2;
+# }
# interface so-0/0/0.0;
# }
+#
# Using overridden
#
# Before state
@@ -293,27 +384,80 @@ EXAMPLES = """
#
# admin# show protocols ospf3
# area 0.0.0.100 {
+# stub default-metric 200;
+# interface so-0/0/1.0 {
+# metric 6;
+# priority 2;
+# }
# interface so-0/0/0.0;
# }
-- name: Override Junos OSPFv3 config
+
+- name: Override runnig OSPFv3 config with provided config
junipernetworks.junos.junos_ospfv3:
- config:
- - areas:
- - area_id: 0.0.0.100
- stub:
- default_metric: 200
- set: true
- interfaces:
- - name: so-0/0/0.0
- priority: 3
- metric: 5
- flood_reduction: true
- passive: true
- - area_id: 0.0.0.200
- interfaces:
- - name: ge-1/1/0.0
- - name: ge-2/2/0.0
- state: overridden
+ config:
+ - router_id: 10.200.16.75
+ areas:
+ - area_id: 0.0.0.100
+ stub:
+ default_metric: 200
+ set: true
+ interfaces:
+ - name: so-0/0/0.0
+ priority: 3
+ metric: 5
+ flood_reduction: true
+ passive: true
+ - area_id: 0.0.0.200
+ interfaces:
+ - name: ge-1/1/0.0
+ - name: ge-2/2/0.0
+ state: overridden
+
+# Task Output:
+# ------------
+#
+# before:
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - metric: 6
+# name: so-0/0/1.0
+# priority: 2
+# - name: so-0/0/0.0
+# stub:
+# default_metric: 200
+# set: true
+# router_id: 10.200.16.75
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf3 delete="delete"/><nc:ospf3><nc:area><nc:name>0.0.0.100</nc:name>
+# <nc:interface><nc:name>so-0/0/0.0</nc:name><nc:priority>3</nc:priority><nc:flood-reduction/>
+# <nc:metric>5</nc:metric><nc:passive/></nc:interface>
+# <nc:stub><nc:default-metric>200</nc:default-metric></nc:stub></nc:area>
+# <nc:area><nc:name>0.0.0.200</nc:name><nc:interface><nc:name>ge-1/1/0.0</nc:name>
+# </nc:interface><nc:interface><nc:name>ge-2/2/0.0</nc:name></nc:interface></nc:area>
+# </nc:ospf3></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:router-id delete="delete"/><nc:router-id>10.200.16.75</nc:router-id></nc:routing-options>
+#
+# after:
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - flood_reduction: true
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# stub:
+# default_metric: 200
+# set: true
+# - area_id: 0.0.0.200
+# interfaces:
+# - name: ge-1/1/0.0
+# - name: ge-2/2/0.0
+# router_id: 10.200.16.75
# After state
# -----------
@@ -332,285 +476,213 @@ EXAMPLES = """
# interface ge-1/1/0.0;
# interface ge-2/2/0.0;
# }
-#
# Using deleted
#
# Before state
# ------------
#
-# adimn# show protocols ospf3
+# admin# show protocols ospf3
# area 0.0.0.100 {
# stub default-metric 200;
# interface so-0/0/0.0 {
+# passive;
# metric 5;
# priority 3;
+# flood-reduction;
# }
# }
+# area 0.0.0.200 {
+# interface ge-1/1/0.0;
+# interface ge-2/2/0.0;
+# }
-- name: Delete Junos OSPFv3 config
+- name: Delete OSPFv3 running config.
junipernetworks.junos.junos_ospfv3:
config:
- - areas:
- - area_id: 0.0.0.100
- interfaces:
- - name: so-0/0/0.0
state: deleted
+# Task Output:
+# ------------
+#
+# before:
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - flood_reduction: true
+# metric: 5
+# name: so-0/0/0.0
+# passive: true
+# priority: 3
+# stub:
+# default_metric: 200
+# set: true
+# - area_id: 0.0.0.200
+# interfaces:
+# - name: ge-1/1/0.0
+# - name: ge-2/2/0.0
+# router_id: 10.200.16.75
+#
+# commands:
+# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf3 delete="delete"/></nc:protocols>
+# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:router-id delete="delete"/></nc:routing-options>
+#
+# after: []
+#
+#
# After state
# -----------
#
# admin# show protocols ospf3
+
# Using gathered
#
# Before state
# ------------
#
-# adimn# show protocols ospf3
+# admin# show protocols ospf3
# area 0.0.0.100 {
# stub default-metric 200;
# interface so-0/0/0.0 {
-# passive;
# metric 5;
# priority 3;
-# flood-reduction;
# }
-# }
-# area 0.0.0.200 {
-# interface ge-1/1/0.0;
-# interface ge-2/2/0.0;
-# }
+# interface so-0/0/1.0 {
+# metric 6;
+# priority 2;
+# }
-- name: Gather Junos OSPFv3 config
+- name: Gather Junos OSPFv3 running-configuration
junipernetworks.junos.junos_ospfv3:
config:
state: gathered
#
#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "gathered": {
-# "areas": [
-# {
-# "area_id": "0.0.0.100",
-# "interfaces": [
-# {
-# "flood_reduction": true,
-# "metric": 5,
-# "name": "so-0/0/0.0",
-# "passive": true,
-# "priority": 3
-# }
-# ],
-# "stub": {
-# "default_metric": 200,
-# "set": true
-# }
-# },
-# {
-# "area_id": "0.0.0.200",
-# "interfaces": [
-# {
-# "name": "ge-1/1/0.0"
-# },
-# {
-# "name": "ge-2/2/0.0"
-# }
-# ]
-# }
-# ],
-# }
-#
-# Using rendered
-#
+# Task Output:
+# ------------
#
-- name: Render the commands for provided configuration
- junipernetworks.junos.junos_ospfv3:
- config:
- - areas:
- - area_id: 0.0.0.100
- stub:
- default_metric: 200
- set: true
- interfaces:
- - name: so-0/0/0.0
- priority: 3
- metric: 5
- flood_reduction: true
- passive: true
- - area_id: 0.0.0.200
- interfaces:
- - name: ge-1/1/0.0
- - name: ge-2/2/0.0
- state: rendered
+# gathered:
+#
+# - areas:
+# - area_id: 0.0.0.100
+# interfaces:
+# - metric: 5
+# name: so-0/0/0.0
+# priority: 3
+# - metric: 6
+# name: so-0/0/1.0
+# priority: 2
+# stub:
+# default_metric: 200
+# set: true
+# router_id: 10.200.16.75
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "rendered": "
-# <nc:protocols
-# xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# <nc:ospf3>
-# <nc:area>
-# <nc:name>0.0.0.100</nc:name>
-# <nc:interface>
-# <nc:name>so-0/0/0.0</nc:name>
-# <nc:priority>3</nc:priority>
-# <nc:flood-reduction/>
-# <nc:metric>5</nc:metric>
-# <nc:passive/>
-# </nc:interface>
-# <nc:stub>
-# <nc:default-metric>200</nc:default-metric>
-# </nc:stub>
-# </nc:area>
-# <nc:area>
-# <nc:name>0.0.0.200</nc:name>
-# <nc:interface>
-# <nc:name>ge-1/1/0.0</nc:name>
-# </nc:interface>
-# <nc:interface>
-# <nc:name>ge-2/2/0.0</nc:name>
-# </nc:interface>
-# </nc:area>
-# </nc:ospf3>
-# </nc:protocols>"
-#
# Using parsed
# parsed.cfg
# ------------
-# <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/18.4R1/junos">
-# <data>
-# <configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"
-# junos:commit-seconds="1601355317" junos:commit-localtime="2020-09-29 04:55:17 UTC" junos:commit-user="rohit">
-# <version>18.4R1-S2.4</version>
-# <interfaces>
-# <interface>
-# <name>ge-0/0/0</name>
-# <description>Configured by Ansi-Team</description>
-# </interface>
-# <interface>
-# <name>gr-0/0/0</name>
-# <description>Configured Manually</description>
-# </interface>
-# <interface>
-# <name>fxp0</name>
-# <unit>
-# <name>0</name>
-# <family>
-# <inet>
-# <dhcp>
-# </dhcp>
-# </inet>
-# </family>
-# </unit>
-# </interface>
-# </interfaces>
-# <protocols>
-# <ospf3>
-# <area>
-# <name>0.0.0.100</name>
-# <stub>
-# <default-metric>200</default-metric>
-# </stub>
-# <interface>
-# <name>so-0/0/0.0</name>
-# <passive>
-# </passive>
-# <metric>5</metric>
-# <priority>3</priority>
-# <flood-reduction/>
-# </interface>
-# </area>
-# <area>
-# <name>0.0.0.200</name>
-# <interface>
-# <name>ge-1/1/0.0</name>
-# </interface>
-# <interface>
-# <name>ge-2/2/0.0</name>
-# </interface>
-# </area>
-# </ospf3>
-# </protocols>
-# <routing-options>
-# <router-id>10.200.16.75</router-id>
-# </routing-options>
-# </configuration>
-# <database-status-information>
-# <database-status>
-# <user>rohit</user>
-# <terminal>pts/0</terminal>
-# <pid>38210</pid>
-# <start-time junos:seconds="1601354977">2020-09-29 04:49:37 UTC</start-time>
-# <idle-time junos:seconds="546">00:09:06</idle-time>
-# <edit-path>[edit]</edit-path>
-# </database-status>
-# </database-status-information>
-# </data>
+# <?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">
+# <protocols>
+# <ospf3>
+# <area>
+# <name>0.0.0.100</name>
+# <stub>
+# <default-metric>200</default-metric>
+# </stub>
+# <interface>
+# <name>so-0/0/0.0</name>
+# <passive></passive>
+# <metric>5</metric>
+# <priority>3</priority>
+# <flood-reduction/>
+# </interface>
+# </area>
+# <area>
+# <name>0.0.0.200</name>
+# <interface>
+# <name>ge-1/1/0.0</name>
+# </interface>
+# <interface>
+# <name>ge-2/2/0.0</name>
+# </interface>
+# </area>
+# </ospf3>
+# </protocols>
+# <routing-options>
+# <router-id>10.200.16.75</router-id>
+# </routing-options>
+# </configuration>
# </rpc-reply>
-- name: Parsed the device configuration to get output commands
+
+- name: Parsed the ospfv3 config into structured ansible resource facts.
junipernetworks.junos.junos_ospfv3:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
#
+# Task Output:
+# ------------
+#
+# parsed:
+# - router_id: 10.200.16.75
+# areas:
+# - area_id: 0.0.0.100
+# stub:
+# default_metric: 200
+# set: true
+# interfaces:
+# - name: so-0/0/0.0
+# priority: 3
+# metric: 5
+# flood_reduction: true
+# passive: true
+# - area_id: 0.0.0.200
+# interfaces:
+# - name: ge-1/1/0.0
+# - name: ge-2/2/0.0
+
+# Using rendered
#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "parsed": [
-# {
-# "areas": [
-# {
-# "area_id": "0.0.0.100",
-# "interfaces": [
-# {
-# "flood_reduction": true,
-# "metric": 5,
-# "name": "so-0/0/0.0",
-# "passive": true,
-# "priority": 3
-# }
-# ],
-# "stub": {
-# "default_metric": 200,
-# "set": true
-# }
-# },
-# {
-# "area_id": "0.0.0.200",
-# "interfaces": [
-# {
-# "name": "ge-1/1/0.0"
-# },
-# {
-# "name": "ge-2/2/0.0"
-# }
-# ]
-# }
-# ],
-# }
-# ]
+- name: Render the commands for provided configuration
+ junipernetworks.junos.junos_ospfv3:
+ config:
+ - router_id: 10.200.16.75
+ areas:
+ - area_id: 0.0.0.100
+ interfaces:
+ - metric: 5
+ name: so-0/0/0.0
+ priority: 3
+ - metric: 6
+ name: so-0/0/1.0
+ priority: 2
+ stub:
+ default_metric: 200
+ set: true
+ state: rendered
+
+# Task Output:
+# ------------
#
+# rendered: "<nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# <nc:ospf3><nc:area><nc:name>0.0.0.100</nc:name><nc:interface>
+# <nc:name>so-0/0/0.0</nc:name><nc:priority>3</nc:priority>
+# <nc:metric>5</nc:metric></nc:interface><nc:interface><nc:name>so-0/0/1.0</nc:name>
+# <nc:priority>2</nc:priority><nc:metric>6</nc:metric></nc:interface><nc:stub>
+# <nc:default-metric>200</nc:default-metric></nc:stub></nc:area></nc:ospf3></nc:protocols>"
"""
RETURN = """
before:
- description: The configuration prior to the model invocation.
+ description: The configuration prior to the module invocation.
returned: always
type: dict
sample: >
The configuration returned will always be in the same format
of the parameters above.
after:
- description: The resulting configuration model invocation.
+ description: The resulting configuration module invocation.
returned: when changed
type: dict
sample: >
@@ -620,40 +692,28 @@ commands:
description: The set of commands pushed to the remote device.
returned: always
type: list
- sample: ['<nc:protocols
- xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
- <nc:ospf3 delete=\"delete\"/>
- <nc:ospf3>
- <nc:area>
- <nc:name>0.0.0.100</nc:name>
- <nc:interface>
- <nc:name>so-0/0/0.0</nc:name>
- <nc:priority>3</nc:priority>
- <nc:flood-reduction/>
- <nc:metric>5</nc:metric>
- <nc:passive/>
- </nc:interface>
- <nc:stub>
- <nc:default-metric>200</nc:default-metric>
- </nc:stub>
- </nc:area>
- <nc:area>
- <nc:name>0.0.0.200</nc:name>
- <nc:interface>
- <nc:name>ge-1/1/0.0</nc:name>
- </nc:interface>
- <nc:interface>
- <nc:name>ge-2/2/0.0</nc:name>
- </nc:interface>
- </nc:area>
- </nc:ospf3>
-</nc:protocols>",
- "
-<nc:routing-options
- xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
- <nc:router-id delete=\"delete\"/>
- <nc:router-id>10.200.16.75</nc:router-id>
-</nc:routing-options>', 'xml 2', 'xml 3']
+ sample: ['<nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><
+ nc:ospf3><nc:area><nc:name>0.0.0.100</nc:name><nc:interface>', 'xml 2', 'xml 3']
+rendered:
+ description: The provided configuration in the task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_package.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_package.py
index 0cffb4ddb..cfd9db297 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_package.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_package.py
@@ -44,27 +44,33 @@ options:
updated package has been installed. If disabled or the remote package does not
need to be changed, the device will not be started.
type: bool
- default: yes
+ default: true
no_copy:
description:
- The I(no_copy) argument is responsible for instructing the remote device on
where to install the package from. When enabled, the package is transferred
to the remote device prior to installing.
type: bool
- default: no
+ default: false
+ unlink:
+ description:
+ - The I(unlink) argument is responsible for instructing the remote device to
+ remove the installation packages after installation.
+ type: bool
+ default: false
validate:
description:
- The I(validate) argument is responsible for instructing the remote device to
skip checking the current device configuration compatibility with the package
being installed. When set to false validation is not performed.
type: bool
- default: yes
+ default: true
force:
description:
- The I(force) argument instructs the module to bypass the package version check
and install the packaged identified in I(src) on the remote device.
type: bool
- default: no
+ default: false
force_host:
description:
- The I(force_host) argument controls the way software package or bundle is added
@@ -93,6 +99,64 @@ options:
used to load SSH information from a configuration file. If this option is not
given by default ~/.ssh/config is queried.
type: path
+ provider:
+ description:
+ - B(Deprecated)
+ - 'Starting with Ansible 2.5 we recommend using C(connection: network_cli) or
+ C(connection: netconf).'
+ - For more information please see the L(Junos OS Platform Options guide, ../network/user_guide/platform_junos.html).
+ - HORIZONTALLINE
+ - A dict object containing connection details.
+ type: dict
+ suboptions:
+ host:
+ description:
+ - Specifies the DNS host name or address for connecting to the remote device
+ over the specified transport. The value of host is used as the destination
+ address for the transport.
+ type: str
+ port:
+ description:
+ - Specifies the port to use when building the connection to the remote device. The
+ port value will default to the well known SSH port of 22 (for C(transport=cli))
+ or port 830 (for C(transport=netconf)) device.
+ type: int
+ username:
+ description:
+ - Configures the username to use to authenticate the connection to the remote
+ device. This value is used to authenticate the SSH session. If the value
+ is not specified in the task, the value of environment variable C(ANSIBLE_NET_USERNAME)
+ will be used instead.
+ type: str
+ password:
+ description:
+ - Specifies the password to use to authenticate the connection to the remote
+ device. This value is used to authenticate the SSH session. If the value
+ is not specified in the task, the value of environment variable C(ANSIBLE_NET_PASSWORD)
+ will be used instead.
+ type: str
+ timeout:
+ description:
+ - Specifies the timeout in seconds for communicating with the network device
+ for either connecting or sending commands. If the timeout is exceeded before
+ the operation is completed, the module will error.
+ type: int
+ ssh_keyfile:
+ description:
+ - Specifies the SSH key to use to authenticate the connection to the remote
+ device. This value is the path to the key used to authenticate the SSH
+ session. If the value is not specified in the task, the value of environment
+ variable C(ANSIBLE_NET_SSH_KEYFILE) will be used instead.
+ type: path
+ transport:
+ description:
+ - Configures the transport connection to use when connecting to the remote
+ device.
+ type: str
+ default: netconf
+ choices:
+ - cli
+ - netconf
requirements:
- junos-eznc
- ncclient (>=v0.5.2)
@@ -117,7 +181,7 @@ EXAMPLES = """
- name: install local package on remote device without rebooting
junipernetworks.junos.junos_package:
src: junos-vsrx-12.1X46-D10.2-domestic.tgz
- reboot: no
+ reboot: false
- name: install local package on remote device with jumpost
junipernetworks.junos.junos_package:
@@ -128,6 +192,7 @@ from ansible.module_utils.basic import AnsibleModule
from ansible_collections.junipernetworks.junos.plugins.module_utils.network.junos.junos import (
get_device,
+ junos_argument_spec,
)
@@ -143,6 +208,7 @@ def install_package(module, device):
junos = SW(device)
package = module.params["src"]
no_copy = module.params["no_copy"]
+ unlink = module.params["unlink"]
validate = module.params["validate"]
force_host = module.params["force_host"]
issu = module.params["issu"]
@@ -155,6 +221,7 @@ def install_package(module, device):
package,
progress=progress_log,
no_copy=no_copy,
+ unlink=unlink,
validate=validate,
force_host=force_host,
issu=issu,
@@ -175,6 +242,7 @@ def main():
version=dict(),
reboot=dict(type="bool", default=True),
no_copy=dict(default=False, type="bool"),
+ unlink=dict(default=False, type="bool"),
validate=dict(default=True, type="bool"),
force=dict(type="bool", default=False),
force_host=dict(type="bool", default=False),
@@ -183,11 +251,16 @@ def main():
ssh_config=dict(type="path"),
)
+ argument_spec.update(junos_argument_spec)
+
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
)
+ if module.params["provider"] is None:
+ module.params["provider"] = {}
+
if not HAS_PYEZ:
module.fail_json(
msg="junos-eznc is required but does not appear to be installed. "
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ping.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ping.py
index 4c373474c..67fc9a1f1 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_ping.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_ping.py
@@ -107,8 +107,8 @@ EXAMPLES = """
- name: Test reachability to 10.50.50.50 using do-not-fragment and rapid
junipernetworks.junos.junos_ping:
dest: 10.50.50.50
- df_bit: True
- rapid: True
+ df_bit: true
+ rapid: true
"""
RETURN = """
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_prefix_lists.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_prefix_lists.py
index 40b101f44..a6e0a32f3 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_prefix_lists.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_prefix_lists.py
@@ -117,45 +117,35 @@ EXAMPLES = """
- 172.16.7.32
- 172.16.9.32
state: merged
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "before": []
-# "commands": [
-# "<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
-# "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
-# "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
-# "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
-# "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
-# "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
-# "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
-# "</nc:prefix-list></nc:policy-options>"
-# ]
-#
-# "after": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.2.32/32",
-# "172.16.7.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
+
+# Task Output
+# -------------
+#
+# before: []
+# commands:
+# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# - "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
+# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
+# - "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
+# - "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
+# - "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
+# - "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
+# - "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
+# - "</nc:prefix-list></nc:policy-options>"
+# after:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.2.32/32
+# - 172.16.7.32/32
+# - 172.16.9.32/32
+# name: Test2
+
+
# After state
# -----------
#
@@ -172,7 +162,8 @@ EXAMPLES = """
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
-#
+
+
# Using gathered
#
# Before state
@@ -195,36 +186,28 @@ EXAMPLES = """
- name: Gather Junos prefix-lists
junipernetworks.junos.junos_prefix_lists:
state: gathered
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "gathered": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.2.32/32",
-# "172.16.7.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
-#
+
+
+# Task Output
+# -------------
+#
+# gathered:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.2.32/32
+# - 172.16.7.32/32
+# - 172.16.9.32/32
+# name: Test2
+
+
# Using replaced
-#
+
+
# Before state
# ------------
#
@@ -241,70 +224,54 @@ EXAMPLES = """
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
+
+
- name: Replace existing Junos prefix-lists configuration with provided config
junipernetworks.junos.junos_prefix_lists:
- config:
- - name: Test2
- address_prefixes:
- - 172.16.4.32
- - 172.16.8.32
- - 172.16.9.32"
- state: replaced
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "before": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.2.32/32",
-# "172.16.7.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
-# "commands": [
-# "<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# "<nc:prefix-list delete=\"delete\"><nc:name>Test2</nc:name></nc:prefix-list>"
-# "<nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item><nc:name>172.16.4.32</nc:name>"
-# "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.8.32</nc:name>"
-# "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.9.32</nc:name>"
-# "</nc:prefix-list-item></nc:prefix-list></nc:policy-options>"
-# ]
-#
-# "after": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.4.32/32",
-# "172.16.8.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
+ config:
+ - name: Test2
+ address_prefixes:
+ - 172.16.4.32
+ - 172.16.8.32
+ - 172.16.9.32"
+ state: replaced
+
+
+# Task Output
+# -------------
+#
+# before:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.2.32/32
+# - 172.16.7.32/32
+# - 172.16.9.32/32
+# name: Test2
+# commands:
+# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# - <nc:prefix-list delete="delete"><nc:name>Test2</nc:name></nc:prefix-list>
+# - "<nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item><nc:name>172.16.4.32</nc:name>"
+# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.8.32</nc:name>"
+# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.9.32</nc:name>"
+# - "</nc:prefix-list-item></nc:prefix-list></nc:policy-options>"
+# after:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.4.32/32
+# - 172.16.8.32/32
+# - 172.16.9.32/32
+# name: Test2
+
# After state
# -----------
#
@@ -321,8 +288,10 @@ EXAMPLES = """
# 172.16.8.32/32;
# 172.16.9.32/32;
# }
+
+
# Using overridden
-#
+
# Before state
# ------------
#
@@ -339,62 +308,50 @@ EXAMPLES = """
# 172.16.8.32/32;
# 172.16.9.32/32;
# }
+
+
- name: Override Junos prefix-lists configuration with provided configuration
junipernetworks.junos.junos_prefix_lists:
- config:
- - name: Test2
- address_prefixes:
- - 172.16.4.32/28
- - 172.16.8.32/28
- - 172.16.9.32/28
- state: overridden
-
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-# "before": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.4.32/32",
-# "172.16.8.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
-# "commands": [
-# "<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# "<nc:prefix-list delete=\"delete\"><nc:name>Internal</nc:name>"
-# "</nc:prefix-list><nc:prefix-list delete=\"delete\"><nc:name>Test1</nc:name>"
-# "</nc:prefix-list><nc:prefix-list delete=\"delete\"><nc:name>Test2</nc:name>"
-# "</nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item>"
-# "<nc:name>172.16.4.32/28</nc:name></nc:prefix-list-item><nc:prefix-list-item>"
-# "<nc:name>172.16.8.32/28</nc:name></nc:prefix-list-item><nc:prefix-list-item>"
-# "<nc:name>172.16.9.32/28</nc:name></nc:prefix-list-item></nc:prefix-list></nc:policy-options>"
-# ]
-#
-# "after": [
-# {
-# "address_prefixes": [
-# "172.16.4.32/28",
-# "172.16.8.32/28",
-# "172.16.9.32/28"
-# ],
-# "name": "Test2"
-# }
-# ]
+ config:
+ - name: Test2
+ address_prefixes:
+ - 172.16.4.32/28
+ - 172.16.8.32/28
+ - 172.16.9.32/28
+ state: overridden
+
+
+# Task Output
+# -------------
+#
+# before:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.4.32/32
+# - 172.16.8.32/32
+# - 172.16.9.32/32
+# name: Test2
+# commands:
+# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# - <nc:prefix-list delete="delete"><nc:name>Internal</nc:name>
+# - </nc:prefix-list><nc:prefix-list delete="delete"><nc:name>Test1</nc:name>
+# - </nc:prefix-list><nc:prefix-list delete="delete"><nc:name>Test2</nc:name>
+# - "</nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item>"
+# - "<nc:name>172.16.4.32/28</nc:name></nc:prefix-list-item><nc:prefix-list-item>"
+# - "<nc:name>172.16.8.32/28</nc:name></nc:prefix-list-item><nc:prefix-list-item>"
+# - "<nc:name>172.16.9.32/28</nc:name></nc:prefix-list-item></nc:prefix-list></nc:policy-options>"
+# after:
+# - address_prefixes:
+# - 172.16.4.32/28
+# - 172.16.8.32/28
+# - 172.16.9.32/28
+# name: Test2
+
# After state
# -----------
#
@@ -404,8 +361,11 @@ EXAMPLES = """
# 172.16.8.32/28;
# 172.16.9.32/28;
# }
+
+
# Using deleted
-#
+
+
# Before state
# ------------
#
@@ -423,52 +383,41 @@ EXAMPLES = """
# 172.16.9.32/32;
# }
+
- name: Delete provided prefix-lists
junipernetworks.junos.junos_prefix_lists:
- config:
- - name: "Test1"
- - name: "Test2"
- state: deleted
-# ------------------------
-# Module Execution Results
-# ------------------------
-#
-# "before": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.2.32/32",
-# "172.16.7.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
-# "commands": [
-# "<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# "<nc:prefix-list delete=\"delete\"><nc:name>Test1</nc:name></nc:prefix-list>"
-# "<nc:prefix-list delete=\"delete\"><nc:name>Test2</nc:name></nc:prefix-list></nc:policy-options>"
-# ]
-#
-# "after": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# }
-# ]
+ config:
+ - name: "Test1"
+ - name: "Test2"
+ state: deleted
+
+
+# Task Output
+# -------------
+#
+# before:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.2.32/32
+# - 172.16.7.32/32
+# - 172.16.9.32/32
+# name: Test2
+# commands:
+# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# - <nc:prefix-list delete="delete"><nc:name>Test1</nc:name></nc:prefix-list>
+# - <nc:prefix-list delete="delete"><nc:name>Test2</nc:name></nc:prefix-list></nc:policy-options>
+# after:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+
+
# After state
# -----------
#
@@ -478,8 +427,11 @@ EXAMPLES = """
# 172.16.3.32/32;
# }
#
+
+
# Using deleted without specifying config
-#
+
+
# Before state
# ------------
#
@@ -497,40 +449,33 @@ EXAMPLES = """
# 172.16.9.32/32;
# }
+
- name: Delete complete Junos prefix-lists configuration
junipernetworks.junos.junos_prefix_lists:
- state: deleted
+ state: deleted
+
+
+# Task Output
+# -------------
+#
+# before:
+# - address_prefixes:
+# - 172.16.1.32/32
+# - 172.16.3.32/32
+# name: Internal
+# - dynamic_db: true
+# name: Test1
+# - address_prefixes:
+# - 172.16.2.32/32
+# - 172.16.7.32/32
+# - 172.16.9.32/32
+# name: Test2
+# commands:
+# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# - <nc:prefix-list delete="delete"/></nc:policy-options>
+# after: []
+
-# ------------------------
-# Module Execution Results
-# ------------------------
-#
-# "before": [
-# {
-# "address_prefixes": [
-# "172.16.1.32/32",
-# "172.16.3.32/32"
-# ],
-# "name": "Internal"
-# },
-# {
-# "dynamic_db": true,
-# "name": "Test1"
-# },
-# {
-# "address_prefixes": [
-# "172.16.2.32/32",
-# "172.16.7.32/32",
-# "172.16.9.32/32"
-# ],
-# "name": "Test2"
-# }
-# ]
-# "commands": ["<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# "<nc:prefix-list delete=\"delete\"/></nc:policy-options>"
-# ]
-#
-# "after": []
# After state
# -----------
#
@@ -538,8 +483,10 @@ EXAMPLES = """
#
# [edit]
-#
+
# Using parsed
+
+
# parsed.cfg
# ------------
# <?xml version="1.0" encoding="UTF-8"?>
@@ -563,34 +510,28 @@ EXAMPLES = """
# </policy-options>
# </configuration>
# </rpc-reply>
+
+
- name: Parse running prefix-lists configuration
junipernetworks.junos.junos_prefix_lists:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "parsed": [
-# {
-# "name": "64510"
-# },
-# {
-# "address_prefixes": [
-# "172.16.1.16/28",
-# "172.16.1.32/28"
-# ],
-# "dynamic_db": true,
-# "name": "64500"
-# }
-# ]
-#
-#
+
+
+# Task Output
+# -------------
+# parsed:
+# - name: '64510'
+# - address_prefixes:
+# - 172.16.1.16/28
+# - 172.16.1.32/28
+# dynamic_db: true
+# name: '64500'
+
+
# Using rendered
-#
+
+
- name: Render the xml for provided configuration
junipernetworks.junos.junos_prefix_lists:
config:
@@ -606,43 +547,78 @@ EXAMPLES = """
- 172.16.7.32
- 172.16.9.32
state: rendered
-#
-#
-# -------------------------
-# Module Execution Result
-# -------------------------
-#
-#
-# "rendered": "<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
-# "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
-# "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name></nc:prefix-list-item>"
-# "</nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name><nc:dynamic-db/></nc:prefix-list>"
-# "<nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item><nc:name>172.16.2.32</nc:name>"
-# "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
-# "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
-# "</nc:prefix-list></nc:policy-options>"
+
+
+# Task Output
+# -------------
+# rendered:
+# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+# - "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
+# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
+# - "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
+# - "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
+# - "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
+# - "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
+# - "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
+# - "</nc:prefix-list></nc:policy-options>"
"""
-RETURN = """
+RRETURN = """
before:
description: The configuration prior to the model invocation.
returned: always
+ type: str
sample: >
The configuration returned will always be in the same format
of the parameters above.
- type: list
after:
description: The resulting configuration model invocation.
returned: when changed
+ type: str
sample: >
The configuration returned will always be in the same format
of the parameters above.
- type: list
commands:
description: The set of commands pushed to the remote device.
returned: always
type: list
- sample: ['<nc:policy-options xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
- "<nc:prefix-list delete=\"delete\"/></nc:policy-options>"', 'xml 2', 'command 3']
+ sample:
+ - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+ - "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
+ - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
+ - "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
+ - "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
+ - "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
+ - "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
+ - "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
+ - "</nc:prefix-list></nc:policy-options>"
+rendered:
+ description: The provided configuration in the task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+ - "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
+ - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
+ - "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
+ - "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
+ - "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
+ - "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
+ - "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
+ - "</nc:prefix-list></nc:policy-options>"
+gathered:
+ description: Facts about the network resource gathered from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_routing_instances.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_routing_instances.py
index 1b7c1c995..eec4720b8 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_routing_instances.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_routing_instances.py
@@ -312,21 +312,21 @@ EXAMPLES = """
- name: Replace existing Junos routing instance config with provided config
junipernetworks.junos.junos_routing_instances:
- config:
- address_family:
- - name: "test"
- type: "vrf"
- route_distinguisher: "10.57.255.1:37"
- vrf_imports:
- - "test-policy"
- vrf_exports:
- - "test-policy"
- interfaces:
- - name: "sp-0/0/0.0"
- - name: "gr-0/0/0.0"
- connector_id_advertise: false
- description: "Configured by Ansible Content Team"
- state: replaced
+ config:
+ address_family:
+ - name: "test"
+ type: "vrf"
+ route_distinguisher: "10.57.255.1:37"
+ vrf_imports:
+ - "test-policy"
+ vrf_exports:
+ - "test-policy"
+ interfaces:
+ - name: "sp-0/0/0.0"
+ - name: "gr-0/0/0.0"
+ connector_id_advertise: false
+ description: "Configured by Ansible Content Team"
+ state: replaced
# After state
# -----------
@@ -368,25 +368,25 @@ EXAMPLES = """
- name: Override Junos routing-instances configuration
junipernetworks.junos.junos_routing_instances:
- config:
- - name: "test"
- type: "vrf"
- route_distinguisher: "10.58.255.1:37"
- vrf_imports:
- - "test-policy"
- vrf_exports:
- - "test-policy"
- - "test-policy-1"
- interfaces:
- - name: "sp-0/0/0.0"
- - name: "gr-0/0/0.0"
- connector_id_advertise: true
- - name: "forwardinst"
- type: "forwarding"
- description: "Configured by Ansible Content Team"
- - name: "vtest1"
- type: "virtual-router"
- state: overridden
+ config:
+ - name: "test"
+ type: "vrf"
+ route_distinguisher: "10.58.255.1:37"
+ vrf_imports:
+ - "test-policy"
+ vrf_exports:
+ - "test-policy"
+ - "test-policy-1"
+ interfaces:
+ - name: "sp-0/0/0.0"
+ - name: "gr-0/0/0.0"
+ connector_id_advertise: true
+ - name: "forwardinst"
+ type: "forwarding"
+ description: "Configured by Ansible Content Team"
+ - name: "vtest1"
+ type: "virtual-router"
+ state: overridden
# After state
# -----------
@@ -432,9 +432,9 @@ EXAMPLES = """
- name: Delete provided junos routing-instamce
junipernetworks.junos.junos_routing_instances:
- config:
- - name: "test"
- state: deleted
+ config:
+ - name: "test"
+ state: deleted
# After state
# -----------
@@ -470,8 +470,8 @@ EXAMPLES = """
- name: Delete complete Junos routing-instances config
junipernetworks.junos.junos_routing_instances:
- config:
- state: deleted
+ config:
+ state: deleted
# After state
# -----------
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.py
index 34657ae8d..605450053 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_scp.py
@@ -19,6 +19,10 @@ description:
version_added: 1.0.0
extends_documentation_fragment:
- junipernetworks.junos.junos
+deprecated:
+ why: Updated modules released with more functionality
+ alternative: Use M(ansible.netcommon.net_get), M(ansible.netcommon.net_put) instead.
+ removed_at_date: '2025-01-01'
options:
src:
description:
@@ -56,6 +60,64 @@ options:
used to load SSH information from a configuration file. If this option is not
given by default ~/.ssh/config is queried.
type: path
+ provider:
+ description:
+ - B(Deprecated)
+ - 'Starting with Ansible 2.5 we recommend using C(connection: network_cli) or
+ C(connection: netconf).'
+ - For more information please see the L(Junos OS Platform Options guide, ../network/user_guide/platform_junos.html).
+ - HORIZONTALLINE
+ - A dict object containing connection details.
+ type: dict
+ suboptions:
+ host:
+ description:
+ - Specifies the DNS host name or address for connecting to the remote device
+ over the specified transport. The value of host is used as the destination
+ address for the transport.
+ type: str
+ port:
+ description:
+ - Specifies the port to use when building the connection to the remote device. The
+ port value will default to the well known SSH port of 22 (for C(transport=cli))
+ or port 830 (for C(transport=netconf)) device.
+ type: int
+ username:
+ description:
+ - Configures the username to use to authenticate the connection to the remote
+ device. This value is used to authenticate the SSH session. If the value
+ is not specified in the task, the value of environment variable C(ANSIBLE_NET_USERNAME)
+ will be used instead.
+ type: str
+ password:
+ description:
+ - Specifies the password to use to authenticate the connection to the remote
+ device. This value is used to authenticate the SSH session. If the value
+ is not specified in the task, the value of environment variable C(ANSIBLE_NET_PASSWORD)
+ will be used instead.
+ type: str
+ timeout:
+ description:
+ - Specifies the timeout in seconds for communicating with the network device
+ for either connecting or sending commands. If the timeout is exceeded before
+ the operation is completed, the module will error.
+ type: int
+ ssh_keyfile:
+ description:
+ - Specifies the SSH key to use to authenticate the connection to the remote
+ device. This value is the path to the key used to authenticate the SSH
+ session. If the value is not specified in the task, the value of environment
+ variable C(ANSIBLE_NET_SSH_KEYFILE) will be used instead.
+ type: path
+ transport:
+ description:
+ - Configures the transport connection to use when connecting to the remote
+ device.
+ type: str
+ default: netconf
+ choices:
+ - cli
+ - netconf
requirements:
- junos-eznc
- ncclient (>=v0.5.2)
@@ -104,6 +166,7 @@ from ansible.module_utils.basic import AnsibleModule
from ansible_collections.junipernetworks.junos.plugins.module_utils.network.junos.junos import (
get_device,
+ junos_argument_spec,
)
@@ -138,11 +201,15 @@ def main():
ssh_config=dict(type="path"),
)
+ argument_spec.update(junos_argument_spec)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
)
+ if module.params["provider"] is None:
+ module.params["provider"] = {}
+
if not HAS_PYEZ:
module.fail_json(
msg="junos-eznc is required but does not appear to be installed. "
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_policies.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_policies.py
index bf8c4f6ee..8d8f50f02 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_policies.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_policies.py
@@ -2545,18 +2545,18 @@ EXAMPLES = """
- junipernetworks.junos.junos_security_policies:
config:
global:
- policies:
- - description: test update
- match:
- application:
- any: true
- destination_address:
- any_ipv6: true
- source_address:
- any: true
- name: test_glob_3
- then:
- deny: true
+ policies:
+ - description: test update
+ match:
+ application:
+ any: true
+ destination_address:
+ any_ipv6: true
+ source_address:
+ any: true
+ name: test_glob_3
+ then:
+ deny: true
state: rendered
#
# -------------------------
@@ -2581,8 +2581,6 @@ EXAMPLES = """
# </nc:global>
# </nc:policies>
# </nc:security>"
-
-
"""
RETURN = """
before:
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_zones.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_zones.py
index 36032cbca..384e92a21 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_zones.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_security_zones.py
@@ -291,7 +291,8 @@ options:
connection to remote host is not required.
type: str
"""
-EXAMPLES = """# Using merged
+EXAMPLES = """
+# Using merged
#
# Before state
# ------------
@@ -308,72 +309,72 @@ EXAMPLES = """# Using merged
description: test description
host_inbound_traffic:
protocols:
- - name: all
- - name: bgp
- except: true
+ - name: all
+ - name: bgp
+ except: true
system_services:
- - name: all
- - except: true
- name: dhcp
+ - name: all
+ - except: true
+ name: dhcp
interfaces:
- ge-0/0/1.0
- ge-0/0/2.0
screen: test_screen
security_zones:
- - address_book:
- address_sets:
- - addresses:
- - test_adr1
- - test_adr2
- name: test_adrset1
- - addresses:
- - test_adr3
- - test_adr4
- name: test_adrset2
- - address_sets:
- - test_adrset1
- - test_adrset2
+ - address_book:
+ address_sets:
+ - addresses:
+ - test_adr1
+ - test_adr2
+ name: test_adrset1
+ - addresses:
+ - test_adr3
+ - test_adr4
+ name: test_adrset2
+ - address_sets:
+ - test_adrset1
+ - test_adrset2
+ addresses:
+ - test_adr5
+ description: test description
+ name: test_adrset3
addresses:
- - test_adr5
- description: test description
- name: test_adrset3
- addresses:
- - description: test desc
- ip_prefix: 10.0.0.0/24
- name: test_adr1
- - dns_name:
- ipv6_only: true
- name: 1.1.1.1
- name: test_adr2
- - name: test_adr3
- range_address:
- from: 10.2.0.1
- to: 10.2.0.2
- - name: test_adr4
- wildcard_address: 10.3.0.1/24
- - description: test desc
- ip_prefix: 10.1.0.0/24
- name: test_adr5
- advance_policy_based_routing_profile: test_profile
- application_tracking: true
- description: test description
- enable_reverse_reroute: true
- host_inbound_traffic:
- protocols:
- - name: all
- - except: true
- name: bgp
- system_services:
- - name: all
- - except: true
- name: dhcp
- interfaces:
- - ge-0/0/3.0
- - ge-0/0/4.0
- name: test_sec_zone1
- screen: test_screen
- source_identity_log: true
- tcp_rst: true
+ - description: test desc
+ ip_prefix: 10.0.0.0/24
+ name: test_adr1
+ - dns_name:
+ ipv6_only: true
+ name: 1.1.1.1
+ name: test_adr2
+ - name: test_adr3
+ range_address:
+ from: 10.2.0.1
+ to: 10.2.0.2
+ - name: test_adr4
+ wildcard_address: 10.3.0.1/24
+ - description: test desc
+ ip_prefix: 10.1.0.0/24
+ name: test_adr5
+ advance_policy_based_routing_profile: test_profile
+ application_tracking: true
+ description: test description
+ enable_reverse_reroute: true
+ host_inbound_traffic:
+ protocols:
+ - name: all
+ - except: true
+ name: bgp
+ system_services:
+ - name: all
+ - except: true
+ name: dhcp
+ interfaces:
+ - ge-0/0/3.0
+ - ge-0/0/4.0
+ name: test_sec_zone1
+ screen: test_screen
+ source_identity_log: true
+ tcp_rst: true
state: merged
#
# -------------------------
@@ -732,16 +733,16 @@ EXAMPLES = """# Using merged
description: test description
host_inbound_traffic:
protocols:
- - name: all
- - name: bgp
- except: true
+ - name: all
+ - name: bgp
+ except: true
system_services:
- - name: all
- - except: true
- name: dhcp
- interfaces:
- - ge-0/0/1.0
- - ge-0/0/2.0
+ - name: all
+ - except: true
+ name: dhcp
+ interfaces:
+ - ge-0/0/1.0
+ - ge-0/0/2.0
screen: test_screen
state: replaced
#
@@ -1047,13 +1048,13 @@ EXAMPLES = """# Using merged
description: test description
host_inbound_traffic:
protocols:
- - name: all
- - name: bgp
- except: true
+ - name: all
+ - name: bgp
+ except: true
system_services:
- - name: all
- - except: true
- name: dhcp
+ - name: all
+ - except: true
+ name: dhcp
interfaces:
- ge-0/0/1.0
- ge-0/0/2.0
@@ -1580,72 +1581,72 @@ EXAMPLES = """# Using merged
description: test description
host_inbound_traffic:
protocols:
- - name: all
- - name: bgp
- except: true
+ - name: all
+ - name: bgp
+ except: true
system_services:
- - name: all
- - except: true
- name: dhcp
+ - name: all
+ - except: true
+ name: dhcp
interfaces:
- ge-0/0/1.0
- ge-0/0/2.0
screen: test_screen
security_zones:
- - address_book:
- address_sets:
- - addresses:
- - test_adr1
- - test_adr2
- name: test_adrset1
- - addresses:
- - test_adr3
- - test_adr4
- name: test_adrset2
- - address_sets:
- - test_adrset1
- - test_adrset2
+ - address_book:
+ address_sets:
+ - addresses:
+ - test_adr1
+ - test_adr2
+ name: test_adrset1
+ - addresses:
+ - test_adr3
+ - test_adr4
+ name: test_adrset2
+ - address_sets:
+ - test_adrset1
+ - test_adrset2
+ - addresses:
+ - test_adr5
+ description: test description
+ name: test_adrset3
addresses:
- - test_adr5
- description: test description
- name: test_adrset3
- addresses:
- - description: test desc
- ip_prefix: 10.0.0.0/24
- name: test_adr1
- - dns_name:
- ipv6_only: true
- name: 1.1.1.1
- name: test_adr2
- - name: test_adr3
- range_address:
- from: 10.2.0.1
- to: 10.2.0.2
- - name: test_adr4
- wildcard_address: 10.3.0.1/24
- - description: test desc
- ip_prefix: 10.1.0.0/24
- name: test_adr5
- advance_policy_based_routing_profile: test_profile
- application_tracking: true
- description: test description
- enable_reverse_reroute: true
- host_inbound_traffic:
- protocols:
- - name: all
- - except: true
- name: bgp
- system_services:
- - name: all
- - except: true
- name: dhcp
- interfaces:
- - ge-0/0/3.0
- - ge-0/0/4.0
- name: test_sec_zone1
- screen: test_screen
- source_identity_log: true
- tcp_rst: true
+ - description: test desc
+ ip_prefix: 10.0.0.0/24
+ name: test_adr1
+ - dns_name:
+ ipv6_only: true
+ name: 1.1.1.1
+ name: test_adr2
+ - name: test_adr3
+ range_address:
+ from: 10.2.0.1
+ to: 10.2.0.2
+ - name: test_adr4
+ wildcard_address: 10.3.0.1/24
+ - description: test desc
+ ip_prefix: 10.1.0.0/24
+ name: test_adr5
+ advance_policy_based_routing_profile: test_profile
+ application_tracking: true
+ description: test description
+ enable_reverse_reroute: true
+ host_inbound_traffic:
+ protocols:
+ - name: all
+ - except: true
+ name: bgp
+ system_services:
+ - name: all
+ - except: true
+ name: dhcp
+ interfaces:
+ - ge-0/0/3.0
+ - ge-0/0/4.0
+ name: test_sec_zone1
+ screen: test_screen
+ source_identity_log: true
+ tcp_rst: true
state: rendered
#
# -------------------------
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_snmp_server.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_snmp_server.py
index 491298327..0e2b286ec 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_snmp_server.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_snmp_server.py
@@ -887,15 +887,15 @@ EXAMPLES = """
set: true
host_name_resolution: true
client_lists: # ATTR-----2
- - name: cl1
- addresses:
- - address: "192.16.1.0/24"
- - address: "192.16.2.0/24"
- - address: "11.11.11.11"
- restrict: true
- - name: cl2
- addresses:
- - address: "192.16.4.0/24"
+ - name: cl1
+ addresses:
+ - address: "192.16.1.0/24"
+ - address: "192.16.2.0/24"
+ - address: "11.11.11.11"
+ restrict: true
+ - name: cl2
+ addresses:
+ - address: "192.16.4.0/24"
routing_instance_access: # ATTR-----3
set: true
access_lists:
@@ -1022,16 +1022,16 @@ EXAMPLES = """
config:
contact: "ansiblesupport11@redhat.com"
customization:
- ether_stats_ifd_only: True
+ ether_stats_ifd_only: true
description: "Local SNMP Server"
engine_id:
local: "local1"
- use_default_ip_address: True
- use_mac_address: True
- filter_duplicates: True
+ use_default_ip_address: true
+ use_mac_address: true
+ filter_duplicates: true
filter_interfaces:
- set: True
- all_internal_interfaces: True
+ set: true
+ all_internal_interfaces: true
interfaces:
- "eth1"
- "eth2"
@@ -1172,20 +1172,20 @@ EXAMPLES = """
config:
contact: "ansiblesupport11@redhat.com"
customization:
- ether_stats_ifd_only: True
+ ether_stats_ifd_only: true
description: "Local SNMP Server"
engine_id:
local: "local1"
- use_default_ip_address: True
- use_mac_address: True
- filter_duplicates: True
+ use_default_ip_address: true
+ use_mac_address: true
+ filter_duplicates: true
filter_interfaces:
- set: True
- all_internal_interfaces: True
+ set: true
+ all_internal_interfaces: true
interfaces:
- "eth1"
- "eth2"
- state: overridden
+ state: overridden
#
# -------------------------
# Module Execution Result
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_static_routes.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_static_routes.py
index 7efe112a7..f89c66783 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_static_routes.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_static_routes.py
@@ -127,27 +127,50 @@ EXAMPLES = """
# static {
# route 192.168.47.0/24 next-hop 172.16.1.2;
# route 192.168.16.0/24 next-hop 172.16.1.2;
-# route 10.200.16.75/24 next-hop 10.200.16.2;
# }
- name: Delete provided configuration (default operation is merge)
junipernetworks.junos.junos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 10.200.16.75/24
- next_hop:
- - forward_router_address: 10.200.16.2
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.168.16.0/24
+ next_hop:
+ - forward_router_address: 172.16.1.2
state: deleted
+# Task Output
+# -----------
+# before:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# commands:
+# - '<nc:routing-options
+# xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:static><nc:route
+# delete="delete"><nc:name>192.168.16.0/24</nc:name></nc:route></nc:static></nc:routing-options>'
+# - '<nc:routing-instances xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>'
+# after:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+
# After state:
# ------------
#
# admin# show routing-options
# static {
# route 192.168.47.0/24 next-hop 172.16.1.2;
-# route 192.168.16.0/24 next-hop 172.16.1.2;
# }
# Using merged
@@ -158,21 +181,44 @@ EXAMPLES = """
# admin# show routing-options
# static {
# route 192.168.47.0/24 next-hop 172.16.1.2;
-# route 192.168.16.0/24 next-hop 172.16.1.2;
# }
- name: Merge provided configuration with device configuration (default operation
is merge)
junipernetworks.junos.junos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 10.200.16.75/24
- next_hop:
- - forward_router_address: 10.200.16.2
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.168.16.0/24
+ next_hop:
+ - forward_router_address: 172.16.1.2
state: merged
+# Task Output
+# -----------
+# before:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# commands:
+# - '<nc:routing-options
+# xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:static><nc:route><nc:name>192.168.16.0/24</nc:name>
+# <nc:next-hop>172.16.1.2</nc:next-hop></nc:route></nc:static></nc:routing-options>'
+# - '<nc:routing-instances xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>'
+# after:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
# After state:
# ------------
#
@@ -180,7 +226,6 @@ EXAMPLES = """
# static {
# route 192.168.47.0/24 next-hop 172.16.1.2;
# route 192.168.16.0/24 next-hop 172.16.1.2;
-# route 10.200.16.75/24 next-hop 10.200.16.2;
# }
# Using overridden
@@ -191,27 +236,53 @@ EXAMPLES = """
# admin# show routing-options
# static {
# route 192.168.47.0/24 next-hop 172.16.1.2;
-# route 192.168.16.0/24 next-hop 172.16.0.1;
+# route 192.168.16.0/24 next-hop 172.16.1.2;
# }
-- name: Override provided configuration with device configuration (default operation
+- name: Override running configuration with provided configuration (default operation
is merge)
junipernetworks.junos.junos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 10.200.16.75/24
- next_hop:
- - forward_router_address: 10.200.16.2
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.168.16.0/24
+ next_hop:
+ - forward_router_address: 172.16.0.1
state: overridden
+# Task Output:
+# ------------
+# before:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# commands:
+# - >-
+# <nc:routing-options
+# xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:static><nc:route
+# delete="delete"><nc:name>192.168.47.0/24</nc:name></nc:route><nc:route
+# delete="delete"><nc:name>192.168.16.0/24</nc:name></nc:route></nc:static><nc:static><nc:route><nc:name>192.168.16.0/24</nc:name><nc:next-hop>172.16.0.1</nc:next-hop></nc:route></nc:static></nc:routing-options>
+# - '<nc:routing-instances xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>'
+# after:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.0.1
# After state:
# ------------
#
# admin# show routing-options
# static {
-# route 10.200.16.75/24 next-hop 10.200.16.2;
+# route 192.168.16.0/24 next-hop 172.16.0.1;
# }
# Using replaced
@@ -229,14 +300,43 @@ EXAMPLES = """
is merge)
junipernetworks.junos.junos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 192.168.47.0/24
- next_hop:
- - forward_router_address: 10.200.16.2
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.168.47.0/24
+ next_hop:
+ - forward_router_address: 10.200.16.2
state: replaced
+# Task Output:
+# ------------
+# before:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# commands:
+# - >-
+# <nc:routing-options
+# xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:static><nc:route
+# delete="delete"><nc:name>192.168.47.0/24</nc:name></nc:route></nc:static><nc:static><nc:route><nc:name>192.168.47.0/24</nc:name><nc:next-hop>10.200.16.2</nc:next-hop></nc:route></nc:static></nc:routing-options>
+# - '<nc:routing-instances xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>'
+# after:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 10.200.16.2
+
# After state:
# ------------
#
@@ -246,7 +346,92 @@ EXAMPLES = """
# route 192.168.16.0/24 next-hop 172.16.1.2;
# }
+# Using gathered to gather static route facts from the device
+# Before state
+# ------------
+# admin# show routing-options
+# static {
+# route 192.168.16.0/24 next-hop 172.16.1.2;
+# route 192.168.47.0/24 next-hop 10.200.16.2;
+# }
+- name: Gather static routes facts from the device using junos_static_routes module
+ junipernetworks.junos.junos_static_routes:
+ state: gathered
+
+# Task output:
+# ------------
+# gathered:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: 172.16.1.2
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 10.200.16.2
+
+# Using rendered
+
+- name: Render platform specific commands (without connecting to the device)
+ junipernetworks.junos.junos_static_routes:
+ config:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.168.16.0/24
+ next_hop:
+ - forward_router_address: 172.16.1.2
+ state: rendered
+
+# Task output:
+# ------------
+# rendered:
+# - '<nc:routing-options
+# xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:static><nc:route><nc:name>192.168.16.0/24</nc:name>
+# <nc:next-hop>172.16.1.2</nc:next-hop></nc:route></nc:static></nc:routing-options>'
+
+# 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">
+# <version>18.4R1-S2.4</version>
+# <routing-options>
+# <static>
+# <route>
+# <name>192.168.16.0/24</name>
+# <next-hop>172.16.1.2</next-hop>
+# <next-hop>172.16.1.3</next-hop>
+# </route>
+# <route>
+# <name>192.168.47.0/24</name>
+# <next-hop>10.200.16.2</next-hop>
+# </route>
+# </static>
+# </routing-options>
+# </configuration>
+# </rpc-reply>
+
+- name: Parsed running config (without connecting to the device)
+ junipernetworks.junos.junos_static_routes:
+ running_config: "{{ lookup('file', 'parsed.cfg') }}"
+ state: parsed
+# Task output:
+# ------------
+# parsed:
+# - address_families:
+# - afi: ipv4
+# routes:
+# - dest: 192.168.16.0/24
+# next_hop:
+# - forward_router_address: '[''172.16.1.2'', ''172.16.1.3'']'
+# - dest: 192.168.47.0/24
+# next_hop:
+# - forward_router_address: 10.200.16.2
"""
RETURN = """
before:
@@ -268,6 +453,26 @@ commands:
returned: always
type: list
sample: ['command 1', 'command 2', 'command 3']
+rendered:
+ description: The provided configuration in the task rendered in device-native format (offline).
+ returned: when I(state) is C(rendered)
+ type: list
+ sample:
+ - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
+gathered:
+ description: Facts about the network resource gathered from the remote device as structured data.
+ returned: when I(state) is C(gathered)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
+parsed:
+ description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
+ returned: when I(state) is C(parsed)
+ type: list
+ sample: >
+ This output will always be in the same format as the
+ module argspec.
"""
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_system.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_system.py
index c70ded66f..011a842f5 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_system.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_system.py
@@ -76,9 +76,9 @@ EXAMPLES = """
hostname: junos01
domain_name: test.example.com
domain-search:
- - ansible.com
- - redhat.com
- - juniper.net
+ - ansible.com
+ - redhat.com
+ - juniper.net
- name: remove configuration
junipernetworks.junos.junos_system:
@@ -87,8 +87,8 @@ EXAMPLES = """
- name: configure name servers
junipernetworks.junos.junos_system:
name_servers:
- - 8.8.8.8
- - 8.8.4.4
+ - 8.8.8.8
+ - 8.8.4.4
"""
RETURN = """
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_user.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_user.py
index 0e9ee8ad9..018dd88f8 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_user.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_user.py
@@ -124,7 +124,7 @@ options:
absolute. It will remove any previously configured users on the device with
the exception of the current defined set of aggregate.
type: bool
- default: no
+ default: false
state:
description:
- The C(state) argument configures the state of the user definitions as it relates
@@ -140,7 +140,7 @@ options:
description:
- Specifies whether or not the configuration is active or deactivated
type: bool
- default: yes
+ default: true
requirements:
- ncclient (>=v0.5.2)
notes:
@@ -167,8 +167,8 @@ EXAMPLES = """
- name: remove all user accounts except ansible
junipernetworks.junos.junos_user:
aggregate:
- - name: ansible
- purge: yes
+ - name: ansible
+ purge: true
- name: set user password
junipernetworks.junos.junos_user:
@@ -180,16 +180,15 @@ EXAMPLES = """
- name: Create list of users
junipernetworks.junos.junos_user:
aggregate:
- - {name: test_user1, full_name: test_user2, role: operator, state: present}
- - {name: test_user2, full_name: test_user2, role: read-only, state: present}
+ - {name: test_user1, full_name: test_user2, role: operator, state: present}
+ - {name: test_user2, full_name: test_user2, role: read-only, state: present}
- name: Delete list of users
junipernetworks.junos.junos_user:
aggregate:
- - {name: test_user1, full_name: test_user2, role: operator, state: absent}
- - {name: test_user2, full_name: test_user2, role: read-only, state: absent}
+ - {name: test_user1, full_name: test_user2, role: operator, state: absent}
+ - {name: test_user2, full_name: test_user2, role: read-only, state: absent}
"""
-
RETURN = """
diff.prepared:
description: Configuration difference before and after applying change.
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_vlans.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_vlans.py
index 32f974df6..e1c834d89 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_vlans.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_vlans.py
@@ -107,11 +107,11 @@ EXAMPLES = """
- name: Merge provided Junos vlans config with running-config
junipernetworks.junos.junos_vlans:
config:
- - name: vlan1
- vlan_id: 1
- - name: vlan2
- vlan_id: 2
- l3_interface: irb.12
+ - name: vlan1
+ vlan_id: 1
+ - name: vlan2
+ vlan_id: 2
+ l3_interface: irb.12
state: merged
#
# -------------------------
@@ -165,12 +165,12 @@ EXAMPLES = """
- name: Replace Junos vlans running-config with the provided config
junipernetworks.junos.junos_vlans:
config:
- - name: vlan1
- vlan_id: 11
- l3_interface: irb.10
+ - name: vlan1
+ vlan_id: 11
+ l3_interface: irb.10
- - name: vlan2
- vlan_id: 2
+ - name: vlan2
+ vlan_id: 2
state: replaced
# -------------------------
# Module Execution Result
@@ -234,9 +234,9 @@ EXAMPLES = """
- name: Override Junos running-config with provided config
junipernetworks.junos.junos_vlans:
config:
- - name: vlan3
- vlan_id: 3
- l3_interface: irb.13
+ - name: vlan3
+ vlan_id: 3
+ l3_interface: irb.13
state: overridden
# -------------------------
# Module Execution Result
@@ -288,7 +288,7 @@ EXAMPLES = """
- name: Delete specific vlan
junipernetworks.junos.junos_vlans:
config:
- - name: vlan3
+ - name: vlan3
state: deleted
# -------------------------
# Module Execution Result
@@ -340,12 +340,12 @@ EXAMPLES = """
- name: Render xml for provided facts.
junipernetworks.junos.junos_vlans:
config:
- - name: vlan1
- vlan_id: 1
+ - name: vlan1
+ vlan_id: 1
- - name: vlan2
- vlan_id: 2
- l3_interface: irb.12
+ - name: vlan2
+ vlan_id: 2
+ l3_interface: irb.12
state: rendered
#
# -------------------------
diff --git a/ansible_collections/junipernetworks/junos/plugins/modules/junos_vrf.py b/ansible_collections/junipernetworks/junos/plugins/modules/junos_vrf.py
index e2332d1c5..3da30d81c 100644
--- a/ansible_collections/junipernetworks/junos/plugins/modules/junos_vrf.py
+++ b/ansible_collections/junipernetworks/junos/plugins/modules/junos_vrf.py
@@ -151,8 +151,8 @@ EXAMPLES = """
name: test-1
description: test-vrf-1
interfaces:
- - ge-0/0/3
- - ge-0/0/2
+ - ge-0/0/3
+ - ge-0/0/2
rd: 192.0.2.1:10
target: target:65514:113
state: present
@@ -162,8 +162,8 @@ EXAMPLES = """
name: test-1
description: test-vrf-1
interfaces:
- - ge-0/0/3
- - ge-0/0/2
+ - ge-0/0/3
+ - ge-0/0/2
rd: 192.0.2.1:10
target: target:65514:113
state: absent
@@ -173,8 +173,8 @@ EXAMPLES = """
name: test-1
description: test-vrf-1
interfaces:
- - ge-0/0/3
- - ge-0/0/2
+ - ge-0/0/3
+ - ge-0/0/2
rd: 192.0.2.1:10
target: target:65514:113
active: false
@@ -184,8 +184,8 @@ EXAMPLES = """
name: test-1
description: test-vrf-1
interfaces:
- - ge-0/0/3
- - ge-0/0/2
+ - ge-0/0/3
+ - ge-0/0/2
rd: 192.0.2.1:10
target: target:65514:113
active: true
@@ -193,19 +193,19 @@ EXAMPLES = """
- name: Create vrf using aggregate
junipernetworks.junos.junos_vrf:
aggregate:
- - name: test-1
- description: test-vrf-1
- interfaces:
- - ge-0/0/3 - ge-0/0/2
- rd: 192.0.2.1:10
- target: target:65514:113
- - name: test-2
- description: test-vrf-2
- interfaces:
- - ge-0/0/4
- - ge-0/0/5
- rd: 192.0.2.2:10
- target: target:65515:114
+ - name: test-1
+ description: test-vrf-1
+ interfaces:
+ - ge-0/0/3 - ge-0/0/2
+ rd: 192.0.2.1:10
+ target: target:65514:113
+ - name: test-2
+ description: test-vrf-2
+ interfaces:
+ - ge-0/0/4
+ - ge-0/0/5
+ rd: 192.0.2.2:10
+ target: target:65515:114
state: present
"""